Commit 4bc554bb authored by Jun-ichi Takimoto's avatar Jun-ichi Takimoto

34636: replace broken isprint() on Mac OS X

parent 0ac87e3f
2015-03-05 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 34636: Src/compat.c, Src/pattern.c, Src/utils.c, Src/ztype.c,
configure.ac: replace broken isprint() on Mac OS X.
2015-03-04 Peter Stephenson <p.stephenson@samsung.com>
* 34641: Src/lex.c, Test/A02alias.ztst: make it possible to
......
......@@ -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 */
......@@ -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:
......
......@@ -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) {
......
......@@ -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
......@@ -2567,6 +2567,8 @@ AH_TEMPLATE([MULTIBYTE_SUPPORT],
[Define to 1 if you want support for multibyte character sets.])
AH_TEMPLATE([BROKEN_WCWIDTH],
[Define to 1 if the wcwidth() function is present but broken.])
AH_TEMPLATE([BROKEN_ISPRINT],
[Define to 1 if the isprint() function is broken under UTF-8 locale.])
if test x$zsh_cv_c_unicode_support = xyes; then
AC_DEFINE(MULTIBYTE_SUPPORT)
......@@ -2622,6 +2624,38 @@ if test x$zsh_cv_c_unicode_support = xyes; then
if test x$zsh_cv_c_broken_wcwidth = xyes; then
AC_DEFINE(BROKEN_WCWIDTH)
fi
dnl Check if isprint() behaves correctly under UTF-8 locale.
dnl On some platform (maybe only on Mac OS X), isprint() returns
dnl true for all characters in the range from 0xa0 to 0xff if
dnl called under UTF-8 locale.
[locale_prog='char *my_locales[] = {
"en_US.UTF-8", "en_GB.UTF-8", "en.UTF-8", '
locale_prog="$locale_prog"`locale -a 2>/dev/null | \
sed -e 's/utf8/UTF-8/' | grep UTF-8 | \
while read line; do echo " \"$line\","; done;`
locale_prog="$locale_prog 0 };
#include <locale.h>
#include <ctype.h>
int main() {
char **localep;
for (localep = my_locales; *localep; localep++)
if (setlocale(LC_ALL, *localep) && isprint(0xa0))
return 0;
return 1;
}
"]
AC_CACHE_CHECK(if the isprint() function is broken,
zsh_cv_c_broken_isprint,
[AC_TRY_RUN([$locale_prog],
zsh_cv_c_broken_isprint=yes,
zsh_cv_c_broken_isprint=no,
zsh_cv_c_broken_isprint=no)])
if test x$zsh_cv_c_broken_isprint = xyes; then
AC_DEFINE(BROKEN_ISPRINT)
fi
fi
dnl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment