diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-02-27 11:46:26 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-02-27 11:46:26 +0000 |
commit | 4ff6e11df26f4504c30fd5f2e981296e83c74dd9 (patch) | |
tree | 0fef9fc7e63d9ddcd685add5e24f21bf95d32f3d /Src/utils.c | |
parent | e21bd541a286cd3946a3951e3dad88a0ef46d530 (diff) | |
download | zsh-4ff6e11df26f4504c30fd5f2e981296e83c74dd9.tar.gz zsh-4ff6e11df26f4504c30fd5f2e981296e83c74dd9.tar.xz zsh-4ff6e11df26f4504c30fd5f2e981296e83c74dd9.zip |
24609: try to be safe about using libiconv
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Src/utils.c b/Src/utils.c index eab36de2a..a5b81420f 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4880,15 +4880,32 @@ getkeystring(char *s, int *len, int how, int *misc) * If the code set isn't handled, we'd better * assume it's US-ASCII rather than just failing * hopelessly. Solaris has a weird habit of - * returning 646. + * returning 646. This is handled by the + * native iconv(), but not by GNU iconv; what's + * more, some versions of the native iconv don't + * handle standard names like ASCII. + * + * This should only be a problem if there's a + * mismatch between the NLS and the iconv in use, + * which probably only means if libiconv is in use. + * We checked at configure time if our libraries + * pulled in _libiconv_version, which should be + * a good test. * * It shouldn't ever be NULL, but while we're * being paranoid... */ - if (!codesetstr || !*codesetstr || - !strcmp(codesetstr, "646")) +#ifdef ICONV_FROM_LIBICONV + if (!codesetstr || !*codesetstr) codesetstr = "US-ASCII"; +#endif cd = iconv_open(codesetstr, "UCS-4BE"); +#ifdef ICONV_FROM_LIBICONV + if (cd == (iconv_t)-1 && !strcmp(codesetstr, "646")) { + codesetstr = "US-ASCII"; + cd = iconv_open(codesetstr, "UCS-4BE"); + } +#endif if (cd == (iconv_t)-1) { zerr("cannot do charset conversion (iconv failed)"); CHARSET_FAILED(); |