aboutsummaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-03-05 01:48:34 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-03-05 01:48:34 +0900
commit4bc554bb8b46d9b47bb847a72bb5c0226d54b8e5 (patch)
tree7bb1c906446262e56ff9992939910f385e53e39b /Src
parent0ac87e3f595ac49e0536eaac2109f0a1f30a7af9 (diff)
downloadzsh-4bc554bb8b46d9b47bb847a72bb5c0226d54b8e5.tar.gz
zsh-4bc554bb8b46d9b47bb847a72bb5c0226d54b8e5.tar.xz
zsh-4bc554bb8b46d9b47bb847a72bb5c0226d54b8e5.zip
34636: replace broken isprint() on Mac OS X
Diffstat (limited to 'Src')
-rw-r--r--Src/compat.c15
-rw-r--r--Src/pattern.c2
-rw-r--r--Src/utils.c4
-rw-r--r--Src/ztype.h6
4 files changed, 24 insertions, 3 deletions
diff --git a/Src/compat.c b/Src/compat.c
index b0bcb6265..09b3d6a5f 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -951,3 +951,18 @@ int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
/**/
#endif /* BROKEN_WCWIDTH && (__STDC_ISO_10646__ || __APPLE__) */
+/**/
+#if defined(__APPLE__) && defined(BROKEN_ISPRINT)
+
+/**/
+int
+isprint_ascii(int c)
+{
+ if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
+ return (c >= 0x20 && c <= 0x7e);
+ else
+ return isprint(c);
+}
+
+/**/
+#endif /* __APPLE__ && BROKEN_ISPRINT */
diff --git a/Src/pattern.c b/Src/pattern.c
index df5e602ca..17cd40c23 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -3622,7 +3622,7 @@ patmatchrange(char *range, int ch, int *indptr, int *mtp)
return 1;
break;
case PP_PRINT:
- if (isprint(ch))
+ if (ISPRINT(ch))
return 1;
break;
case PP_PUNCT:
diff --git a/Src/utils.c b/Src/utils.c
index 1bcceb091..3d12807e2 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -414,7 +414,7 @@ nicechar(int c)
static char buf[6];
char *s = buf;
c &= 0xff;
- if (isprint(c))
+ if (ISPRINT(c))
goto done;
if (c & 0x80) {
if (isset(PRINTEIGHTBIT))
@@ -423,7 +423,7 @@ nicechar(int c)
*s++ = 'M';
*s++ = '-';
c &= 0x7f;
- if(isprint(c))
+ if(ISPRINT(c))
goto done;
}
if (c == 0x7f) {
diff --git a/Src/ztype.h b/Src/ztype.h
index eef0f23db..d1bef0a5a 100644
--- a/Src/ztype.h
+++ b/Src/ztype.h
@@ -75,3 +75,9 @@
#define WC_ZISTYPE(X,Y) zistype((X),(Y))
#define WC_ISPRINT(X) isprint(X)
#endif
+
+#if defined(__APPLE__) && defined(BROKEN_ISPRINT)
+#define ISPRINT(c) isprint_ascii(c)
+#else
+#define ISPRINT(c) isprint(c)
+#endif