/* Multibyte character data type.
- Copyright (C) 2001, 2005-2006 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2005-2007 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
#include <stdio.h>
#include <time.h>
#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"
#define MBCHAR_BUF_SIZE 24
/* Copying a character. */
static inline void
-mb_copy (mbchar_t *new, const mbchar_t *old)
+mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc)
{
- if (old->ptr == &old->buf[0])
+ if (old_mbc->ptr == &old_mbc->buf[0])
{
- memcpy (&new->buf[0], &old->buf[0], old->bytes);
- new->ptr = &new->buf[0];
+ memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes);
+ new_mbc->ptr = &new_mbc->buf[0];
}
else
- new->ptr = old->ptr;
- new->bytes = old->bytes;
- if ((new->wc_valid = old->wc_valid))
- new->wc = old->wc;
+ new_mbc->ptr = old_mbc->ptr;
+ new_mbc->bytes = old_mbc->bytes;
+ if ((new_mbc->wc_valid = old_mbc->wc_valid))
+ new_mbc->wc = old_mbc->wc;
}
/* The character set is ISO-646, not EBCDIC. */
# define IS_BASIC_ASCII 1
-extern unsigned int is_basic_table[];
+extern const unsigned int is_basic_table[];
static inline bool
is_basic (char c)