summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-09-16 10:47:43 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-09-16 10:48:04 -0700
commit0cd711b27ba11019c96314a42e197bc288f415d7 (patch)
treeac862ac2e2f63d3f59b7a0e9380d64596d26b1a4
parentead34780b88448b7ccd9ffd18968a3cef76aa14c (diff)
downloadgnulib-0cd711b27ba11019c96314a42e197bc288f415d7.tar.gz
localcharset: work around Mac OS X bug with UTF-8 and MB_CUR_MAX
* lib/localcharset.c (locale_charset) [DARWIN7]: Return "ASCII" if the system reports "UTF-8" and MB_CUR_MAX <= 1, as these two values are incompatible. Problem reported by Max Horn. For more discussion, please see <http://lists.gnu.org/archive/html/bug-gnulib/2012-09/msg00061.html>.
-rw-r--r--ChangeLog7
-rw-r--r--lib/localcharset.c7
2 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 268292b107..5425df45b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2012-09-16 Paul Eggert <eggert@cs.ucla.edu>
+ localcharset: work around Mac OS X bug with UTF-8 and MB_CUR_MAX
+ * lib/localcharset.c (locale_charset) [DARWIN7]:
+ Return "ASCII" if the system reports "UTF-8" and MB_CUR_MAX <= 1,
+ as these two values are incompatible. Problem reported by Max Horn.
+ For more discussion, please see
+ <http://lists.gnu.org/archive/html/bug-gnulib/2012-09/msg00061.html>.
+
doc: document sticky-EOF issue
* doc/posix-functions/fgetc.texi (fgetc):
* doc/posix-functions/fgets.texi (fgets):
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 54a2432b3e..1a94042362 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -542,5 +542,12 @@ locale_charset (void)
if (codeset[0] == '\0')
codeset = "ASCII";
+#ifdef DARWIN7
+ /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
+ (the default codeset) does not work when MB_CUR_MAX is 1. */
+ if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1)
+ codeset = "ASCII";
+#endif
+
return codeset;
}