diff options
author | Bruno Haible <bruno@clisp.org> | 2006-07-28 15:22:23 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2006-07-28 15:22:23 +0000 |
commit | 6589d0566178283e0b68c7bd872317566ea955a4 (patch) | |
tree | 02004574ee26e9a13305eaa82238ba3968183694 /lib/mbchar.h | |
parent | 4e3c4c0478e6e1e81f093b80d8272840a39ca2bd (diff) | |
download | gnulib-6589d0566178283e0b68c7bd872317566ea955a4.tar.gz |
Define fallbacks for missing isw* functions on FreeBSD 4.x.
Diffstat (limited to 'lib/mbchar.h')
-rw-r--r-- | lib/mbchar.h | 109 |
1 files changed, 109 insertions, 0 deletions
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 <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" |