mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-04 20:40:57 +02:00
34636: replace broken isprint() on Mac OS X
This commit is contained in:
parent
0ac87e3f59
commit
4bc554bb8b
6 changed files with 63 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2015-03-04 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
* 34641: Src/lex.c, Test/A02alias.ztst: make it possible to
|
* 34641: Src/lex.c, Test/A02alias.ztst: make it possible to
|
||||||
|
|
15
Src/compat.c
15
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__) */
|
#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;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case PP_PRINT:
|
case PP_PRINT:
|
||||||
if (isprint(ch))
|
if (ISPRINT(ch))
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case PP_PUNCT:
|
case PP_PUNCT:
|
||||||
|
|
|
@ -414,7 +414,7 @@ nicechar(int c)
|
||||||
static char buf[6];
|
static char buf[6];
|
||||||
char *s = buf;
|
char *s = buf;
|
||||||
c &= 0xff;
|
c &= 0xff;
|
||||||
if (isprint(c))
|
if (ISPRINT(c))
|
||||||
goto done;
|
goto done;
|
||||||
if (c & 0x80) {
|
if (c & 0x80) {
|
||||||
if (isset(PRINTEIGHTBIT))
|
if (isset(PRINTEIGHTBIT))
|
||||||
|
@ -423,7 +423,7 @@ nicechar(int c)
|
||||||
*s++ = 'M';
|
*s++ = 'M';
|
||||||
*s++ = '-';
|
*s++ = '-';
|
||||||
c &= 0x7f;
|
c &= 0x7f;
|
||||||
if(isprint(c))
|
if(ISPRINT(c))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (c == 0x7f) {
|
if (c == 0x7f) {
|
||||||
|
|
|
@ -75,3 +75,9 @@
|
||||||
#define WC_ZISTYPE(X,Y) zistype((X),(Y))
|
#define WC_ZISTYPE(X,Y) zistype((X),(Y))
|
||||||
#define WC_ISPRINT(X) isprint(X)
|
#define WC_ISPRINT(X) isprint(X)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(BROKEN_ISPRINT)
|
||||||
|
#define ISPRINT(c) isprint_ascii(c)
|
||||||
|
#else
|
||||||
|
#define ISPRINT(c) isprint(c)
|
||||||
|
#endif
|
||||||
|
|
34
configure.ac
34
configure.ac
|
@ -2567,6 +2567,8 @@ AH_TEMPLATE([MULTIBYTE_SUPPORT],
|
||||||
[Define to 1 if you want support for multibyte character sets.])
|
[Define to 1 if you want support for multibyte character sets.])
|
||||||
AH_TEMPLATE([BROKEN_WCWIDTH],
|
AH_TEMPLATE([BROKEN_WCWIDTH],
|
||||||
[Define to 1 if the wcwidth() function is present but broken.])
|
[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
|
if test x$zsh_cv_c_unicode_support = xyes; then
|
||||||
AC_DEFINE(MULTIBYTE_SUPPORT)
|
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
|
if test x$zsh_cv_c_broken_wcwidth = xyes; then
|
||||||
AC_DEFINE(BROKEN_WCWIDTH)
|
AC_DEFINE(BROKEN_WCWIDTH)
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
|
Loading…
Reference in a new issue