From 1982cd6d68d03371a7acbf0b6ba142b2909810eb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 24 Dec 2006 07:55:08 +0000 Subject: [PATCH] Fix bug reported by Bruno Haible in where quotearg.c didn't compile on Mac OS X 10.2 because it lacks and wint_t. * lib/wctype_.h (__wctype_wint_t): New type. Include , , only if HAVE_WINT_T. (iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, iswgraph): (iswlower, iswprint, iswpunct, iswspace, iswupper, ixwxdigit): Arg is now of type __wctype_wint_t, not wint_t. * m4/wctype.m4 (gl_WCTYPE_H): Require gt_TYPE_WINT_T, and substitute HAVE_WINT_T. * modules/wctype (Files): Add m4/wint_t.m4. (wctype.h): Substitute HAVE_WINT_T. --- ChangeLog | 16 ++++++++++++++++ lib/wctype_.h | 35 ++++++++++++++++++++--------------- m4/wctype.m4 | 3 +++ modules/wctype | 2 ++ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1149ee45b..23fe11031 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-12-23 Paul Eggert + + Fix bug reported by Bruno Haible in + + where quotearg.c didn't compile on Mac OS X 10.2 because it + lacks and wint_t. + * lib/wctype_.h (__wctype_wint_t): New type. + Include , , only if HAVE_WINT_T. + (iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, iswgraph): + (iswlower, iswprint, iswpunct, iswspace, iswupper, ixwxdigit): + Arg is now of type __wctype_wint_t, not wint_t. + * m4/wctype.m4 (gl_WCTYPE_H): Require gt_TYPE_WINT_T, and + substitute HAVE_WINT_T. + * modules/wctype (Files): Add m4/wint_t.m4. + (wctype.h): Substitute HAVE_WINT_T. + 2006-12-23 Bruno Haible * lib/safe-read.h [C++]: Wrap declarations in extern "C". diff --git a/lib/wctype_.h b/lib/wctype_.h index 77a68143c..aa17f9c8f 100644 --- a/lib/wctype_.h +++ b/lib/wctype_.h @@ -29,14 +29,19 @@ #ifndef _GL_WCTYPE_H #define _GL_WCTYPE_H +#if @HAVE_WINT_T@ - 0 /* Solaris 2.5 has a bug: must be included before . Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.1 has a bug: and must be included before . */ -#include -#include -#include +# include +# include +# include +typedef wint_t __wctype_wint_t; +#else +typedef int __wctype_wint_t; +#endif /* Include the original if it exists. BeOS 5 has the functions but no . */ @@ -55,7 +60,7 @@ static wint_t _ctmp_; #if !defined iswalnum && !HAVE_ISWCNTRL static inline int -iswalnum (wint_t wc) +iswalnum (__wctype_wint_t wc) { return ((wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); @@ -65,7 +70,7 @@ iswalnum (wint_t wc) #if !defined iswalpha && !HAVE_ISWCNTRL static inline int -iswalpha (wint_t wc) +iswalpha (__wctype_wint_t wc) { return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; } @@ -74,7 +79,7 @@ iswalpha (wint_t wc) #if !defined iswblank && !HAVE_ISWCNTRL static inline int -iswblank (wint_t wc) +iswblank (__wctype_wint_t wc) { return wc == ' ' || wc == '\t'; } @@ -83,7 +88,7 @@ iswblank (wint_t wc) #if !defined iswcntrl && !HAVE_ISWCNTRL static inline int -iswcntrl (wint_t wc) +iswcntrl (__wctype_wint_t wc) { return (wc & ~0x1f) == 0 || wc == 0x7f; } @@ -92,7 +97,7 @@ iswcntrl (wint_t wc) #if !defined iswdigit && !HAVE_ISWCNTRL static inline int -iswdigit (wint_t wc) +iswdigit (__wctype_wint_t wc) { return wc >= '0' && wc <= '9'; } @@ -101,7 +106,7 @@ iswdigit (wint_t wc) #if !defined iswgraph && !HAVE_ISWCNTRL static inline int -iswgraph (wint_t wc) +iswgraph (__wctype_wint_t wc) { return wc >= '!' && wc <= '~'; } @@ -110,7 +115,7 @@ iswgraph (wint_t wc) #if !defined iswlower && !HAVE_ISWCNTRL static inline int -iswlower (wint_t wc) +iswlower (__wctype_wint_t wc) { return wc >= 'a' && wc <= 'z'; } @@ -119,7 +124,7 @@ iswlower (wint_t wc) #if !defined iswprint && !HAVE_ISWCNTRL static inline int -iswprint (wint_t wc) +iswprint (__wctype_wint_t wc) { return wc >= ' ' && wc <= '~'; } @@ -128,7 +133,7 @@ iswprint (wint_t wc) #if !defined iswpunct && !HAVE_ISWCNTRL static inline int -iswpunct (wint_t wc) +iswpunct (__wctype_wint_t wc) { return (wc >= '!' && wc <= '~' && !((wc >= '0' && wc <= '9') @@ -139,7 +144,7 @@ iswpunct (wint_t wc) #if !defined iswspace && !HAVE_ISWCNTRL static inline int -iswspace (wint_t wc) +iswspace (__wctype_wint_t wc) { return (wc == ' ' || wc == '\t' || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); @@ -149,7 +154,7 @@ iswspace (wint_t wc) #if !defined iswupper && !HAVE_ISWCNTRL static inline int -iswupper (wint_t wc) +iswupper (__wctype_wint_t wc) { return wc >= 'A' && wc <= 'Z'; } @@ -158,7 +163,7 @@ iswupper (wint_t wc) #if !defined iswxdigit && !HAVE_ISWCNTRL static inline int -iswxdigit (wint_t wc) +iswxdigit (__wctype_wint_t wc) { return ((wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); diff --git a/m4/wctype.m4 b/m4/wctype.m4 index 357c7a5f9..c24e75f26 100644 --- a/m4/wctype.m4 +++ b/m4/wctype.m4 @@ -13,6 +13,9 @@ AC_DEFUN([gl_WCTYPE_H], AC_CHECK_HEADERS_ONCE([wctype.h]) AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([gt_TYPE_WINT_T]) + AC_SUBST([HAVE_WINT_T]) + if test $ac_cv_header_wctype_h = yes; then gl_ABSOLUTE_HEADER([wctype.h]) ABSOLUTE_WCTYPE_H=\"$gl_cv_absolute_wctype_h\" diff --git a/modules/wctype b/modules/wctype index 33e49f605..9818a99d3 100644 --- a/modules/wctype +++ b/modules/wctype @@ -4,6 +4,7 @@ A that conforms better to C99. Files: lib/wctype_.h m4/wctype.m4 +m4/wint_t.m4 Depends-on: @@ -21,6 +22,7 @@ wctype.h: wctype_.h sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ -e 's|@''ABSOLUTE_WCTYPE_H''@|$(ABSOLUTE_WCTYPE_H)|g' \ -e 's/@''HAVE_WCTYPE_CTMP_BUG''@/$(HAVE_WCTYPE_CTMP_BUG)/g' \ + -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ < $(srcdir)/wctype_.h; \ } > $@-t mv $@-t $@ -- 2.11.0