From 6589d0566178283e0b68c7bd872317566ea955a4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 28 Jul 2006 15:22:23 +0000 Subject: [PATCH] Define fallbacks for missing isw* functions on FreeBSD 4.x. --- lib/ChangeLog | 12 ++++++ lib/mbchar.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ m4/ChangeLog | 4 ++ m4/mbchar.m4 | 6 ++- 4 files changed, 129 insertions(+), 2 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index fbca6af5dc..d15935025c 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,15 @@ +2006-07-28 Bruno Haible + + * mbchar.h (iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, iswgraph, + iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit): Define + fallbacks. + Avoids link error on FreeBSD 4.x. + Reported by Yoann Vandoorselaere . + + * wcwidth.h (iswprint): Assume an ASCII compatible wide character + encoding. + * mbswidth.c (iswcntrl): Likewise. + 2006-07-28 Paul Eggert * modechange.c (mode_compile): Numeric modes now affect setuid and diff --git a/lib/mbchar.h b/lib/mbchar.h index 738efd948a..e6e351d830 100644 --- a/lib/mbchar.h +++ b/lib/mbchar.h @@ -157,6 +157,115 @@ #include #include +/* FreeBSD 4.4 to 4.11 has but lacks the functions. + Assume all 12 functions are implemented the same way, or not at all. */ +#if !defined iswalnum && !HAVE_ISWCNTRL +ststic inline int +iswalnum (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z') + : 0); +} +#endif +#if !defined iswalpha && !HAVE_ISWCNTRL +ststic inline int +iswalpha (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z' + : 0); +} +#endif +#if !defined iswblank && !HAVE_ISWCNTRL +ststic inline int +iswblank (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc == ' ' || wc == '\t' + : 0); +} +#endif +#if !defined iswcntrl && !HAVE_ISWCNTRL +ststic inline int +iswcntrl (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? (wc & ~0x1f) == 0 || wc == 0x7f + : 0); +} +#endif +#if !defined iswdigit && !HAVE_ISWCNTRL +ststic inline int +iswdigit (wint_t wc) +{ + return (wc >= '0' && wc <= '9'); +} +#endif +#if !defined iswgraph && !HAVE_ISWCNTRL +ststic inline int +iswgraph (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc >= '!' && wc <= '~' + : 1); +} +#endif +#if !defined iswlower && !HAVE_ISWCNTRL +ststic inline int +iswlower (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc >= 'a' && wc <= 'z' + : 0); +} +#endif +#if !defined iswprint && !HAVE_ISWCNTRL +ststic inline int +iswprint (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc >= ' ' && wc <= '~' + : 1); +} +#endif +#if !defined iswpunct && !HAVE_ISWCNTRL +ststic inline int +iswpunct (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc >= '!' && wc <= '~' + && !((wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')) + : 1); +} +#endif +#if !defined iswspace && !HAVE_ISWCNTRL +ststic inline int +iswspace (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc == ' ' || wc == '\t' + || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r' + : 0); +} +#endif +#if !defined iswupper && !HAVE_ISWCNTRL +ststic inline int +iswupper (wint_t wc) +{ + return (wc >= 0 && wc < 128 + ? wc >= 'A' && wc <= 'Z' + : 0); +} +#endif +#if !defined iswxdigit && !HAVE_ISWCNTRL +ststic inline int +iswxdigit (wint_t wc) +{ + return (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'); +} +#endif #include "wcwidth.h" diff --git a/m4/ChangeLog b/m4/ChangeLog index 62cee0ccc5..9aba0709ab 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2006-07-28 Bruno Haible + + * mbchar.m4 (gl_MBCHAR): Also test for iswcntrl. + 2006-07-27 Bruno Haible * stdint.m4 (gl_STDINT_H): Define __STDC_CONSTANT_MACROS during the diff --git a/m4/mbchar.m4 b/m4/mbchar.m4 index df351a6eb2..ec4cbab114 100644 --- a/m4/mbchar.m4 +++ b/m4/mbchar.m4 @@ -1,5 +1,5 @@ -# mbchar.m4 serial 2 -dnl Copyright (C) 2005 Free Software Foundation, Inc. +# mbchar.m4 serial 3 +dnl Copyright (C) 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -16,5 +16,7 @@ AC_DEFUN([gl_MBCHAR], dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H. if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then AC_LIBOBJ([mbchar]) + dnl Prerequisites of mbchar.h and mbchar.c. + AC_CHECK_FUNCS([iswcntrl]) fi ]) -- 2.30.2