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 /frm | |
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 'frm')
-rw-r--r-- | frm/common.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/frm/common.c b/frm/common.c index a604a2d22..0045e604b 100644 --- a/frm/common.c +++ b/frm/common.c @@ -63,10 +63,6 @@ get_charset () if (!output_charset) { char *tmp; - const char *str = NULL; - char locale[32]; - - memset (locale, 0, sizeof (locale)); /* Try to deduce the charset from LC_ALL or LANG variables */ @@ -76,24 +72,14 @@ get_charset () if (tmp) { - char *sp = NULL; - char *lang; - char *terr; - - strncpy (locale, tmp, sizeof (locale) - 1); + struct mu_lc_all lc_all; - lang = strtok_r (locale, "_", &sp); - terr = strtok_r (NULL, ".", &sp); - str = strtok_r (NULL, "@", &sp); - - if (!str) - str = mu_charset_lookup (lang, terr); + if (mu_parse_lc_all (tmp, &lc_all, MU_LC_CSET) == 0) + output_charset = lc_all.charset; } - if (!str) - str = "ASCII"; - - output_charset = xstrdup (str); + if (!output_charset) + output_charset = xstrdup ("ASCII"); } return output_charset; } |