Mercurial > hg > octave-kai > gnulib-hg
changeset 7057:cb4ff5d170d3
Define fallbacks for missing isw* functions on FreeBSD 4.x.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 28 Jul 2006 15:22:23 +0000 |
parents | db9b9e26e735 |
children | 35f0e7415e65 |
files | lib/ChangeLog lib/mbchar.h m4/ChangeLog m4/mbchar.m4 |
diffstat | 4 files changed, 129 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,15 @@ +2006-07-28 Bruno Haible <bruno@clisp.org> + + * 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 <yoann.v@prelude-ids.com>. + + * wcwidth.h (iswprint): Assume an ASCII compatible wide character + encoding. + * mbswidth.c (iswcntrl): Likewise. + 2006-07-28 Paul Eggert <eggert@cs.ucla.edu> * modechange.c (mode_compile): Numeric modes now affect setuid and
--- a/lib/mbchar.h +++ b/lib/mbchar.h @@ -157,6 +157,115 @@ #include <wchar.h> #include <wctype.h> +/* FreeBSD 4.4 to 4.11 has <wctype.h> 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"
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2006-07-28 Bruno Haible <bruno@clisp.org> + + * mbchar.m4 (gl_MBCHAR): Also test for iswcntrl. + 2006-07-27 Bruno Haible <bruno@clisp.org> * stdint.m4 (gl_STDINT_H): Define __STDC_CONSTANT_MACROS during the
--- 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 @@ 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 ])