about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Src/compat.c4
-rw-r--r--Src/zsh.h9
3 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f391bce0a..d1c87a57f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-23  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* Jun T: 30640 (plus additional comment): Src/zsh.h,
+	Src/compat.c: MacOS doesn't define __STDC_ISO_10646__ but we
+	need the replacement wcwidth() anyway.
+
 2012-08-23  Peter Stephenson  <pws@csr.com>
 
 	* Aaron Schrab: 30636: Completion/Unix/Command/_telnet:
@@ -108,5 +114,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5709 $
+* $Revision: 1.5710 $
 *****************************************************
diff --git a/Src/compat.c b/Src/compat.c
index 6d08dab94..cc4e876da 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -630,7 +630,7 @@ strtoul(nptr, endptr, base)
 #endif /* HAVE_STRTOUL */
 
 /**/
-#if defined(BROKEN_WCWIDTH) && defined(__STDC_ISO_10646__)
+#if defined(BROKEN_WCWIDTH) && (defined(__STDC_ISO_10646__) || defined(__APPLE__))
 
 /*
  * This is an implementation of wcwidth() and wcswidth() (defined in
@@ -949,5 +949,5 @@ int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
 #endif /* 0 */
 
 /**/
-#endif /* BROKEN_WCWIDTH && __STDC_ISO_10646__ */
+#endif /* BROKEN_WCWIDTH && (__STDC_ISO_10646__ || __APPLE__) */
 
diff --git a/Src/zsh.h b/Src/zsh.h
index b9f2846f7..e20838249 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2681,7 +2681,14 @@ typedef wint_t convchar_t;
 #define MB_METASTRWIDTH(str)	mb_metastrlen(str, 1)
 #define MB_METASTRLEN2(str, widthp)	mb_metastrlen(str, widthp)
 
-#if defined(BROKEN_WCWIDTH) && defined(__STDC_ISO_10646__)
+/*
+ * We replace broken implementations with one that uses Unicode
+ * characters directly as wide characters.  In principle this is only
+ * likely to work if __STDC_ISO_10646__ is defined, since that's pretty
+ * much what the definition tells us.  However, we happen to know this
+ * works on MacOS which doesn't define that.
+ */
+#if defined(BROKEN_WCWIDTH) && (defined(__STDC_ISO_10646__) || defined(__APPLE__))
 #define WCWIDTH(wc)	mk_wcwidth(wc)
 #else
 #define WCWIDTH(wc)	wcwidth(wc)