about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-02-26 16:19:33 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-02-26 16:19:33 +0000
commit4c7bb13f63bcb91839cafd81a0479ee19cf672df (patch)
tree5167ce719a2fab4f93bdf5f743d29e90b0cf4288
parentf674ea76d22ee2d084856c2fb3bec68ce8854cff (diff)
downloadzsh-4c7bb13f63bcb91839cafd81a0479ee19cf672df.tar.gz
zsh-4c7bb13f63bcb91839cafd81a0479ee19cf672df.tar.xz
zsh-4c7bb13f63bcb91839cafd81a0479ee19cf672df.zip
24596: use "US-ASCII" as charset if nl_langinfo(CODESET) returns "" or "646"
-rw-r--r--ChangeLog3
-rw-r--r--Src/utils.c13
2 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index bf26f2cb2..c7deeebdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-02-26  Peter Stephenson  <pws@csr.com>
 
+	* 24596: Src/utils.c: if nl_langinfo(CODESET) returns ""
+	or "646" use "US-ASCII".
+
 	* 24592: Src/utils.c: make errors about charset conversion
 	more explicit.
 
diff --git a/Src/utils.c b/Src/utils.c
index b25ea8506..271f2c046 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4867,6 +4867,7 @@ getkeystring(char *s, int *len, int how, int *misc)
 		} else {
 #   ifdef HAVE_ICONV
 		    ICONV_CONST char *inptr = inbuf;
+		    const char *codesetstr = nl_langinfo(CODESET);
     	    	    inbytes = 4;
 		    outbytes = 6;
 		    /* store value in big endian form */
@@ -4875,6 +4876,18 @@ getkeystring(char *s, int *len, int how, int *misc)
 			wval >>= 8;
 		    }
 
+		    /*
+		     * 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.
+		     *
+		     * It shouldn't ever be NULL, but while we're
+		     * being paranoid...
+		     */
+		    if (!codessetstr || !*codsetstr ||
+			!strcmp(codesetstr, "646"))
+			codesetstr == "US-ASCII";
     	    	    cd = iconv_open(nl_langinfo(CODESET), "UCS-4BE");
 		    if (cd == (iconv_t)-1) {
 			zerr("cannot do charset conversion (iconv failed)");