diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-02 10:14:43 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-02 10:14:43 +0200 |
commit | 38d688c17f9545c032e22f117189b970e858697d (patch) | |
tree | d0ba9311b365c6b187205d43491c9c7eb2de834c /mail/escape.c | |
parent | 0fac46ab0e306070a46c5016cf2cf52c776c791c (diff) | |
download | mailutils-38d688c17f9545c032e22f117189b970e858697d.tar.gz mailutils-38d688c17f9545c032e22f117189b970e858697d.tar.bz2 |
Avoid using strtok(_r)
* TODO: Update.
* gnulib.modules: Remove strtok_r
* imap4d/auth_gsasl.c (auth_gsasl_capa_init): Use mu_wordsplit instead
of strtok.
* imap4d/imap4d.h (strtok_r): Remove declaration.
* lib/mailcap.c (mime_context) <no_ask_str>: Remove. All uses updated.
(mime_context_fill): Use mu_wordsplit instead
of strtok.
(mime_context_write_input): Tolerate ENOSYS return from mu_stream_seek.
(display_stream_mailcap): Use mu_wordsplit instead
of strtok.
* libmailutils/diag/gdebug.c (mu_debug_level_from_string)
(mu_global_debug_from_string): Use mu_wordsplit instead of strtok.
* libmu_cfg/sieve.c (_add_path): Likewise.
* libmu_sieve/extensions/list.c: Likewise.
* mail/escape.c (quote0): Likewise.
* mail/util.c (util_header_expand): Likewise.
(util_rfc2047_decode): Use mu_parse_lc_all.
* mh/mh_init.c (mh_charset): Use mu_parse_lc_all.
* frm/common.c (get_charset): Use mu_parse_lc_all.
* libmailutils/base/lcall.c: New file.
* libmailutils/base/Makefile.am (libbase_la_SOURCES): Add lcall.c
* libmailutils/string/strlst.c: New file.
* libmailutils/string/Makefile.am (libstring_la_SOURCES): Add strlst.c.
* include/mailutils/cstr.h: Include mailutils/types.h
(mu_string_split): New proto.
* include/mailutils/nls.h (MU_LC_LANG, MU_LC_TERR)
(MU_LC_CSET,MU_LC_MOD): New flags.
(mu_lc_all): New struct.
(mu_parse_lc_all, mu_lc_all_free): New protos.
(mu_charset_lookup): New proto (from util.h).
* include/mailutils/util.h (mu_charset_lookup): Move to nls.h
* libmailutils/base/tempfile.c (mu_tempname): Shut up compiler
warning.
Diffstat (limited to 'mail/escape.c')
-rw-r--r-- | mail/escape.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/mail/escape.c b/mail/escape.c index 27d8c2f12..18e60e0aa 100644 --- a/mail/escape.c +++ b/mail/escape.c @@ -443,7 +443,8 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) mu_header_t hdr; mu_body_t body; mu_stream_t stream; - char buffer[512]; + char *buffer = NULL; + size_t size = 0; size_t n = 0; char *prefix = "\t"; @@ -465,22 +466,18 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) mu_header_sget_field_name (hdr, i, &sptr); if (mail_header_is_visible (sptr)) { - char *value; + const char *value; fprintf (ofile, "%s%s: ", prefix, sptr); - if (mu_header_aget_value (hdr, sptr, &value) == 0) + if (mu_header_sget_value (hdr, sptr, &value) == 0) { - int i; - char *p, *s; - - for (i = 0, p = strtok_r (value, "\n", &s); p; - p = strtok_r (NULL, "\n", &s), i++) + for (; *value; value++) { - if (i) + fputc (*value, ofile); + if (*value == '\n') fprintf (ofile, "%s", prefix); - fprintf (ofile, "%s\n", p); } - free (value); + fputc ('\n', ofile); } } } @@ -498,12 +495,9 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) } /* FIXME: Use mu_stream_copy? */ - while (mu_stream_readline (stream, buffer, sizeof buffer - 1, &n) == 0 - && n != 0) - { - buffer[n] = '\0'; - fprintf (ofile, "%s%s", prefix, buffer); - } + while (mu_stream_getline (stream, &buffer, &size, &n) == 0 && n != 0) + fprintf (ofile, "%s%s", prefix, buffer); + free (buffer); mu_stream_destroy (&stream); return 0; } |