summaryrefslogtreecommitdiff
path: root/lib/unistr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unistr')
-rw-r--r--lib/unistr/u-cmp2.h6
-rw-r--r--lib/unistr/u-cpy-alloc.h5
-rw-r--r--lib/unistr/u-cpy.h2
-rw-r--r--lib/unistr/u-endswith.h2
-rw-r--r--lib/unistr/u-move.h6
-rw-r--r--lib/unistr/u-set.h20
-rw-r--r--lib/unistr/u-startswith.h6
-rw-r--r--lib/unistr/u-stpcpy.h2
-rw-r--r--lib/unistr/u-stpncpy.h12
-rw-r--r--lib/unistr/u-strcat.h2
-rw-r--r--lib/unistr/u-strcoll.h76
-rw-r--r--lib/unistr/u-strcpy.h2
-rw-r--r--lib/unistr/u-strcspn.h30
-rw-r--r--lib/unistr/u-strdup.h5
-rw-r--r--lib/unistr/u-strlen.h2
-rw-r--r--lib/unistr/u-strncat.h2
-rw-r--r--lib/unistr/u-strncpy.h2
-rw-r--r--lib/unistr/u-strnlen.h2
-rw-r--r--lib/unistr/u-strpbrk.h16
-rw-r--r--lib/unistr/u-strspn.h30
-rw-r--r--lib/unistr/u-strstr.h24
-rw-r--r--lib/unistr/u-strtok.h10
-rw-r--r--lib/unistr/u16-check.c26
-rw-r--r--lib/unistr/u16-chr.c35
-rw-r--r--lib/unistr/u16-cmp.c30
-rw-r--r--lib/unistr/u16-cmp2.c2
-rw-r--r--lib/unistr/u16-cpy-alloc.c2
-rw-r--r--lib/unistr/u16-cpy.c2
-rw-r--r--lib/unistr/u16-endswith.c2
-rw-r--r--lib/unistr/u16-mblen.c23
-rw-r--r--lib/unistr/u16-mbsnlen.c11
-rw-r--r--lib/unistr/u16-mbtouc-aux.c24
-rw-r--r--lib/unistr/u16-mbtouc-unsafe-aux.c24
-rw-r--r--lib/unistr/u16-mbtouc-unsafe.c24
-rw-r--r--lib/unistr/u16-mbtouc.c24
-rw-r--r--lib/unistr/u16-mbtoucr.c28
-rw-r--r--lib/unistr/u16-move.c2
-rw-r--r--lib/unistr/u16-next.c4
-rw-r--r--lib/unistr/u16-prev.c28
-rw-r--r--lib/unistr/u16-set.c2
-rw-r--r--lib/unistr/u16-startswith.c2
-rw-r--r--lib/unistr/u16-stpcpy.c3
-rw-r--r--lib/unistr/u16-stpncpy.c2
-rw-r--r--lib/unistr/u16-strcat.c2
-rw-r--r--lib/unistr/u16-strchr.c45
-rw-r--r--lib/unistr/u16-strcmp.c24
-rw-r--r--lib/unistr/u16-strcoll.c2
-rw-r--r--lib/unistr/u16-strcpy.c2
-rw-r--r--lib/unistr/u16-strcspn.c2
-rw-r--r--lib/unistr/u16-strdup.c2
-rw-r--r--lib/unistr/u16-strlen.c2
-rw-r--r--lib/unistr/u16-strmblen.c5
-rw-r--r--lib/unistr/u16-strmbtouc.c11
-rw-r--r--lib/unistr/u16-strncat.c2
-rw-r--r--lib/unistr/u16-strncmp.c30
-rw-r--r--lib/unistr/u16-strncpy.c2
-rw-r--r--lib/unistr/u16-strnlen.c2
-rw-r--r--lib/unistr/u16-strpbrk.c2
-rw-r--r--lib/unistr/u16-strrchr.c43
-rw-r--r--lib/unistr/u16-strspn.c2
-rw-r--r--lib/unistr/u16-strstr.c2
-rw-r--r--lib/unistr/u16-strtok.c2
-rw-r--r--lib/unistr/u16-to-u32.c84
-rw-r--r--lib/unistr/u16-to-u8.c102
-rw-r--r--lib/unistr/u16-uctomb-aux.c36
-rw-r--r--lib/unistr/u16-uctomb.c44
-rw-r--r--lib/unistr/u32-check.c8
-rw-r--r--lib/unistr/u32-chr.c4
-rw-r--r--lib/unistr/u32-cmp.c10
-rw-r--r--lib/unistr/u32-cmp2.c2
-rw-r--r--lib/unistr/u32-cpy-alloc.c2
-rw-r--r--lib/unistr/u32-cpy.c2
-rw-r--r--lib/unistr/u32-endswith.c2
-rw-r--r--lib/unistr/u32-mblen.c4
-rw-r--r--lib/unistr/u32-mbsnlen.c2
-rw-r--r--lib/unistr/u32-mbtouc-unsafe.c2
-rw-r--r--lib/unistr/u32-mbtouc.c2
-rw-r--r--lib/unistr/u32-mbtoucr.c2
-rw-r--r--lib/unistr/u32-move.c2
-rw-r--r--lib/unistr/u32-next.c4
-rw-r--r--lib/unistr/u32-prev.c10
-rw-r--r--lib/unistr/u32-set.c2
-rw-r--r--lib/unistr/u32-startswith.c2
-rw-r--r--lib/unistr/u32-stpcpy.c2
-rw-r--r--lib/unistr/u32-stpncpy.c2
-rw-r--r--lib/unistr/u32-strcat.c2
-rw-r--r--lib/unistr/u32-strchr.c6
-rw-r--r--lib/unistr/u32-strcmp.c4
-rw-r--r--lib/unistr/u32-strcoll.c2
-rw-r--r--lib/unistr/u32-strcpy.c2
-rw-r--r--lib/unistr/u32-strcspn.c8
-rw-r--r--lib/unistr/u32-strdup.c2
-rw-r--r--lib/unistr/u32-strlen.c2
-rw-r--r--lib/unistr/u32-strmblen.c2
-rw-r--r--lib/unistr/u32-strmbtouc.c2
-rw-r--r--lib/unistr/u32-strncat.c2
-rw-r--r--lib/unistr/u32-strncmp.c10
-rw-r--r--lib/unistr/u32-strncpy.c2
-rw-r--r--lib/unistr/u32-strnlen.c2
-rw-r--r--lib/unistr/u32-strpbrk.c8
-rw-r--r--lib/unistr/u32-strrchr.c6
-rw-r--r--lib/unistr/u32-strspn.c8
-rw-r--r--lib/unistr/u32-strstr.c2
-rw-r--r--lib/unistr/u32-strtok.c2
-rw-r--r--lib/unistr/u32-to-u16.c90
-rw-r--r--lib/unistr/u32-to-u8.c90
-rw-r--r--lib/unistr/u32-uctomb.c12
-rw-r--r--lib/unistr/u8-check.c126
-rw-r--r--lib/unistr/u8-chr.c83
-rw-r--r--lib/unistr/u8-cmp.c2
-rw-r--r--lib/unistr/u8-cmp2.c2
-rw-r--r--lib/unistr/u8-cpy-alloc.c2
-rw-r--r--lib/unistr/u8-cpy.c2
-rw-r--r--lib/unistr/u8-endswith.c2
-rw-r--r--lib/unistr/u8-mblen.c99
-rw-r--r--lib/unistr/u8-mbsnlen.c11
-rw-r--r--lib/unistr/u8-mbtouc-aux.c224
-rw-r--r--lib/unistr/u8-mbtouc-unsafe-aux.c224
-rw-r--r--lib/unistr/u8-mbtouc-unsafe.c224
-rw-r--r--lib/unistr/u8-mbtouc.c224
-rw-r--r--lib/unistr/u8-mbtoucr.c476
-rw-r--r--lib/unistr/u8-move.c2
-rw-r--r--lib/unistr/u8-next.c4
-rw-r--r--lib/unistr/u8-prev.c92
-rw-r--r--lib/unistr/u8-set.c12
-rw-r--r--lib/unistr/u8-startswith.c2
-rw-r--r--lib/unistr/u8-stpcpy.c2
-rw-r--r--lib/unistr/u8-stpncpy.c2
-rw-r--r--lib/unistr/u8-strcat.c2
-rw-r--r--lib/unistr/u8-strchr.c105
-rw-r--r--lib/unistr/u8-strcmp.c2
-rw-r--r--lib/unistr/u8-strcoll.c2
-rw-r--r--lib/unistr/u8-strcpy.c2
-rw-r--r--lib/unistr/u8-strcspn.c2
-rw-r--r--lib/unistr/u8-strdup.c2
-rw-r--r--lib/unistr/u8-strlen.c2
-rw-r--r--lib/unistr/u8-strmblen.c75
-rw-r--r--lib/unistr/u8-strmbtouc.c135
-rw-r--r--lib/unistr/u8-strncat.c2
-rw-r--r--lib/unistr/u8-strncmp.c2
-rw-r--r--lib/unistr/u8-strncpy.c2
-rw-r--r--lib/unistr/u8-strnlen.c2
-rw-r--r--lib/unistr/u8-strpbrk.c2
-rw-r--r--lib/unistr/u8-strrchr.c105
-rw-r--r--lib/unistr/u8-strspn.c2
-rw-r--r--lib/unistr/u8-strstr.c2
-rw-r--r--lib/unistr/u8-strtok.c2
-rw-r--r--lib/unistr/u8-to-u16.c102
-rw-r--r--lib/unistr/u8-to-u32.c84
-rw-r--r--lib/unistr/u8-uctomb-aux.c6
-rw-r--r--lib/unistr/u8-uctomb.c58
151 files changed, 1947 insertions, 1916 deletions
diff --git a/lib/unistr/u-cmp2.h b/lib/unistr/u-cmp2.h
index ae3750c..6058c4a 100644
--- a/lib/unistr/u-cmp2.h
+++ b/lib/unistr/u-cmp2.h
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -23,9 +23,9 @@ FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2)
if (cmp == 0)
{
if (n1 < n2)
- cmp = -1;
+ cmp = -1;
else if (n1 > n2)
- cmp = 1;
+ cmp = 1;
}
return cmp;
diff --git a/lib/unistr/u-cpy-alloc.h b/lib/unistr/u-cpy-alloc.h
index dace3e2..f36a8d0 100644
--- a/lib/unistr/u-cpy-alloc.h
+++ b/lib/unistr/u-cpy-alloc.h
@@ -1,5 +1,6 @@
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,7 +31,7 @@ FUNC (const UNIT *s, size_t n)
UNIT *destptr = dest;
for (; n > 0; n--)
- *destptr++ = *s++;
+ *destptr++ = *s++;
#else
memcpy ((char *) dest, (const char *) s, n * sizeof (UNIT));
#endif
diff --git a/lib/unistr/u-cpy.h b/lib/unistr/u-cpy.h
index c660eae..6dad952 100644
--- a/lib/unistr/u-cpy.h
+++ b/lib/unistr/u-cpy.h
@@ -1,5 +1,5 @@
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-endswith.h b/lib/unistr/u-endswith.h
index 739bfbb..094a87f 100644
--- a/lib/unistr/u-endswith.h
+++ b/lib/unistr/u-endswith.h
@@ -1,5 +1,5 @@
/* Substring test for UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-move.h b/lib/unistr/u-move.h
index 77b6788..d8d58b0 100644
--- a/lib/unistr/u-move.h
+++ b/lib/unistr/u-move.h
@@ -1,5 +1,5 @@
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -27,7 +27,7 @@ FUNC (UNIT *dest, const UNIT *src, size_t n)
const UNIT *srcptr = src;
for (; n > 0; n--)
- *destptr++ = *srcptr++;
+ *destptr++ = *srcptr++;
}
else if (dest > src)
{
@@ -35,7 +35,7 @@ FUNC (UNIT *dest, const UNIT *src, size_t n)
const UNIT *srcptr = src + n - 1;
for (; n > 0; n--)
- *destptr-- = *srcptr--;
+ *destptr-- = *srcptr--;
}
#else
memmove ((char *) dest, (const char *) src, n * sizeof (UNIT));
diff --git a/lib/unistr/u-set.h b/lib/unistr/u-set.h
index a093e7f..de78a8e 100644
--- a/lib/unistr/u-set.h
+++ b/lib/unistr/u-set.h
@@ -1,5 +1,5 @@
/* Fill UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -23,17 +23,17 @@ FUNC (UNIT *s, ucs4_t uc, size_t n)
if (n > 0)
{
if (IS_SINGLE_UNIT (uc))
- {
- UNIT *ptr = s;
+ {
+ UNIT *ptr = s;
- for (; n > 0; n--)
- *ptr++ = uc;
- }
+ for (; n > 0; n--)
+ *ptr++ = uc;
+ }
else
- {
- errno = EILSEQ;
- return NULL;
- }
+ {
+ errno = EILSEQ;
+ return NULL;
+ }
}
return s;
}
diff --git a/lib/unistr/u-startswith.h b/lib/unistr/u-startswith.h
index 0486ef8..1696651 100644
--- a/lib/unistr/u-startswith.h
+++ b/lib/unistr/u-startswith.h
@@ -1,5 +1,5 @@
/* Substring test for UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -23,8 +23,8 @@ FUNC (const UNIT *str, const UNIT *prefix)
UNIT uc1 = *str++;
UNIT uc2 = *prefix++;
if (uc2 == 0)
- return true;
+ return true;
if (uc1 != uc2)
- return false;
+ return false;
}
}
diff --git a/lib/unistr/u-stpcpy.h b/lib/unistr/u-stpcpy.h
index b13e816..483f3c2 100644
--- a/lib/unistr/u-stpcpy.h
+++ b/lib/unistr/u-stpcpy.h
@@ -1,5 +1,5 @@
/* Copy UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-stpncpy.h b/lib/unistr/u-stpncpy.h
index 09bf434..4d6dd3c 100644
--- a/lib/unistr/u-stpncpy.h
+++ b/lib/unistr/u-stpncpy.h
@@ -1,5 +1,5 @@
/* Copy UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -23,8 +23,12 @@ FUNC (UNIT *dest, const UNIT *src, size_t n)
/* This behavior is rarely useful, but it is here for consistency with
strncpy and wcsncpy. */
- for (; n > 0; n--)
- *dest++ = 0;
+ {
+ UNIT *destptr = dest;
- return dest - 1;
+ for (; n > 0; n--)
+ *destptr++ = 0;
+ }
+
+ return dest;
}
diff --git a/lib/unistr/u-strcat.h b/lib/unistr/u-strcat.h
index e86bbf9..84430fc 100644
--- a/lib/unistr/u-strcat.h
+++ b/lib/unistr/u-strcat.h
@@ -1,5 +1,5 @@
/* Concatenate UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strcoll.h b/lib/unistr/u-strcoll.h
index af404a0..9ec5c60 100644
--- a/lib/unistr/u-strcoll.h
+++ b/lib/unistr/u-strcoll.h
@@ -1,6 +1,6 @@
/* Compare UTF-8/UTF-16/UTF-32 strings using the collation rules of the current
locale.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -32,48 +32,54 @@ FUNC (const UNIT *s1, const UNIT *s2)
{
sl2 = U_STRCONV_TO_LOCALE (s2);
if (sl2 != NULL)
- {
- /* Compare sl1 and sl2. */
- errno = 0;
- result = strcoll (sl1, sl2);
- if (errno == 0)
- {
- /* strcoll succeeded. */
- free (sl1);
- free (sl2);
- }
- else
- {
- /* strcoll failed. */
- final_errno = errno;
- free (sl1);
- free (sl2);
- result = U_STRCMP (s1, s2);
- }
- }
+ {
+ /* Compare sl1 and sl2. */
+ errno = 0;
+ result = strcoll (sl1, sl2);
+ if (errno == 0)
+ {
+ /* strcoll succeeded. */
+ free (sl1);
+ free (sl2);
+ /* The conversion to locale encoding can do transliteration or
+ map some characters to question marks. Therefore sl1 and sl2
+ may be equal when s1 and s2 were in fact different. Return a
+ nonzero result in this case. */
+ if (result == 0)
+ result = U_STRCMP (s1, s2);
+ }
+ else
+ {
+ /* strcoll failed. */
+ final_errno = errno;
+ free (sl1);
+ free (sl2);
+ result = U_STRCMP (s1, s2);
+ }
+ }
else
- {
- /* s1 could be converted to locale encoding, s2 not. */
- final_errno = errno;
- free (sl1);
- result = -1;
- }
+ {
+ /* s1 could be converted to locale encoding, s2 not. */
+ final_errno = errno;
+ free (sl1);
+ result = -1;
+ }
}
else
{
final_errno = errno;
sl2 = U_STRCONV_TO_LOCALE (s2);
if (sl2 != NULL)
- {
- /* s2 could be converted to locale encoding, s1 not. */
- free (sl2);
- result = 1;
- }
+ {
+ /* s2 could be converted to locale encoding, s1 not. */
+ free (sl2);
+ result = 1;
+ }
else
- {
- /* Neither s1 nor s2 could be converted to locale encoding. */
- result = U_STRCMP (s1, s2);
- }
+ {
+ /* Neither s1 nor s2 could be converted to locale encoding. */
+ result = U_STRCMP (s1, s2);
+ }
}
errno = final_errno;
diff --git a/lib/unistr/u-strcpy.h b/lib/unistr/u-strcpy.h
index 153f60e..b059aea 100644
--- a/lib/unistr/u-strcpy.h
+++ b/lib/unistr/u-strcpy.h
@@ -1,5 +1,5 @@
/* Copy UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strcspn.h b/lib/unistr/u-strcspn.h
index de32656..77b9550 100644
--- a/lib/unistr/u-strcspn.h
+++ b/lib/unistr/u-strcspn.h
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -26,11 +26,11 @@ FUNC (const UNIT *str, const UNIT *reject)
int count = U_STRMBTOUC (&uc, reject);
if (count >= 0 && reject[count] == 0)
{
- const UNIT *found = U_STRCHR (str, uc);
- if (found != NULL)
- return found - str;
- else
- return U_STRLEN (str);
+ const UNIT *found = U_STRCHR (str, uc);
+ if (found != NULL)
+ return found - str;
+ else
+ return U_STRLEN (str);
}
}
/* General case. */
@@ -39,15 +39,15 @@ FUNC (const UNIT *str, const UNIT *reject)
for (;;)
{
- ucs4_t uc;
- int count = U_STRMBTOUC (&uc, ptr);
- if (count == 0)
- return ptr - str;
- if (count < 0)
- break;
- if (U_STRCHR (reject, uc))
- return ptr - str;
- ptr += count;
+ ucs4_t uc;
+ int count = U_STRMBTOUC (&uc, ptr);
+ if (count == 0)
+ return ptr - str;
+ if (count < 0)
+ break;
+ if (U_STRCHR (reject, uc))
+ return ptr - str;
+ ptr += count;
}
return U_STRLEN (str);
}
diff --git a/lib/unistr/u-strdup.h b/lib/unistr/u-strdup.h
index 71e527a..a92e1ef 100644
--- a/lib/unistr/u-strdup.h
+++ b/lib/unistr/u-strdup.h
@@ -1,5 +1,6 @@
/* Copy UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,7 +32,7 @@ FUNC (const UNIT *s)
UNIT *destptr = dest;
for (; n > 0; n--)
- *destptr++ = *s++;
+ *destptr++ = *s++;
#else
memcpy ((char *) dest, (const char *) s, n * sizeof (UNIT));
#endif
diff --git a/lib/unistr/u-strlen.h b/lib/unistr/u-strlen.h
index 51dcae0..a54d614 100644
--- a/lib/unistr/u-strlen.h
+++ b/lib/unistr/u-strlen.h
@@ -1,5 +1,5 @@
/* Determine length of UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strncat.h b/lib/unistr/u-strncat.h
index 40b442e..e5c9a04 100644
--- a/lib/unistr/u-strncat.h
+++ b/lib/unistr/u-strncat.h
@@ -1,5 +1,5 @@
/* Concatenate UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strncpy.h b/lib/unistr/u-strncpy.h
index 3d441b5..55a4f67 100644
--- a/lib/unistr/u-strncpy.h
+++ b/lib/unistr/u-strncpy.h
@@ -1,5 +1,5 @@
/* Copy UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strnlen.h b/lib/unistr/u-strnlen.h
index 6a1d2ad..9bcc3da 100644
--- a/lib/unistr/u-strnlen.h
+++ b/lib/unistr/u-strnlen.h
@@ -1,5 +1,5 @@
/* Determine bounded length of UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u-strpbrk.h b/lib/unistr/u-strpbrk.h
index 2ff4618..34aabc5 100644
--- a/lib/unistr/u-strpbrk.h
+++ b/lib/unistr/u-strpbrk.h
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,13 +33,13 @@ FUNC (const UNIT *str, const UNIT *accept)
for (;;)
{
- ucs4_t uc;
- int count = U_STRMBTOUC (&uc, ptr);
- if (count <= 0)
- break;
- if (U_STRCHR (accept, uc))
- return (UNIT *) ptr;
- ptr += count;
+ ucs4_t uc;
+ int count = U_STRMBTOUC (&uc, ptr);
+ if (count <= 0)
+ break;
+ if (U_STRCHR (accept, uc))
+ return (UNIT *) ptr;
+ ptr += count;
}
return NULL;
}
diff --git a/lib/unistr/u-strspn.h b/lib/unistr/u-strspn.h
index 6502ce4..d6669af 100644
--- a/lib/unistr/u-strspn.h
+++ b/lib/unistr/u-strspn.h
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -26,11 +26,11 @@ FUNC (const UNIT *str, const UNIT *accept)
int count = U_STRMBTOUC (&uc, accept);
if (count >= 0 && accept[count] == 0)
{
- const UNIT *ptr = str;
- for (; *ptr != 0; ptr += count)
- if (U_CMP (ptr, accept, count) != 0)
- break;
- return ptr - str;
+ const UNIT *ptr = str;
+ for (; *ptr != 0; ptr += count)
+ if (U_CMP (ptr, accept, count) != 0)
+ break;
+ return ptr - str;
}
}
/* General case. */
@@ -39,15 +39,15 @@ FUNC (const UNIT *str, const UNIT *accept)
for (;;)
{
- ucs4_t uc;
- int count = U_STRMBTOUC (&uc, ptr);
- if (count == 0)
- return ptr - str;
- if (count < 0)
- break;
- if (!U_STRCHR (accept, uc))
- return ptr - str;
- ptr += count;
+ ucs4_t uc;
+ int count = U_STRMBTOUC (&uc, ptr);
+ if (count == 0)
+ return ptr - str;
+ if (count < 0)
+ break;
+ if (!U_STRCHR (accept, uc))
+ return ptr - str;
+ ptr += count;
}
return U_STRLEN (str);
}
diff --git a/lib/unistr/u-strstr.h b/lib/unistr/u-strstr.h
index 55b5a31..df32be8 100644
--- a/lib/unistr/u-strstr.h
+++ b/lib/unistr/u-strstr.h
@@ -1,5 +1,5 @@
/* Substring test for UTF-8/UTF-16/UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -32,17 +32,17 @@ FUNC (const UNIT *haystack, const UNIT *needle)
for (; *haystack != 0; haystack++)
if (*haystack == first)
{
- /* Compare with needle's remaining units. */
- const UNIT *hptr = haystack + 1;
- const UNIT *nptr = needle + 1;
- for (;;)
- {
- if (*hptr != *nptr)
- break;
- hptr++; nptr++;
- if (*nptr == 0)
- return (UNIT *) haystack;
- }
+ /* Compare with needle's remaining units. */
+ const UNIT *hptr = haystack + 1;
+ const UNIT *nptr = needle + 1;
+ for (;;)
+ {
+ if (*hptr != *nptr)
+ break;
+ hptr++; nptr++;
+ if (*nptr == 0)
+ return (UNIT *) haystack;
+ }
}
return NULL;
diff --git a/lib/unistr/u-strtok.h b/lib/unistr/u-strtok.h
index 7ed57d6..7fdef57 100644
--- a/lib/unistr/u-strtok.h
+++ b/lib/unistr/u-strtok.h
@@ -1,5 +1,5 @@
/* Tokenize UTF-8/UTF-16/UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -22,7 +22,7 @@ FUNC (UNIT *str, const UNIT *delim, UNIT **ptr)
{
str = *ptr;
if (str == NULL)
- return NULL; /* reminder that end of token sequence has been reached */
+ return NULL; /* reminder that end of token sequence has been reached */
}
/* Skip leading delimiters. */
@@ -40,9 +40,9 @@ FUNC (UNIT *str, const UNIT *delim, UNIT **ptr)
UNIT *token_end = U_STRPBRK (str, delim);
if (token_end)
{
- /* NUL-terminate the token. */
- *token_end = 0;
- *ptr = token_end + 1;
+ /* NUL-terminate the token. */
+ *token_end = 0;
+ *ptr = token_end + 1;
}
else
*ptr = NULL;
diff --git a/lib/unistr/u16-check.c b/lib/unistr/u16-check.c
index 380cec2..4f18383 100644
--- a/lib/unistr/u16-check.c
+++ b/lib/unistr/u16-check.c
@@ -1,5 +1,5 @@
/* Check UTF-16 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,19 +31,19 @@ u16_check (const uint16_t *s, size_t n)
uint16_t c = *s;
if (c < 0xd800 || c >= 0xe000)
- {
- s++;
- continue;
- }
+ {
+ s++;
+ continue;
+ }
if (c < 0xdc00)
- {
- if (s + 2 <= s_end
- && s[1] >= 0xdc00 && s[1] < 0xe000)
- {
- s += 2;
- continue;
- }
- }
+ {
+ if (s + 2 <= s_end
+ && s[1] >= 0xdc00 && s[1] < 0xe000)
+ {
+ s += 2;
+ continue;
+ }
+ }
/* invalid or incomplete multibyte character */
return s;
}
diff --git a/lib/unistr/u16-chr.c b/lib/unistr/u16-chr.c
index 2d7d797..13deef4 100644
--- a/lib/unistr/u16-chr.c
+++ b/lib/unistr/u16-chr.c
@@ -1,5 +1,6 @@
/* Search character in piece of UTF-16 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,27 +31,27 @@ u16_chr (const uint16_t *s, size_t n, ucs4_t uc)
uint16_t c0 = uc;
for (; n > 0; s++, n--)
- {
- if (*s == c0)
- return (uint16_t *) s;
- }
+ {
+ if (*s == c0)
+ return (uint16_t *) s;
+ }
}
else
switch (u16_uctomb_aux (c, uc, 2))
{
case 2:
- if (n > 1)
- {
- uint16_t c0 = c[0];
- uint16_t c1 = c[1];
-
- for (n--; n > 0; s++, n--)
- {
- if (*s == c0 && s[1] == c1)
- return (uint16_t *) s;
- }
- }
- break;
+ if (n > 1)
+ {
+ uint16_t c0 = c[0];
+ uint16_t c1 = c[1];
+
+ for (n--; n > 0; s++, n--)
+ {
+ if (*s == c0 && s[1] == c1)
+ return (uint16_t *) s;
+ }
+ }
+ break;
}
return NULL;
}
diff --git a/lib/unistr/u16-cmp.c b/lib/unistr/u16-cmp.c
index 0130d27..b71c1c3 100644
--- a/lib/unistr/u16-cmp.c
+++ b/lib/unistr/u16-cmp.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,22 +31,22 @@ u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n)
uint16_t c1 = *s1++;
uint16_t c2 = *s2++;
if (c1 == c2)
- {
- n--;
- continue;
- }
+ {
+ n--;
+ continue;
+ }
if (c1 < 0xd800 || c1 >= 0xe000)
- {
- if (!(c2 < 0xd800 || c2 >= 0xe000))
- /* c2 is a surrogate, but c1 is not. */
- return -1;
- }
+ {
+ if (!(c2 < 0xd800 || c2 >= 0xe000))
+ /* c2 is a surrogate, but c1 is not. */
+ return -1;
+ }
else
- {
- if (c2 < 0xd800 || c2 >= 0xe000)
- /* c1 is a surrogate, but c2 is not. */
- return 1;
- }
+ {
+ if (c2 < 0xd800 || c2 >= 0xe000)
+ /* c1 is a surrogate, but c2 is not. */
+ return 1;
+ }
return (int)c1 - (int)c2;
/* > 0 if c1 > c2, < 0 if c1 < c2. */
}
diff --git a/lib/unistr/u16-cmp2.c b/lib/unistr/u16-cmp2.c
index 766dcd2..8c2a8d6 100644
--- a/lib/unistr/u16-cmp2.c
+++ b/lib/unistr/u16-cmp2.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-cpy-alloc.c b/lib/unistr/u16-cpy-alloc.c
index 047977e..33984f9 100644
--- a/lib/unistr/u16-cpy-alloc.c
+++ b/lib/unistr/u16-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-cpy.c b/lib/unistr/u16-cpy.c
index 13e04b8..614d24c 100644
--- a/lib/unistr/u16-cpy.c
+++ b/lib/unistr/u16-cpy.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-endswith.c b/lib/unistr/u16-endswith.c
index d9abf46..27dcd5a 100644
--- a/lib/unistr/u16-endswith.c
+++ b/lib/unistr/u16-endswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-16 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-mblen.c b/lib/unistr/u16-mblen.c
index 6bb35ac..9e7a93a 100644
--- a/lib/unistr/u16-mblen.c
+++ b/lib/unistr/u16-mblen.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -29,19 +30,19 @@ u16_mblen (const uint16_t *s, size_t n)
uint16_t c = *s;
if (c < 0xd800 || c >= 0xe000)
- return (c != 0 ? 1 : 0);
+ return (c != 0 ? 1 : 0);
#if CONFIG_UNICODE_SAFETY
if (c < 0xdc00)
- {
- if (n >= 2
- && s[1] >= 0xdc00 && s[1] < 0xe000)
- return 2;
- }
+ {
+ if (n >= 2
+ && s[1] >= 0xdc00 && s[1] < 0xe000)
+ return 2;
+ }
#else
- {
- if (n >= 2)
- return 2;
- }
+ {
+ if (n >= 2)
+ return 2;
+ }
#endif
}
/* invalid or incomplete multibyte character */
diff --git a/lib/unistr/u16-mbsnlen.c b/lib/unistr/u16-mbsnlen.c
index 881958e..601d81d 100644
--- a/lib/unistr/u16-mbsnlen.c
+++ b/lib/unistr/u16-mbsnlen.c
@@ -1,5 +1,5 @@
/* Count characters in UTF-16 string.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify it
@@ -28,12 +28,15 @@ u16_mbsnlen (const uint16_t *s, size_t n)
characters = 0;
while (n > 0)
{
- int count = u16_mblen (s, n);
+ ucs4_t uc;
+ int count = u16_mbtoucr (&uc, s, n);
+ characters++;
+ if (count == -2)
+ break;
if (count <= 0)
- count = 1;
+ count = 1;
s += count;
n -= count;
- characters++;
}
return characters;
}
diff --git a/lib/unistr/u16-mbtouc-aux.c b/lib/unistr/u16-mbtouc-aux.c
index 5f35b86..bee77fc 100644
--- a/lib/unistr/u16-mbtouc-aux.c
+++ b/lib/unistr/u16-mbtouc-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-16 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -30,18 +30,18 @@ u16_mbtouc_aux (ucs4_t *puc, const uint16_t *s, size_t n)
if (c < 0xdc00)
{
if (n >= 2)
- {
- if (s[1] >= 0xdc00 && s[1] < 0xe000)
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
- /* invalid multibyte character */
- }
+ {
+ if (s[1] >= 0xdc00 && s[1] < 0xe000)
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
else
- {
- /* incomplete multibyte character */
- }
+ {
+ /* incomplete multibyte character */
+ }
}
/* invalid multibyte character */
*puc = 0xfffd;
diff --git a/lib/unistr/u16-mbtouc-unsafe-aux.c b/lib/unistr/u16-mbtouc-unsafe-aux.c
index 9906e30..f2d7225 100644
--- a/lib/unistr/u16-mbtouc-unsafe-aux.c
+++ b/lib/unistr/u16-mbtouc-unsafe-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-16 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -32,20 +32,20 @@ u16_mbtouc_unsafe_aux (ucs4_t *puc, const uint16_t *s, size_t n)
#endif
{
if (n >= 2)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if (s[1] >= 0xdc00 && s[1] < 0xe000)
+ if (s[1] >= 0xdc00 && s[1] < 0xe000)
#endif
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
- /* invalid multibyte character */
- }
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
else
- {
- /* incomplete multibyte character */
- }
+ {
+ /* incomplete multibyte character */
+ }
}
/* invalid multibyte character */
*puc = 0xfffd;
diff --git a/lib/unistr/u16-mbtouc-unsafe.c b/lib/unistr/u16-mbtouc-unsafe.c
index cc858d8..a5a3638 100644
--- a/lib/unistr/u16-mbtouc-unsafe.c
+++ b/lib/unistr/u16-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -43,20 +43,20 @@ u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
#endif
{
if (n >= 2)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if (s[1] >= 0xdc00 && s[1] < 0xe000)
+ if (s[1] >= 0xdc00 && s[1] < 0xe000)
#endif
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
- /* invalid multibyte character */
- }
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
else
- {
- /* incomplete multibyte character */
- }
+ {
+ /* incomplete multibyte character */
+ }
}
/* invalid multibyte character */
*puc = 0xfffd;
diff --git a/lib/unistr/u16-mbtouc.c b/lib/unistr/u16-mbtouc.c
index 2691db8..26b6089 100644
--- a/lib/unistr/u16-mbtouc.c
+++ b/lib/unistr/u16-mbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -40,18 +40,18 @@ u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
if (c < 0xdc00)
{
if (n >= 2)
- {
- if (s[1] >= 0xdc00 && s[1] < 0xe000)
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
- /* invalid multibyte character */
- }
+ {
+ if (s[1] >= 0xdc00 && s[1] < 0xe000)
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
else
- {
- /* incomplete multibyte character */
- }
+ {
+ /* incomplete multibyte character */
+ }
}
/* invalid multibyte character */
*puc = 0xfffd;
diff --git a/lib/unistr/u16-mbtoucr.c b/lib/unistr/u16-mbtoucr.c
index a1bd8ee..00b7b70 100644
--- a/lib/unistr/u16-mbtoucr.c
+++ b/lib/unistr/u16-mbtoucr.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-16 string, returning an error code.
- Copyright (C) 1999-2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -33,20 +33,20 @@ u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n)
if (c < 0xdc00)
{
if (n >= 2)
- {
- if (s[1] >= 0xdc00 && s[1] < 0xe000)
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
- /* invalid multibyte character */
- }
+ {
+ if (s[1] >= 0xdc00 && s[1] < 0xe000)
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
}
/* invalid multibyte character */
*puc = 0xfffd;
diff --git a/lib/unistr/u16-move.c b/lib/unistr/u16-move.c
index 2bf8c61..f6efb88 100644
--- a/lib/unistr/u16-move.c
+++ b/lib/unistr/u16-move.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-next.c b/lib/unistr/u16-next.c
index 7c49f72..8245f11 100644
--- a/lib/unistr/u16-next.c
+++ b/lib/unistr/u16-next.c
@@ -1,5 +1,5 @@
/* Iterate over next character in UTF-16 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,7 +31,7 @@ u16_next (ucs4_t *puc, const uint16_t *s)
else
{
if (count < 0)
- *puc = 0xfffd;
+ *puc = 0xfffd;
return NULL;
}
}
diff --git a/lib/unistr/u16-prev.c b/lib/unistr/u16-prev.c
index 3beecf0..4c902ad 100644
--- a/lib/unistr/u16-prev.c
+++ b/lib/unistr/u16-prev.c
@@ -1,5 +1,5 @@
/* Iterate over previous character in UTF-16 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -29,25 +29,25 @@ u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start)
uint16_t c_1 = s[-1];
if (c_1 < 0xd800 || c_1 >= 0xe000)
- {
- *puc = c_1;
- return s - 1;
- }
+ {
+ *puc = c_1;
+ return s - 1;
+ }
#if CONFIG_UNICODE_SAFETY
if (c_1 >= 0xdc00)
#endif
- if (s - 1 != start)
- {
- uint16_t c_2 = s[-2];
+ if (s - 1 != start)
+ {
+ uint16_t c_2 = s[-2];
#if CONFIG_UNICODE_SAFETY
- if (c_2 >= 0xd800 && c_2 < 0xdc00)
+ if (c_2 >= 0xd800 && c_2 < 0xdc00)
#endif
- {
- *puc = 0x10000 + ((c_2 - 0xd800) << 10) + (c_1 - 0xdc00);
- return s - 2;
- }
- }
+ {
+ *puc = 0x10000 + ((c_2 - 0xd800) << 10) + (c_1 - 0xdc00);
+ return s - 2;
+ }
+ }
}
return NULL;
}
diff --git a/lib/unistr/u16-set.c b/lib/unistr/u16-set.c
index 9ef307f..7bad3d6 100644
--- a/lib/unistr/u16-set.c
+++ b/lib/unistr/u16-set.c
@@ -1,5 +1,5 @@
/* Fill UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-startswith.c b/lib/unistr/u16-startswith.c
index 2f39d74..22a5d5f 100644
--- a/lib/unistr/u16-startswith.c
+++ b/lib/unistr/u16-startswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-16 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-stpcpy.c b/lib/unistr/u16-stpcpy.c
index 9207edc..59467f7 100644
--- a/lib/unistr/u16-stpcpy.c
+++ b/lib/unistr/u16-stpcpy.c
@@ -1,5 +1,6 @@
/* Copy UTF-16 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-stpncpy.c b/lib/unistr/u16-stpncpy.c
index 30ef7e3..49c616e 100644
--- a/lib/unistr/u16-stpncpy.c
+++ b/lib/unistr/u16-stpncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strcat.c b/lib/unistr/u16-strcat.c
index bb88f1b..8b35868 100644
--- a/lib/unistr/u16-strcat.c
+++ b/lib/unistr/u16-strcat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strchr.c b/lib/unistr/u16-strchr.c
index 673152f..1f8719f 100644
--- a/lib/unistr/u16-strchr.c
+++ b/lib/unistr/u16-strchr.c
@@ -1,5 +1,6 @@
/* Search character in UTF-16 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,33 +31,33 @@ u16_strchr (const uint16_t *s, ucs4_t uc)
uint16_t c0 = uc;
for (;; s++)
- {
- if (*s == c0)
- break;
- if (*s == 0)
- goto notfound;
- }
+ {
+ if (*s == c0)
+ break;
+ if (*s == 0)
+ goto notfound;
+ }
return (uint16_t *) s;
}
else
switch (u16_uctomb_aux (c, uc, 2))
{
case 2:
- if (*s == 0)
- goto notfound;
- {
- uint16_t c0 = c[0];
- uint16_t c1 = c[1];
-
- for (;; s++)
- {
- if (s[1] == 0)
- goto notfound;
- if (*s == c0 && s[1] == c1)
- break;
- }
- return (uint16_t *) s;
- }
+ if (*s == 0)
+ goto notfound;
+ {
+ uint16_t c0 = c[0];
+ uint16_t c1 = c[1];
+
+ for (;; s++)
+ {
+ if (s[1] == 0)
+ goto notfound;
+ if (*s == c0 && s[1] == c1)
+ break;
+ }
+ return (uint16_t *) s;
+ }
}
notfound:
return NULL;
diff --git a/lib/unistr/u16-strcmp.c b/lib/unistr/u16-strcmp.c
index c161c65..b781211 100644
--- a/lib/unistr/u16-strcmp.c
+++ b/lib/unistr/u16-strcmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,19 +31,19 @@ u16_strcmp (const uint16_t *s1, const uint16_t *s2)
uint16_t c1 = *s1++;
uint16_t c2 = *s2++;
if (c1 != 0 && c1 == c2)
- continue;
+ continue;
if (c1 < 0xd800 || c1 >= 0xe000)
- {
- if (!(c2 < 0xd800 || c2 >= 0xe000))
- /* c2 is a surrogate, but c1 is not. */
- return -1;
- }
+ {
+ if (!(c2 < 0xd800 || c2 >= 0xe000))
+ /* c2 is a surrogate, but c1 is not. */
+ return -1;
+ }
else
- {
- if (c2 < 0xd800 || c2 >= 0xe000)
- /* c1 is a surrogate, but c2 is not. */
- return 1;
- }
+ {
+ if (c2 < 0xd800 || c2 >= 0xe000)
+ /* c1 is a surrogate, but c2 is not. */
+ return 1;
+ }
return (int)c1 - (int)c2;
/* > 0 if c1 > c2, < 0 if c1 < c2. */
}
diff --git a/lib/unistr/u16-strcoll.c b/lib/unistr/u16-strcoll.c
index 280ba83..5a504bf 100644
--- a/lib/unistr/u16-strcoll.c
+++ b/lib/unistr/u16-strcoll.c
@@ -1,5 +1,5 @@
/* Compare UTF-16 strings using the collation rules of the current locale.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strcpy.c b/lib/unistr/u16-strcpy.c
index 92c3e7e..ecde75d 100644
--- a/lib/unistr/u16-strcpy.c
+++ b/lib/unistr/u16-strcpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strcspn.c b/lib/unistr/u16-strcspn.c
index 2f5ba43..b18bb37 100644
--- a/lib/unistr/u16-strcspn.c
+++ b/lib/unistr/u16-strcspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strdup.c b/lib/unistr/u16-strdup.c
index 22242c2..4a94451 100644
--- a/lib/unistr/u16-strdup.c
+++ b/lib/unistr/u16-strdup.c
@@ -1,5 +1,5 @@
/* Copy UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strlen.c b/lib/unistr/u16-strlen.c
index 9c05541..da613c2 100644
--- a/lib/unistr/u16-strlen.c
+++ b/lib/unistr/u16-strlen.c
@@ -1,5 +1,5 @@
/* Determine length of UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strmblen.c b/lib/unistr/u16-strmblen.c
index e7f3625..f07ca0b 100644
--- a/lib/unistr/u16-strmblen.c
+++ b/lib/unistr/u16-strmblen.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -32,7 +33,7 @@ u16_strmblen (const uint16_t *s)
if (c < 0xdc00)
{
if (s[1] >= 0xdc00 && s[1] < 0xe000)
- return 2;
+ return 2;
}
#else
if (s[1] != 0)
diff --git a/lib/unistr/u16-strmbtouc.c b/lib/unistr/u16-strmbtouc.c
index 78d482e..9aa5d43 100644
--- a/lib/unistr/u16-strmbtouc.c
+++ b/lib/unistr/u16-strmbtouc.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -40,10 +41,10 @@ u16_strmbtouc (ucs4_t *puc, const uint16_t *s)
#else
if (s[1] != 0)
#endif
- {
- *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
- return 2;
- }
+ {
+ *puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00);
+ return 2;
+ }
}
/* invalid or incomplete multibyte character */
return -1;
diff --git a/lib/unistr/u16-strncat.c b/lib/unistr/u16-strncat.c
index 9e14388..7082716 100644
--- a/lib/unistr/u16-strncat.c
+++ b/lib/unistr/u16-strncat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strncmp.c b/lib/unistr/u16-strncmp.c
index 7278b6f..3ed59c3 100644
--- a/lib/unistr/u16-strncmp.c
+++ b/lib/unistr/u16-strncmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,22 +31,22 @@ u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n)
uint16_t c1 = *s1++;
uint16_t c2 = *s2++;
if (c1 != 0 && c1 == c2)
- {
- n--;
- continue;
- }
+ {
+ n--;
+ continue;
+ }
if (c1 < 0xd800 || c1 >= 0xe000)
- {
- if (!(c2 < 0xd800 || c2 >= 0xe000))
- /* c2 is a surrogate, but c1 is not. */
- return -1;
- }
+ {
+ if (!(c2 < 0xd800 || c2 >= 0xe000))
+ /* c2 is a surrogate, but c1 is not. */
+ return -1;
+ }
else
- {
- if (c2 < 0xd800 || c2 >= 0xe000)
- /* c1 is a surrogate, but c2 is not. */
- return 1;
- }
+ {
+ if (c2 < 0xd800 || c2 >= 0xe000)
+ /* c1 is a surrogate, but c2 is not. */
+ return 1;
+ }
return (int)c1 - (int)c2;
/* > 0 if c1 > c2, < 0 if c1 < c2, = 0 if c1 and c2 are both 0. */
}
diff --git a/lib/unistr/u16-strncpy.c b/lib/unistr/u16-strncpy.c
index 65676aa..bd2eb6f 100644
--- a/lib/unistr/u16-strncpy.c
+++ b/lib/unistr/u16-strncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strnlen.c b/lib/unistr/u16-strnlen.c
index 1cd80c4..49e6d58 100644
--- a/lib/unistr/u16-strnlen.c
+++ b/lib/unistr/u16-strnlen.c
@@ -1,5 +1,5 @@
/* Determine bounded length of UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strpbrk.c b/lib/unistr/u16-strpbrk.c
index 6360581..45353fa 100644
--- a/lib/unistr/u16-strpbrk.c
+++ b/lib/unistr/u16-strpbrk.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strrchr.c b/lib/unistr/u16-strrchr.c
index b3c7ab0..3cf3de2 100644
--- a/lib/unistr/u16-strrchr.c
+++ b/lib/unistr/u16-strrchr.c
@@ -1,5 +1,6 @@
/* Search character in UTF-16 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,32 +34,32 @@ u16_strrchr (const uint16_t *s, ucs4_t uc)
uint16_t c0 = uc;
for (;; s++)
- {
- if (*s == c0)
- result = (uint16_t *) s;
- if (*s == 0)
- break;
- }
+ {
+ if (*s == c0)
+ result = (uint16_t *) s;
+ if (*s == 0)
+ break;
+ }
}
else
switch (u16_uctomb_aux (c, uc, 2))
{
case 2:
- if (*s)
- {
- uint16_t c0 = c[0];
- uint16_t c1 = c[1];
+ if (*s)
+ {
+ uint16_t c0 = c[0];
+ uint16_t c1 = c[1];
- /* FIXME: Maybe walking the string via u16_mblen is a win? */
- for (;; s++)
- {
- if (s[1] == 0)
- break;
- if (*s == c0 && s[1] == c1)
- result = (uint16_t *) s;
- }
- }
- break;
+ /* FIXME: Maybe walking the string via u16_mblen is a win? */
+ for (;; s++)
+ {
+ if (s[1] == 0)
+ break;
+ if (*s == c0 && s[1] == c1)
+ result = (uint16_t *) s;
+ }
+ }
+ break;
}
return result;
}
diff --git a/lib/unistr/u16-strspn.c b/lib/unistr/u16-strspn.c
index 04ba8e6..ab812eb 100644
--- a/lib/unistr/u16-strspn.c
+++ b/lib/unistr/u16-strspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strstr.c b/lib/unistr/u16-strstr.c
index bc61233..54a74d6 100644
--- a/lib/unistr/u16-strstr.c
+++ b/lib/unistr/u16-strstr.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-16 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-strtok.c b/lib/unistr/u16-strtok.c
index dd9b247..f84c465 100644
--- a/lib/unistr/u16-strtok.c
+++ b/lib/unistr/u16-strtok.c
@@ -1,5 +1,5 @@
/* Tokenize UTF-16 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u16-to-u32.c b/lib/unistr/u16-to-u32.c
index 2f39dcd..3544cde 100644
--- a/lib/unistr/u16-to-u32.c
+++ b/lib/unistr/u16-to-u32.c
@@ -1,5 +1,5 @@
/* Convert UTF-16 string to UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -58,57 +58,57 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
int count;
/* Fetch a Unicode character from the input string. */
- count = u16_mbtouc (&uc, s, s_end - s);
+ count = u16_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
if (length + 1 > allocated)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 1 > allocated)
- allocated = length + 1;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 1 > allocated)
+ allocated = length + 1;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ }
result[length++] = uc;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -117,7 +117,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u16-to-u8.c b/lib/unistr/u16-to-u8.c
index 38b27ec..f92cc93 100644
--- a/lib/unistr/u16-to-u8.c
+++ b/lib/unistr/u16-to-u8.c
@@ -1,5 +1,5 @@
/* Convert UTF-16 string to UTF-8 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -58,68 +58,68 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
int count;
/* Fetch a Unicode character from the input string. */
- count = u16_mbtouc (&uc, s, s_end - s);
+ count = u16_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
count = u8_uctomb (result + length, uc, allocated - length);
if (count == -1)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
if (count == -2)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 6 > allocated)
- allocated = length + 6;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- count = u8_uctomb (result + length, uc, allocated - length);
- if (count < 0)
- abort ();
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 6 > allocated)
+ allocated = length + 6;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ count = u8_uctomb (result + length, uc, allocated - length);
+ if (count < 0)
+ abort ();
+ }
length += count;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -128,7 +128,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u16-uctomb-aux.c b/lib/unistr/u16-uctomb-aux.c
index 384452b..e2acc9e 100644
--- a/lib/unistr/u16-uctomb-aux.c
+++ b/lib/unistr/u16-uctomb-aux.c
@@ -1,5 +1,5 @@
/* Conversion UCS-4 to UTF-16.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,29 +30,29 @@ u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n)
else if (uc < 0x10000)
{
if (uc >= 0xe000)
- {
- if (n >= 1)
- {
- s[0] = uc;
- return 1;
- }
- }
+ {
+ if (n >= 1)
+ {
+ s[0] = uc;
+ return 1;
+ }
+ }
else
- return -1;
+ return -1;
}
else
{
if (uc < 0x110000)
- {
- if (n >= 2)
- {
- s[0] = 0xd800 + ((uc - 0x10000) >> 10);
- s[1] = 0xdc00 + ((uc - 0x10000) & 0x3ff);
- return 2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ s[0] = 0xd800 + ((uc - 0x10000) >> 10);
+ s[1] = 0xdc00 + ((uc - 0x10000) & 0x3ff);
+ return 2;
+ }
+ }
else
- return -1;
+ return -1;
}
return -2;
}
diff --git a/lib/unistr/u16-uctomb.c b/lib/unistr/u16-uctomb.c
index 6ac5ada..cbc1abc 100644
--- a/lib/unistr/u16-uctomb.c
+++ b/lib/unistr/u16-uctomb.c
@@ -1,5 +1,5 @@
/* Store a character in UTF-16 string.
- Copyright (C) 2002, 2005-2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,38 +33,38 @@ u16_uctomb (uint16_t *s, ucs4_t uc, int n)
if (uc < 0xd800)
{
if (n > 0)
- {
- s[0] = uc;
- return 1;
- }
+ {
+ s[0] = uc;
+ return 1;
+ }
/* else return -2, below. */
}
else if (uc < 0x10000)
{
if (uc >= 0xe000)
- {
- if (n >= 1)
- {
- s[0] = uc;
- return 1;
- }
- }
+ {
+ if (n >= 1)
+ {
+ s[0] = uc;
+ return 1;
+ }
+ }
else
- return -1;
+ return -1;
}
else
{
if (uc < 0x110000)
- {
- if (n >= 2)
- {
- s[0] = 0xd800 + ((uc - 0x10000) >> 10);
- s[1] = 0xdc00 + ((uc - 0x10000) & 0x3ff);
- return 2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ s[0] = 0xd800 + ((uc - 0x10000) >> 10);
+ s[1] = 0xdc00 + ((uc - 0x10000) & 0x3ff);
+ return 2;
+ }
+ }
else
- return -1;
+ return -1;
}
return -2;
}
diff --git a/lib/unistr/u32-check.c b/lib/unistr/u32-check.c
index 87e9127..8c5f518 100644
--- a/lib/unistr/u32-check.c
+++ b/lib/unistr/u32-check.c
@@ -1,5 +1,5 @@
/* Check UTF-32 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,10 +30,10 @@ u32_check (const uint32_t *s, size_t n)
uint32_t c = *s;
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
- s++;
+ s++;
else
- /* invalid Unicode character */
- return s;
+ /* invalid Unicode character */
+ return s;
}
return NULL;
}
diff --git a/lib/unistr/u32-chr.c b/lib/unistr/u32-chr.c
index 5a594b2..1900288 100644
--- a/lib/unistr/u32-chr.c
+++ b/lib/unistr/u32-chr.c
@@ -1,5 +1,5 @@
/* Search character in piece of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -26,7 +26,7 @@ u32_chr (const uint32_t *s, size_t n, ucs4_t uc)
for (; n > 0; s++, n--)
{
if (*s == uc)
- return (uint32_t *) s;
+ return (uint32_t *) s;
}
return NULL;
}
diff --git a/lib/unistr/u32-cmp.c b/lib/unistr/u32-cmp.c
index a273b10..36496f7 100644
--- a/lib/unistr/u32-cmp.c
+++ b/lib/unistr/u32-cmp.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -28,10 +28,10 @@ u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n)
uint32_t uc1 = *s1++;
uint32_t uc2 = *s2++;
if (uc1 == uc2)
- {
- n--;
- continue;
- }
+ {
+ n--;
+ continue;
+ }
/* Note that uc1 and uc2 each have at most 31 bits. */
return (int)uc1 - (int)uc2;
/* > 0 if uc1 > uc2, < 0 if uc1 < uc2. */
diff --git a/lib/unistr/u32-cmp2.c b/lib/unistr/u32-cmp2.c
index 6924c48..3247602 100644
--- a/lib/unistr/u32-cmp2.c
+++ b/lib/unistr/u32-cmp2.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-cpy-alloc.c b/lib/unistr/u32-cpy-alloc.c
index f9c6960..b9ebefe 100644
--- a/lib/unistr/u32-cpy-alloc.c
+++ b/lib/unistr/u32-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-cpy.c b/lib/unistr/u32-cpy.c
index 2493b65..747430b 100644
--- a/lib/unistr/u32-cpy.c
+++ b/lib/unistr/u32-cpy.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-endswith.c b/lib/unistr/u32-endswith.c
index d77fa8c..cee0d93 100644
--- a/lib/unistr/u32-endswith.c
+++ b/lib/unistr/u32-endswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-32 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-mblen.c b/lib/unistr/u32-mblen.c
index a48c8b2..4530fe4 100644
--- a/lib/unistr/u32-mblen.c
+++ b/lib/unistr/u32-mblen.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,7 +30,7 @@ u32_mblen (const uint32_t *s, size_t n)
#if CONFIG_UNICODE_SAFETY
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
#endif
- return (c != 0 ? 1 : 0);
+ return (c != 0 ? 1 : 0);
}
/* invalid or incomplete multibyte character */
return -1;
diff --git a/lib/unistr/u32-mbsnlen.c b/lib/unistr/u32-mbsnlen.c
index b7a5d18..0a71293 100644
--- a/lib/unistr/u32-mbsnlen.c
+++ b/lib/unistr/u32-mbsnlen.c
@@ -1,5 +1,5 @@
/* Count characters in UTF-32 string.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-mbtouc-unsafe.c b/lib/unistr/u32-mbtouc-unsafe.c
index 4bd9e81..8dbbfe4 100644
--- a/lib/unistr/u32-mbtouc-unsafe.c
+++ b/lib/unistr/u32-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string.
- Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-mbtouc.c b/lib/unistr/u32-mbtouc.c
index 4eeef58..05f7c77 100644
--- a/lib/unistr/u32-mbtouc.c
+++ b/lib/unistr/u32-mbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string.
- Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-mbtoucr.c b/lib/unistr/u32-mbtoucr.c
index 7d7993c..83f7782 100644
--- a/lib/unistr/u32-mbtoucr.c
+++ b/lib/unistr/u32-mbtoucr.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string, returning an error code.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-move.c b/lib/unistr/u32-move.c
index d6c08f4..6362d85 100644
--- a/lib/unistr/u32-move.c
+++ b/lib/unistr/u32-move.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-next.c b/lib/unistr/u32-next.c
index c529295..987fb02 100644
--- a/lib/unistr/u32-next.c
+++ b/lib/unistr/u32-next.c
@@ -1,5 +1,5 @@
/* Iterate over next character in UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -32,7 +32,7 @@ u32_next (ucs4_t *puc, const uint32_t *s)
{
#if CONFIG_UNICODE_SAFETY
if (count < 0)
- *puc = 0xfffd;
+ *puc = 0xfffd;
#endif
return NULL;
}
diff --git a/lib/unistr/u32-prev.c b/lib/unistr/u32-prev.c
index bc20c93..f20b1b7 100644
--- a/lib/unistr/u32-prev.c
+++ b/lib/unistr/u32-prev.c
@@ -1,5 +1,5 @@
/* Iterate over previous character in UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,10 +30,10 @@ u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start)
#if CONFIG_UNICODE_SAFETY
if (c_1 < 0xd800 || (c_1 >= 0xe000 && c_1 < 0x110000))
#endif
- {
- *puc = c_1;
- return s - 1;
- }
+ {
+ *puc = c_1;
+ return s - 1;
+ }
}
return NULL;
}
diff --git a/lib/unistr/u32-set.c b/lib/unistr/u32-set.c
index de10e09..5c517cd 100644
--- a/lib/unistr/u32-set.c
+++ b/lib/unistr/u32-set.c
@@ -1,5 +1,5 @@
/* Fill UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-startswith.c b/lib/unistr/u32-startswith.c
index 0f9a185..7fcb597 100644
--- a/lib/unistr/u32-startswith.c
+++ b/lib/unistr/u32-startswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-32 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-stpcpy.c b/lib/unistr/u32-stpcpy.c
index 5df8233..3cbfa92 100644
--- a/lib/unistr/u32-stpcpy.c
+++ b/lib/unistr/u32-stpcpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-stpncpy.c b/lib/unistr/u32-stpncpy.c
index 19a0894..e55891e 100644
--- a/lib/unistr/u32-stpncpy.c
+++ b/lib/unistr/u32-stpncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strcat.c b/lib/unistr/u32-strcat.c
index cd4737f..4e26bb4 100644
--- a/lib/unistr/u32-strcat.c
+++ b/lib/unistr/u32-strcat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strchr.c b/lib/unistr/u32-strchr.c
index 57a3a3c..b5df7b7 100644
--- a/lib/unistr/u32-strchr.c
+++ b/lib/unistr/u32-strchr.c
@@ -1,5 +1,5 @@
/* Search character in UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -26,9 +26,9 @@ u32_strchr (const uint32_t *s, ucs4_t uc)
for (;; s++)
{
if (*s == uc)
- break;
+ break;
if (*s == 0)
- goto notfound;
+ goto notfound;
}
return (uint32_t *) s;
notfound:
diff --git a/lib/unistr/u32-strcmp.c b/lib/unistr/u32-strcmp.c
index b82d5ed..5f336ce 100644
--- a/lib/unistr/u32-strcmp.c
+++ b/lib/unistr/u32-strcmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -28,7 +28,7 @@ u32_strcmp (const uint32_t *s1, const uint32_t *s2)
uint32_t uc1 = *s1++;
uint32_t uc2 = *s2++;
if (uc1 != 0 && uc1 == uc2)
- continue;
+ continue;
/* Note that uc1 and uc2 each have at most 31 bits. */
return (int)uc1 - (int)uc2;
/* > 0 if uc1 > uc2, < 0 if uc1 < uc2. */
diff --git a/lib/unistr/u32-strcoll.c b/lib/unistr/u32-strcoll.c
index d5e1482..9748855 100644
--- a/lib/unistr/u32-strcoll.c
+++ b/lib/unistr/u32-strcoll.c
@@ -1,5 +1,5 @@
/* Compare UTF-32 strings using the collation rules of the current locale.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strcpy.c b/lib/unistr/u32-strcpy.c
index e500100..f3c70e6 100644
--- a/lib/unistr/u32-strcpy.c
+++ b/lib/unistr/u32-strcpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strcspn.c b/lib/unistr/u32-strcspn.c
index f93ab2e..595d32e 100644
--- a/lib/unistr/u32-strcspn.c
+++ b/lib/unistr/u32-strcspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -36,8 +36,8 @@ FUNC (const UNIT *str, const UNIT *reject)
ucs4_t uc = reject[0];
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
- if (*ptr == uc)
- break;
+ if (*ptr == uc)
+ break;
return ptr - str;
}
/* General case. */
@@ -45,7 +45,7 @@ FUNC (const UNIT *str, const UNIT *reject)
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
if (U_STRCHR (reject, *ptr))
- break;
+ break;
return ptr - str;
}
}
diff --git a/lib/unistr/u32-strdup.c b/lib/unistr/u32-strdup.c
index 66e9393..da4cc5a 100644
--- a/lib/unistr/u32-strdup.c
+++ b/lib/unistr/u32-strdup.c
@@ -1,5 +1,5 @@
/* Copy UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strlen.c b/lib/unistr/u32-strlen.c
index eb64cc2..95d32ab 100644
--- a/lib/unistr/u32-strlen.c
+++ b/lib/unistr/u32-strlen.c
@@ -1,5 +1,5 @@
/* Determine length of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strmblen.c b/lib/unistr/u32-strmblen.c
index 4dde3ff..54b78d7 100644
--- a/lib/unistr/u32-strmblen.c
+++ b/lib/unistr/u32-strmblen.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strmbtouc.c b/lib/unistr/u32-strmbtouc.c
index e94ac30..4c067b9 100644
--- a/lib/unistr/u32-strmbtouc.c
+++ b/lib/unistr/u32-strmbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strncat.c b/lib/unistr/u32-strncat.c
index 86f895b..c9260b0 100644
--- a/lib/unistr/u32-strncat.c
+++ b/lib/unistr/u32-strncat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strncmp.c b/lib/unistr/u32-strncmp.c
index 026ce50..dcbb935 100644
--- a/lib/unistr/u32-strncmp.c
+++ b/lib/unistr/u32-strncmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -28,10 +28,10 @@ u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n)
uint32_t uc1 = *s1++;
uint32_t uc2 = *s2++;
if (uc1 != 0 && uc1 == uc2)
- {
- n--;
- continue;
- }
+ {
+ n--;
+ continue;
+ }
/* Note that uc1 and uc2 each have at most 31 bits. */
return (int)uc1 - (int)uc2;
/* > 0 if uc1 > uc2, < 0 if uc1 < uc2, = 0 if uc1 and uc2 are both 0. */
diff --git a/lib/unistr/u32-strncpy.c b/lib/unistr/u32-strncpy.c
index c8f409b..9a54f97 100644
--- a/lib/unistr/u32-strncpy.c
+++ b/lib/unistr/u32-strncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strnlen.c b/lib/unistr/u32-strnlen.c
index 2ead8f2..8102ac7 100644
--- a/lib/unistr/u32-strnlen.c
+++ b/lib/unistr/u32-strnlen.c
@@ -1,5 +1,5 @@
/* Determine bounded length of UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strpbrk.c b/lib/unistr/u32-strpbrk.c
index 9579a1b..2c4b6bc 100644
--- a/lib/unistr/u32-strpbrk.c
+++ b/lib/unistr/u32-strpbrk.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -35,8 +35,8 @@ FUNC (const UNIT *str, const UNIT *accept)
ucs4_t uc = accept[0];
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
- if (*ptr == uc)
- return (UNIT *) ptr;
+ if (*ptr == uc)
+ return (UNIT *) ptr;
return NULL;
}
/* General case. */
@@ -44,7 +44,7 @@ FUNC (const UNIT *str, const UNIT *accept)
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
if (U_STRCHR (accept, *ptr))
- return (UNIT *) ptr;
+ return (UNIT *) ptr;
return NULL;
}
}
diff --git a/lib/unistr/u32-strrchr.c b/lib/unistr/u32-strrchr.c
index b4641f3..f0030e5 100644
--- a/lib/unistr/u32-strrchr.c
+++ b/lib/unistr/u32-strrchr.c
@@ -1,5 +1,5 @@
/* Search character in UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,9 +30,9 @@ u32_strrchr (const uint32_t *s, ucs4_t uc)
for (;; s++)
{
if (*s == uc)
- result = (uint32_t *) s;
+ result = (uint32_t *) s;
if (*s == 0)
- break;
+ break;
}
return result;
}
diff --git a/lib/unistr/u32-strspn.c b/lib/unistr/u32-strspn.c
index 6f80202..e2571d5 100644
--- a/lib/unistr/u32-strspn.c
+++ b/lib/unistr/u32-strspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -35,8 +35,8 @@ FUNC (const UNIT *str, const UNIT *accept)
ucs4_t uc = accept[0];
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
- if (*ptr != uc)
- break;
+ if (*ptr != uc)
+ break;
return ptr - str;
}
/* General case. */
@@ -44,7 +44,7 @@ FUNC (const UNIT *str, const UNIT *accept)
const UNIT *ptr = str;
for (; *ptr != 0; ptr++)
if (!U_STRCHR (accept, *ptr))
- break;
+ break;
return ptr - str;
}
}
diff --git a/lib/unistr/u32-strstr.c b/lib/unistr/u32-strstr.c
index 285746d..cad06fc 100644
--- a/lib/unistr/u32-strstr.c
+++ b/lib/unistr/u32-strstr.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-32 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-strtok.c b/lib/unistr/u32-strtok.c
index 3f21919..067122f 100644
--- a/lib/unistr/u32-strtok.c
+++ b/lib/unistr/u32-strtok.c
@@ -1,5 +1,5 @@
/* Tokenize UTF-32 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u32-to-u16.c b/lib/unistr/u32-to-u16.c
index 3a32162..be32770 100644
--- a/lib/unistr/u32-to-u16.c
+++ b/lib/unistr/u32-to-u16.c
@@ -1,5 +1,5 @@
/* Convert UTF-32 string to UTF-16 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -60,60 +60,60 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
/* Fetch a Unicode character from the input string. */
uc = *s++;
/* No need to call the safe variant u32_mbtouc, because
- u16_uctomb will verify uc anyway. */
+ u16_uctomb will verify uc anyway. */
/* Store it in the output string. */
count = u16_uctomb (result + length, uc, allocated - length);
if (count == -1)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
if (count == -2)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 2 > allocated)
- allocated = length + 2;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- count = u16_uctomb (result + length, uc, allocated - length);
- if (count < 0)
- abort ();
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 2 > allocated)
+ allocated = length + 2;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ count = u16_uctomb (result + length, uc, allocated - length);
+ if (count < 0)
+ abort ();
+ }
length += count;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -122,7 +122,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u32-to-u8.c b/lib/unistr/u32-to-u8.c
index 4dce896..36710d3 100644
--- a/lib/unistr/u32-to-u8.c
+++ b/lib/unistr/u32-to-u8.c
@@ -1,5 +1,5 @@
/* Convert UTF-32 string to UTF-8 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -60,60 +60,60 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
/* Fetch a Unicode character from the input string. */
uc = *s++;
/* No need to call the safe variant u32_mbtouc, because
- u8_uctomb will verify uc anyway. */
+ u8_uctomb will verify uc anyway. */
/* Store it in the output string. */
count = u8_uctomb (result + length, uc, allocated - length);
if (count == -1)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
if (count == -2)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 6 > allocated)
- allocated = length + 6;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- count = u8_uctomb (result + length, uc, allocated - length);
- if (count < 0)
- abort ();
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 6 > allocated)
+ allocated = length + 6;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ count = u8_uctomb (result + length, uc, allocated - length);
+ if (count < 0)
+ abort ();
+ }
length += count;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -122,7 +122,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u32-uctomb.c b/lib/unistr/u32-uctomb.c
index 583b3b6..3ac58b4 100644
--- a/lib/unistr/u32-uctomb.c
+++ b/lib/unistr/u32-uctomb.c
@@ -1,5 +1,5 @@
/* Store a character in UTF-32 string.
- Copyright (C) 2002, 2005-2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,12 +33,12 @@ u32_uctomb (uint32_t *s, ucs4_t uc, int n)
if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
{
if (n > 0)
- {
- *s = uc;
- return 1;
- }
+ {
+ *s = uc;
+ return 1;
+ }
else
- return -2;
+ return -2;
}
else
return -1;
diff --git a/lib/unistr/u8-check.c b/lib/unistr/u8-check.c
index 53897fc..368042b 100644
--- a/lib/unistr/u8-check.c
+++ b/lib/unistr/u8-check.c
@@ -1,5 +1,5 @@
/* Check UTF-8 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,73 +31,73 @@ u8_check (const uint8_t *s, size_t n)
uint8_t c = *s;
if (c < 0x80)
- {
- s++;
- continue;
- }
+ {
+ s++;
+ continue;
+ }
if (c >= 0xc2)
- {
- if (c < 0xe0)
- {
- if (s + 2 <= s_end
- && (s[1] ^ 0x80) < 0x40)
- {
- s += 2;
- continue;
- }
- }
- else if (c < 0xf0)
- {
- if (s + 3 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
- {
- s += 3;
- continue;
- }
- }
- else if (c < 0xf8)
- {
- if (s + 4 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ {
+ if (c < 0xe0)
+ {
+ if (s + 2 <= s_end
+ && (s[1] ^ 0x80) < 0x40)
+ {
+ s += 2;
+ continue;
+ }
+ }
+ else if (c < 0xf0)
+ {
+ if (s + 3 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
+ {
+ s += 3;
+ continue;
+ }
+ }
+ else if (c < 0xf8)
+ {
+ if (s + 4 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
- {
- s += 4;
- continue;
- }
- }
+ )
+ {
+ s += 4;
+ continue;
+ }
+ }
#if 0
- else if (c < 0xfc)
- {
- if (s + 5 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
- {
- s += 5;
- continue;
- }
- }
- else if (c < 0xfe)
- {
- if (s + 6 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
- {
- s += 6;
- continue;
- }
- }
+ else if (c < 0xfc)
+ {
+ if (s + 5 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
+ {
+ s += 5;
+ continue;
+ }
+ }
+ else if (c < 0xfe)
+ {
+ if (s + 6 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
+ {
+ s += 6;
+ continue;
+ }
+ }
#endif
- }
+ }
/* invalid or incomplete multibyte character */
return s;
}
diff --git a/lib/unistr/u8-chr.c b/lib/unistr/u8-chr.c
index 2c4d768..435d1be 100644
--- a/lib/unistr/u8-chr.c
+++ b/lib/unistr/u8-chr.c
@@ -1,5 +1,6 @@
/* Search character in piece of UTF-8 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,58 +31,58 @@ u8_chr (const uint8_t *s, size_t n, ucs4_t uc)
uint8_t c0 = uc;
for (; n > 0; s++, n--)
- {
- if (*s == c0)
- return (uint8_t *) s;
- }
+ {
+ if (*s == c0)
+ return (uint8_t *) s;
+ }
}
else
switch (u8_uctomb_aux (c, uc, 6))
{
case 2:
- if (n > 1)
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
+ if (n > 1)
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
- for (n--; n > 0; s++, n--)
- {
- if (*s == c0 && s[1] == c1)
- return (uint8_t *) s;
- }
- }
- break;
+ for (n--; n > 0; s++, n--)
+ {
+ if (*s == c0 && s[1] == c1)
+ return (uint8_t *) s;
+ }
+ }
+ break;
case 3:
- if (n > 2)
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
+ if (n > 2)
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
- for (n -= 2; n > 0; s++, n--)
- {
- if (*s == c0 && s[1] == c1 && s[2] == c2)
- return (uint8_t *) s;
- }
- }
- break;
+ for (n -= 2; n > 0; s++, n--)
+ {
+ if (*s == c0 && s[1] == c1 && s[2] == c2)
+ return (uint8_t *) s;
+ }
+ }
+ break;
case 4:
- if (n > 3)
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
- uint8_t c3 = c[3];
+ if (n > 3)
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
+ uint8_t c3 = c[3];
- for (n -= 3; n > 0; s++, n--)
- {
- if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
- return (uint8_t *) s;
- }
- }
- break;
+ for (n -= 3; n > 0; s++, n--)
+ {
+ if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
+ return (uint8_t *) s;
+ }
+ }
+ break;
}
return NULL;
}
diff --git a/lib/unistr/u8-cmp.c b/lib/unistr/u8-cmp.c
index 77b2402..d021b1a 100644
--- a/lib/unistr/u8-cmp.c
+++ b/lib/unistr/u8-cmp.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-cmp2.c b/lib/unistr/u8-cmp2.c
index 99cee9f..8a97db4 100644
--- a/lib/unistr/u8-cmp2.c
+++ b/lib/unistr/u8-cmp2.c
@@ -1,5 +1,5 @@
/* Compare pieces of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-cpy-alloc.c b/lib/unistr/u8-cpy-alloc.c
index b2dcc5d..1884516 100644
--- a/lib/unistr/u8-cpy-alloc.c
+++ b/lib/unistr/u8-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-cpy.c b/lib/unistr/u8-cpy.c
index bf3a55b..2f29200 100644
--- a/lib/unistr/u8-cpy.c
+++ b/lib/unistr/u8-cpy.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-endswith.c b/lib/unistr/u8-endswith.c
index e40613a..833b3e1 100644
--- a/lib/unistr/u8-endswith.c
+++ b/lib/unistr/u8-endswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-mblen.c b/lib/unistr/u8-mblen.c
index 1981bef..f6a2027 100644
--- a/lib/unistr/u8-mblen.c
+++ b/lib/unistr/u8-mblen.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -29,69 +30,69 @@ u8_mblen (const uint8_t *s, size_t n)
uint8_t c = *s;
if (c < 0x80)
- return (c != 0 ? 1 : 0);
+ return (c != 0 ? 1 : 0);
if (c >= 0xc2)
- {
- if (c < 0xe0)
- {
- if (n >= 2
+ {
+ if (c < 0xe0)
+ {
+ if (n >= 2
#if CONFIG_UNICODE_SAFETY
- && (s[1] ^ 0x80) < 0x40
+ && (s[1] ^ 0x80) < 0x40
#endif
- )
- return 2;
- }
- else if (c < 0xf0)
- {
- if (n >= 3
+ )
+ return 2;
+ }
+ else if (c < 0xf0)
+ {
+ if (n >= 3
#if CONFIG_UNICODE_SAFETY
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0)
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0)
#endif
- )
- return 3;
- }
- else if (c < 0xf8)
- {
- if (n >= 4
+ )
+ return 3;
+ }
+ else if (c < 0xf8)
+ {
+ if (n >= 4
#if CONFIG_UNICODE_SAFETY
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
#endif
- )
- return 4;
- }
+ )
+ return 4;
+ }
#if 0
- else if (c < 0xfc)
- {
- if (n >= 5
+ else if (c < 0xfc)
+ {
+ if (n >= 5
#if CONFIG_UNICODE_SAFETY
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88)
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88)
#endif
- )
- return 5;
- }
- else if (c < 0xfe)
- {
- if (n >= 6
+ )
+ return 5;
+ }
+ else if (c < 0xfe)
+ {
+ if (n >= 6
#if CONFIG_UNICODE_SAFETY
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84)
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84)
#endif
- )
- return 6;
- }
+ )
+ return 6;
+ }
#endif
- }
+ }
}
/* invalid or incomplete multibyte character */
return -1;
diff --git a/lib/unistr/u8-mbsnlen.c b/lib/unistr/u8-mbsnlen.c
index 29af297..9ddc42e 100644
--- a/lib/unistr/u8-mbsnlen.c
+++ b/lib/unistr/u8-mbsnlen.c
@@ -1,5 +1,5 @@
/* Count characters in UTF-8 string.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify it
@@ -28,12 +28,15 @@ u8_mbsnlen (const uint8_t *s, size_t n)
characters = 0;
while (n > 0)
{
- int count = u8_mblen (s, n);
+ ucs4_t uc;
+ int count = u8_mbtoucr (&uc, s, n);
+ characters++;
+ if (count == -2)
+ break;
if (count <= 0)
- count = 1;
+ count = 1;
s += count;
n -= count;
- characters++;
}
return characters;
}
diff --git a/lib/unistr/u8-mbtouc-aux.c b/lib/unistr/u8-mbtouc-aux.c
index 53d02bf..c997589 100644
--- a/lib/unistr/u8-mbtouc-aux.c
+++ b/lib/unistr/u8-mbtouc-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-8 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -30,124 +30,124 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
if (c >= 0xc2)
{
if (c < 0xe0)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf0)
- {
- if (n >= 3)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 3)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf8)
- {
- if (n >= 4)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ {
+ if (n >= 4)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ )
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
- if (n >= 5)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 5)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xfe)
- {
- if (n >= 6)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 6)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#endif
}
/* invalid multibyte character */
diff --git a/lib/unistr/u8-mbtouc-unsafe-aux.c b/lib/unistr/u8-mbtouc-unsafe-aux.c
index 43e4a36..47590e3 100644
--- a/lib/unistr/u8-mbtouc-unsafe-aux.c
+++ b/lib/unistr/u8-mbtouc-unsafe-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-8 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -30,134 +30,134 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
if (c >= 0xc2)
{
if (c < 0xe0)
- {
- if (n >= 2)
- {
+ {
+ if (n >= 2)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40)
+ if ((s[1] ^ 0x80) < 0x40)
#endif
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf0)
- {
- if (n >= 3)
- {
+ {
+ if (n >= 3)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
#endif
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf8)
- {
- if (n >= 4)
- {
+ {
+ if (n >= 4)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
+ )
#endif
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
- if (n >= 5)
- {
+ {
+ if (n >= 5)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
#endif
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xfe)
- {
- if (n >= 6)
- {
+ {
+ if (n >= 6)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
#endif
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#endif
}
/* invalid multibyte character */
diff --git a/lib/unistr/u8-mbtouc-unsafe.c b/lib/unistr/u8-mbtouc-unsafe.c
index 4661569..41583f9 100644
--- a/lib/unistr/u8-mbtouc-unsafe.c
+++ b/lib/unistr/u8-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -41,134 +41,134 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2)
{
if (c < 0xe0)
- {
- if (n >= 2)
- {
+ {
+ if (n >= 2)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40)
+ if ((s[1] ^ 0x80) < 0x40)
#endif
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf0)
- {
- if (n >= 3)
- {
+ {
+ if (n >= 3)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
#endif
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf8)
- {
- if (n >= 4)
- {
+ {
+ if (n >= 4)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
+ )
#endif
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
- if (n >= 5)
- {
+ {
+ if (n >= 5)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
#endif
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xfe)
- {
- if (n >= 6)
- {
+ {
+ if (n >= 6)
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
#endif
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#endif
}
/* invalid multibyte character */
diff --git a/lib/unistr/u8-mbtouc.c b/lib/unistr/u8-mbtouc.c
index ff624f1..96cd5b7 100644
--- a/lib/unistr/u8-mbtouc.c
+++ b/lib/unistr/u8-mbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2002, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -40,124 +40,124 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2)
{
if (c < 0xe0)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf0)
- {
- if (n >= 3)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 3)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xf8)
- {
- if (n >= 4)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ {
+ if (n >= 4)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ )
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
- if (n >= 5)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 5)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
else if (c < 0xfe)
- {
- if (n >= 6)
- {
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return n;
- }
- }
+ {
+ if (n >= 6)
+ {
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return n;
+ }
+ }
#endif
}
/* invalid multibyte character */
diff --git a/lib/unistr/u8-mbtoucr.c b/lib/unistr/u8-mbtoucr.c
index dd83352..a749c48 100644
--- a/lib/unistr/u8-mbtoucr.c
+++ b/lib/unistr/u8-mbtoucr.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string, returning an error code.
- Copyright (C) 1999-2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify it
@@ -33,250 +33,250 @@ u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2)
{
if (c < 0xe0)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
else if (c < 0xf0)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
- {
- if (n >= 3)
- {
- if ((s[2] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
+ {
+ if (n >= 3)
+ {
+ if ((s[2] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
else if (c < 0xf8)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
- {
- if (n >= 3)
- {
- if ((s[2] ^ 0x80) < 0x40)
- {
- if (n >= 4)
- {
- if ((s[3] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
+ )
+ {
+ if (n >= 3)
+ {
+ if ((s[2] ^ 0x80) < 0x40)
+ {
+ if (n >= 4)
+ {
+ if ((s[3] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
- {
- if (n >= 3)
- {
- if ((s[2] ^ 0x80) < 0x40)
- {
- if (n >= 4)
- {
- if ((s[3] ^ 0x80) < 0x40)
- {
- if (n >= 5)
- {
- if ((s[4] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
+ {
+ if (n >= 3)
+ {
+ if ((s[2] ^ 0x80) < 0x40)
+ {
+ if (n >= 4)
+ {
+ if ((s[3] ^ 0x80) < 0x40)
+ {
+ if (n >= 5)
+ {
+ if ((s[4] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
else if (c < 0xfe)
- {
- if (n >= 2)
- {
- if ((s[1] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
- {
- if (n >= 3)
- {
- if ((s[2] ^ 0x80) < 0x40)
- {
- if (n >= 4)
- {
- if ((s[3] ^ 0x80) < 0x40)
- {
- if (n >= 5)
- {
- if ((s[4] ^ 0x80) < 0x40)
- {
- if (n >= 6)
- {
- if ((s[5] ^ 0x80) < 0x40)
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
- /* invalid multibyte character */
- }
- else
- {
- /* incomplete multibyte character */
- *puc = 0xfffd;
- return -2;
- }
- }
+ {
+ if (n >= 2)
+ {
+ if ((s[1] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
+ {
+ if (n >= 3)
+ {
+ if ((s[2] ^ 0x80) < 0x40)
+ {
+ if (n >= 4)
+ {
+ if ((s[3] ^ 0x80) < 0x40)
+ {
+ if (n >= 5)
+ {
+ if ((s[4] ^ 0x80) < 0x40)
+ {
+ if (n >= 6)
+ {
+ if ((s[5] ^ 0x80) < 0x40)
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
+ /* invalid multibyte character */
+ }
+ else
+ {
+ /* incomplete multibyte character */
+ *puc = 0xfffd;
+ return -2;
+ }
+ }
#endif
}
/* invalid multibyte character */
diff --git a/lib/unistr/u8-move.c b/lib/unistr/u8-move.c
index 5a30be8..5c48411 100644
--- a/lib/unistr/u8-move.c
+++ b/lib/unistr/u8-move.c
@@ -1,5 +1,5 @@
/* Copy piece of UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-next.c b/lib/unistr/u8-next.c
index ecf4f80..34249aa 100644
--- a/lib/unistr/u8-next.c
+++ b/lib/unistr/u8-next.c
@@ -1,5 +1,5 @@
/* Iterate over next character in UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,7 +31,7 @@ u8_next (ucs4_t *puc, const uint8_t *s)
else
{
if (count < 0)
- *puc = 0xfffd;
+ *puc = 0xfffd;
return NULL;
}
}
diff --git a/lib/unistr/u8-prev.c b/lib/unistr/u8-prev.c
index 245d22f..97a27f5 100644
--- a/lib/unistr/u8-prev.c
+++ b/lib/unistr/u8-prev.c
@@ -1,5 +1,5 @@
/* Iterate over previous character in UTF-8 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -29,65 +29,65 @@ u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
uint8_t c_1 = s[-1];
if (c_1 < 0x80)
- {
- *puc = c_1;
- return s - 1;
- }
+ {
+ *puc = c_1;
+ return s - 1;
+ }
#if CONFIG_UNICODE_SAFETY
if ((c_1 ^ 0x80) < 0x40)
#endif
- if (s - 1 != start)
- {
- uint8_t c_2 = s[-2];
+ if (s - 1 != start)
+ {
+ uint8_t c_2 = s[-2];
- if (c_2 >= 0xc2 && c_2 < 0xe0)
- {
- *puc = ((unsigned int) (c_2 & 0x1f) << 6)
- | (unsigned int) (c_1 ^ 0x80);
- return s - 2;
- }
+ if (c_2 >= 0xc2 && c_2 < 0xe0)
+ {
+ *puc = ((unsigned int) (c_2 & 0x1f) << 6)
+ | (unsigned int) (c_1 ^ 0x80);
+ return s - 2;
+ }
#if CONFIG_UNICODE_SAFETY
- if ((c_2 ^ 0x80) < 0x40)
+ if ((c_2 ^ 0x80) < 0x40)
#endif
- if (s - 2 != start)
- {
- uint8_t c_3 = s[-3];
+ if (s - 2 != start)
+ {
+ uint8_t c_3 = s[-3];
- if (c_3 >= 0xe0 && c_3 < 0xf0
+ if (c_3 >= 0xe0 && c_3 < 0xf0
#if CONFIG_UNICODE_SAFETY
- && (c_3 >= 0xe1 || c_2 >= 0xa0)
- && (c_3 != 0xed || c_2 < 0xa0)
+ && (c_3 >= 0xe1 || c_2 >= 0xa0)
+ && (c_3 != 0xed || c_2 < 0xa0)
#endif
- )
- {
- *puc = ((unsigned int) (c_3 & 0x0f) << 12)
- | ((unsigned int) (c_2 ^ 0x80) << 6)
- | (unsigned int) (c_1 ^ 0x80);
- return s - 3;
- }
+ )
+ {
+ *puc = ((unsigned int) (c_3 & 0x0f) << 12)
+ | ((unsigned int) (c_2 ^ 0x80) << 6)
+ | (unsigned int) (c_1 ^ 0x80);
+ return s - 3;
+ }
#if CONFIG_UNICODE_SAFETY
- if ((c_3 ^ 0x80) < 0x40)
+ if ((c_3 ^ 0x80) < 0x40)
#endif
- if (s - 3 != start)
- {
- uint8_t c_4 = s[-4];
+ if (s - 3 != start)
+ {
+ uint8_t c_4 = s[-4];
- if (c_4 >= 0xf0 && c_4 < 0xf8
+ if (c_4 >= 0xf0 && c_4 < 0xf8
#if CONFIG_UNICODE_SAFETY
- && (c_4 >= 0xf1 || c_3 >= 0x90)
- && (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))
+ && (c_4 >= 0xf1 || c_3 >= 0x90)
+ && (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))
#endif
- )
- {
- *puc = ((unsigned int) (c_4 & 0x07) << 18)
- | ((unsigned int) (c_3 ^ 0x80) << 12)
- | ((unsigned int) (c_2 ^ 0x80) << 6)
- | (unsigned int) (c_1 ^ 0x80);
- return s - 4;
- }
- }
- }
- }
+ )
+ {
+ *puc = ((unsigned int) (c_4 & 0x07) << 18)
+ | ((unsigned int) (c_3 ^ 0x80) << 12)
+ | ((unsigned int) (c_2 ^ 0x80) << 6)
+ | (unsigned int) (c_1 ^ 0x80);
+ return s - 4;
+ }
+ }
+ }
+ }
}
return NULL;
}
diff --git a/lib/unistr/u8-set.c b/lib/unistr/u8-set.c
index 5bb4fd7..3cca23b 100644
--- a/lib/unistr/u8-set.c
+++ b/lib/unistr/u8-set.c
@@ -1,5 +1,5 @@
/* Fill UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,12 +33,12 @@ FUNC (UNIT *s, ucs4_t uc, size_t n)
if (n > 0)
{
if (IS_SINGLE_UNIT (uc))
- memset ((char *) s, uc, n);
+ memset ((char *) s, uc, n);
else
- {
- errno = EILSEQ;
- return NULL;
- }
+ {
+ errno = EILSEQ;
+ return NULL;
+ }
}
return s;
}
diff --git a/lib/unistr/u8-startswith.c b/lib/unistr/u8-startswith.c
index 671e3d9..4cc436a 100644
--- a/lib/unistr/u8-startswith.c
+++ b/lib/unistr/u8-startswith.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-stpcpy.c b/lib/unistr/u8-stpcpy.c
index a5c15c5..0faba41 100644
--- a/lib/unistr/u8-stpcpy.c
+++ b/lib/unistr/u8-stpcpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-stpncpy.c b/lib/unistr/u8-stpncpy.c
index 87f254d..a456bea 100644
--- a/lib/unistr/u8-stpncpy.c
+++ b/lib/unistr/u8-stpncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strcat.c b/lib/unistr/u8-strcat.c
index 25ec5d3..2b54bad 100644
--- a/lib/unistr/u8-strcat.c
+++ b/lib/unistr/u8-strcat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strchr.c b/lib/unistr/u8-strchr.c
index 370a793..3be14c7 100644
--- a/lib/unistr/u8-strchr.c
+++ b/lib/unistr/u8-strchr.c
@@ -1,5 +1,6 @@
/* Search character in UTF-8 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -30,70 +31,70 @@ u8_strchr (const uint8_t *s, ucs4_t uc)
uint8_t c0 = uc;
for (;; s++)
- {
- if (*s == c0)
- break;
- if (*s == 0)
- goto notfound;
- }
+ {
+ if (*s == c0)
+ break;
+ if (*s == 0)
+ goto notfound;
+ }
return (uint8_t *) s;
}
else
switch (u8_uctomb_aux (c, uc, 6))
{
case 2:
- if (*s == 0)
- goto notfound;
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
+ if (*s == 0)
+ goto notfound;
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
- for (;; s++)
- {
- if (s[1] == 0)
- goto notfound;
- if (*s == c0 && s[1] == c1)
- break;
- }
- return (uint8_t *) s;
- }
+ for (;; s++)
+ {
+ if (s[1] == 0)
+ goto notfound;
+ if (*s == c0 && s[1] == c1)
+ break;
+ }
+ return (uint8_t *) s;
+ }
case 3:
- if (*s == 0 || s[1] == 0)
- goto notfound;
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
+ if (*s == 0 || s[1] == 0)
+ goto notfound;
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
- for (;; s++)
- {
- if (s[2] == 0)
- goto notfound;
- if (*s == c0 && s[1] == c1 && s[2] == c2)
- break;
- }
- return (uint8_t *) s;
- }
+ for (;; s++)
+ {
+ if (s[2] == 0)
+ goto notfound;
+ if (*s == c0 && s[1] == c1 && s[2] == c2)
+ break;
+ }
+ return (uint8_t *) s;
+ }
case 4:
- if (*s == 0 || s[1] == 0 || s[2] == 0)
- goto notfound;
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
- uint8_t c3 = c[3];
+ if (*s == 0 || s[1] == 0 || s[2] == 0)
+ goto notfound;
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
+ uint8_t c3 = c[3];
- for (;; s++)
- {
- if (s[3] == 0)
- goto notfound;
- if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
- break;
- }
- return (uint8_t *) s;
- }
+ for (;; s++)
+ {
+ if (s[3] == 0)
+ goto notfound;
+ if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
+ break;
+ }
+ return (uint8_t *) s;
+ }
}
notfound:
return NULL;
diff --git a/lib/unistr/u8-strcmp.c b/lib/unistr/u8-strcmp.c
index 58b4b8c..82a4414 100644
--- a/lib/unistr/u8-strcmp.c
+++ b/lib/unistr/u8-strcmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strcoll.c b/lib/unistr/u8-strcoll.c
index ca08609..9ffa135 100644
--- a/lib/unistr/u8-strcoll.c
+++ b/lib/unistr/u8-strcoll.c
@@ -1,5 +1,5 @@
/* Compare UTF-8 strings using the collation rules of the current locale.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strcpy.c b/lib/unistr/u8-strcpy.c
index b93c8cb..9662de5 100644
--- a/lib/unistr/u8-strcpy.c
+++ b/lib/unistr/u8-strcpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strcspn.c b/lib/unistr/u8-strcspn.c
index a43b53f..4b5b8e0 100644
--- a/lib/unistr/u8-strcspn.c
+++ b/lib/unistr/u8-strcspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strdup.c b/lib/unistr/u8-strdup.c
index feaa872..58a3077 100644
--- a/lib/unistr/u8-strdup.c
+++ b/lib/unistr/u8-strdup.c
@@ -1,5 +1,5 @@
/* Copy UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strlen.c b/lib/unistr/u8-strlen.c
index cf5b9ce..b8bebf0 100644
--- a/lib/unistr/u8-strlen.c
+++ b/lib/unistr/u8-strlen.c
@@ -1,5 +1,5 @@
/* Determine length of UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strmblen.c b/lib/unistr/u8-strmblen.c
index 52db99d..52242c5 100644
--- a/lib/unistr/u8-strmblen.c
+++ b/lib/unistr/u8-strmblen.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,64 +32,64 @@ u8_strmblen (const uint8_t *s)
if (c >= 0xc2)
{
if (c < 0xe0)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40)
+ if ((s[1] ^ 0x80) < 0x40)
#else
- if (s[1] != 0)
+ if (s[1] != 0)
#endif
- return 2;
- }
+ return 2;
+ }
else if (c < 0xf0)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
#else
- if (s[1] != 0 && s[2] != 0)
+ if (s[1] != 0 && s[2] != 0)
#endif
- return 3;
- }
+ return 3;
+ }
else if (c < 0xf8)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
+ )
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0)
#endif
- return 4;
- }
+ return 4;
+ }
#if 0
else if (c < 0xfc)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0)
#endif
- return 5;
- }
+ return 5;
+ }
else if (c < 0xfe)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0 && s[5] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0 && s[5] != 0)
#endif
- return 6;
- }
+ return 6;
+ }
#endif
}
/* invalid or incomplete multibyte character */
diff --git a/lib/unistr/u8-strmbtouc.c b/lib/unistr/u8-strmbtouc.c
index bc2fdb0..67016c6 100644
--- a/lib/unistr/u8-strmbtouc.c
+++ b/lib/unistr/u8-strmbtouc.c
@@ -1,5 +1,6 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -34,94 +35,94 @@ u8_strmbtouc (ucs4_t *puc, const uint8_t *s)
if (c >= 0xc2)
{
if (c < 0xe0)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40)
+ if ((s[1] ^ 0x80) < 0x40)
#else
- if (s[1] != 0)
+ if (s[1] != 0)
#endif
- {
- *puc = ((unsigned int) (c & 0x1f) << 6)
- | (unsigned int) (s[1] ^ 0x80);
- return 2;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x1f) << 6)
+ | (unsigned int) (s[1] ^ 0x80);
+ return 2;
+ }
+ }
else if (c < 0xf0)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
#else
- if (s[1] != 0 && s[2] != 0)
+ if (s[1] != 0 && s[2] != 0)
#endif
- {
- *puc = ((unsigned int) (c & 0x0f) << 12)
- | ((unsigned int) (s[1] ^ 0x80) << 6)
- | (unsigned int) (s[2] ^ 0x80);
- return 3;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x0f) << 12)
+ | ((unsigned int) (s[1] ^ 0x80) << 6)
+ | (unsigned int) (s[2] ^ 0x80);
+ return 3;
+ }
+ }
else if (c < 0xf8)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
+ )
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0)
#endif
- {
- *puc = ((unsigned int) (c & 0x07) << 18)
- | ((unsigned int) (s[1] ^ 0x80) << 12)
- | ((unsigned int) (s[2] ^ 0x80) << 6)
- | (unsigned int) (s[3] ^ 0x80);
- return 4;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x07) << 18)
+ | ((unsigned int) (s[1] ^ 0x80) << 12)
+ | ((unsigned int) (s[2] ^ 0x80) << 6)
+ | (unsigned int) (s[3] ^ 0x80);
+ return 4;
+ }
+ }
#if 0
else if (c < 0xfc)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0)
#endif
- {
- *puc = ((unsigned int) (c & 0x03) << 24)
- | ((unsigned int) (s[1] ^ 0x80) << 18)
- | ((unsigned int) (s[2] ^ 0x80) << 12)
- | ((unsigned int) (s[3] ^ 0x80) << 6)
- | (unsigned int) (s[4] ^ 0x80);
- return 5;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x03) << 24)
+ | ((unsigned int) (s[1] ^ 0x80) << 18)
+ | ((unsigned int) (s[2] ^ 0x80) << 12)
+ | ((unsigned int) (s[3] ^ 0x80) << 6)
+ | (unsigned int) (s[4] ^ 0x80);
+ return 5;
+ }
+ }
else if (c < 0xfe)
- {
+ {
#if CONFIG_UNICODE_SAFETY
- if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
+ if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
#else
- if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0 && s[5] != 0)
+ if (s[1] != 0 && s[2] != 0 && s[3] != 0 && s[4] != 0 && s[5] != 0)
#endif
- {
- *puc = ((unsigned int) (c & 0x01) << 30)
- | ((unsigned int) (s[1] ^ 0x80) << 24)
- | ((unsigned int) (s[2] ^ 0x80) << 18)
- | ((unsigned int) (s[3] ^ 0x80) << 12)
- | ((unsigned int) (s[4] ^ 0x80) << 6)
- | (unsigned int) (s[5] ^ 0x80);
- return 6;
- }
- }
+ {
+ *puc = ((unsigned int) (c & 0x01) << 30)
+ | ((unsigned int) (s[1] ^ 0x80) << 24)
+ | ((unsigned int) (s[2] ^ 0x80) << 18)
+ | ((unsigned int) (s[3] ^ 0x80) << 12)
+ | ((unsigned int) (s[4] ^ 0x80) << 6)
+ | (unsigned int) (s[5] ^ 0x80);
+ return 6;
+ }
+ }
#endif
}
/* invalid or incomplete multibyte character */
diff --git a/lib/unistr/u8-strncat.c b/lib/unistr/u8-strncat.c
index d965460..4780350 100644
--- a/lib/unistr/u8-strncat.c
+++ b/lib/unistr/u8-strncat.c
@@ -1,5 +1,5 @@
/* Concatenate UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strncmp.c b/lib/unistr/u8-strncmp.c
index 5aad7e7..286450b 100644
--- a/lib/unistr/u8-strncmp.c
+++ b/lib/unistr/u8-strncmp.c
@@ -1,5 +1,5 @@
/* Compare UTF-8 strings.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strncpy.c b/lib/unistr/u8-strncpy.c
index f478fab..5ef757b 100644
--- a/lib/unistr/u8-strncpy.c
+++ b/lib/unistr/u8-strncpy.c
@@ -1,5 +1,5 @@
/* Copy UTF-8 string.
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strnlen.c b/lib/unistr/u8-strnlen.c
index 32ce7b8..e732ea2 100644
--- a/lib/unistr/u8-strnlen.c
+++ b/lib/unistr/u8-strnlen.c
@@ -1,5 +1,5 @@
/* Determine bounded length of UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strpbrk.c b/lib/unistr/u8-strpbrk.c
index 1538faa..ec6dc27 100644
--- a/lib/unistr/u8-strpbrk.c
+++ b/lib/unistr/u8-strpbrk.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strrchr.c b/lib/unistr/u8-strrchr.c
index 309f323..6d8e297 100644
--- a/lib/unistr/u8-strrchr.c
+++ b/lib/unistr/u8-strrchr.c
@@ -1,5 +1,6 @@
/* Search character in UTF-8 string.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,69 +34,69 @@ u8_strrchr (const uint8_t *s, ucs4_t uc)
uint8_t c0 = uc;
for (;; s++)
- {
- if (*s == c0)
- result = (uint8_t *) s;
- if (*s == 0)
- break;
- }
+ {
+ if (*s == c0)
+ result = (uint8_t *) s;
+ if (*s == 0)
+ break;
+ }
}
else
switch (u8_uctomb_aux (c, uc, 6))
{
case 2:
- if (*s)
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
+ if (*s)
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
- /* FIXME: Maybe walking the string via u8_mblen is a win? */
- for (;; s++)
- {
- if (s[1] == 0)
- break;
- if (*s == c0 && s[1] == c1)
- result = (uint8_t *) s;
- }
- }
- break;
+ /* FIXME: Maybe walking the string via u8_mblen is a win? */
+ for (;; s++)
+ {
+ if (s[1] == 0)
+ break;
+ if (*s == c0 && s[1] == c1)
+ result = (uint8_t *) s;
+ }
+ }
+ break;
case 3:
- if (*s && s[1])
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
+ if (*s && s[1])
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
- /* FIXME: Maybe walking the string via u8_mblen is a win? */
- for (;; s++)
- {
- if (s[2] == 0)
- break;
- if (*s == c0 && s[1] == c1 && s[2] == c2)
- result = (uint8_t *) s;
- }
- }
- break;
+ /* FIXME: Maybe walking the string via u8_mblen is a win? */
+ for (;; s++)
+ {
+ if (s[2] == 0)
+ break;
+ if (*s == c0 && s[1] == c1 && s[2] == c2)
+ result = (uint8_t *) s;
+ }
+ }
+ break;
case 4:
- if (*s && s[1] && s[2])
- {
- uint8_t c0 = c[0];
- uint8_t c1 = c[1];
- uint8_t c2 = c[2];
- uint8_t c3 = c[3];
+ if (*s && s[1] && s[2])
+ {
+ uint8_t c0 = c[0];
+ uint8_t c1 = c[1];
+ uint8_t c2 = c[2];
+ uint8_t c3 = c[3];
- /* FIXME: Maybe walking the string via u8_mblen is a win? */
- for (;; s++)
- {
- if (s[3] == 0)
- break;
- if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
- result = (uint8_t *) s;
- }
- }
- break;
+ /* FIXME: Maybe walking the string via u8_mblen is a win? */
+ for (;; s++)
+ {
+ if (s[3] == 0)
+ break;
+ if (*s == c0 && s[1] == c1 && s[2] == c2 && s[3] == c3)
+ result = (uint8_t *) s;
+ }
+ }
+ break;
}
return result;
}
diff --git a/lib/unistr/u8-strspn.c b/lib/unistr/u8-strspn.c
index 582c825..7747815 100644
--- a/lib/unistr/u8-strspn.c
+++ b/lib/unistr/u8-strspn.c
@@ -1,5 +1,5 @@
/* Search for some characters in UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strstr.c b/lib/unistr/u8-strstr.c
index b5cbf24..cce37ad 100644
--- a/lib/unistr/u8-strstr.c
+++ b/lib/unistr/u8-strstr.c
@@ -1,5 +1,5 @@
/* Substring test for UTF-8 strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-strtok.c b/lib/unistr/u8-strtok.c
index a8d3821..e5c7203 100644
--- a/lib/unistr/u8-strtok.c
+++ b/lib/unistr/u8-strtok.c
@@ -1,5 +1,5 @@
/* Tokenize UTF-8 string.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-to-u16.c b/lib/unistr/u8-to-u16.c
index 03c6600..3745c2b 100644
--- a/lib/unistr/u8-to-u16.c
+++ b/lib/unistr/u8-to-u16.c
@@ -1,5 +1,5 @@
/* Convert UTF-8 string to UTF-16 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -58,68 +58,68 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
int count;
/* Fetch a Unicode character from the input string. */
- count = u8_mbtouc (&uc, s, s_end - s);
+ count = u8_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
count = u16_uctomb (result + length, uc, allocated - length);
if (count == -1)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
if (count == -2)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 2 > allocated)
- allocated = length + 2;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- count = u16_uctomb (result + length, uc, allocated - length);
- if (count < 0)
- abort ();
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 2 > allocated)
+ allocated = length + 2;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ count = u16_uctomb (result + length, uc, allocated - length);
+ if (count < 0)
+ abort ();
+ }
length += count;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -128,7 +128,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u8-to-u32.c b/lib/unistr/u8-to-u32.c
index 2a0ad39..de2a35e 100644
--- a/lib/unistr/u8-to-u32.c
+++ b/lib/unistr/u8-to-u32.c
@@ -1,5 +1,5 @@
/* Convert UTF-8 string to UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -58,57 +58,57 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
int count;
/* Fetch a Unicode character from the input string. */
- count = u8_mbtouc (&uc, s, s_end - s);
+ count = u8_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
if (length + 1 > allocated)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 1 > allocated)
- allocated = length + 1;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 1 > allocated)
+ allocated = length + 1;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ }
result[length++] = uc;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -117,7 +117,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unistr/u8-uctomb-aux.c b/lib/unistr/u8-uctomb-aux.c
index c42fa50..695921d 100644
--- a/lib/unistr/u8-uctomb-aux.c
+++ b/lib/unistr/u8-uctomb-aux.c
@@ -1,5 +1,5 @@
/* Conversion UCS-4 to UTF-8.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,9 +33,9 @@ u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n)
else if (uc < 0x10000)
{
if (uc < 0xd800 || uc >= 0xe000)
- count = 3;
+ count = 3;
else
- return -1;
+ return -1;
}
#if 0
else if (uc < 0x200000)
diff --git a/lib/unistr/u8-uctomb.c b/lib/unistr/u8-uctomb.c
index 3392166..fd33c05 100644
--- a/lib/unistr/u8-uctomb.c
+++ b/lib/unistr/u8-uctomb.c
@@ -1,5 +1,5 @@
/* Store a character in UTF-8 string.
- Copyright (C) 2002, 2005-2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -33,10 +33,10 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
if (uc < 0x80)
{
if (n > 0)
- {
- s[0] = uc;
- return 1;
- }
+ {
+ s[0] = uc;
+ return 1;
+ }
/* else return -2, below. */
}
else
@@ -44,43 +44,43 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
int count;
if (uc < 0x800)
- count = 2;
+ count = 2;
else if (uc < 0x10000)
- {
- if (uc < 0xd800 || uc >= 0xe000)
- count = 3;
- else
- return -1;
- }
+ {
+ if (uc < 0xd800 || uc >= 0xe000)
+ count = 3;
+ else
+ return -1;
+ }
#if 0
else if (uc < 0x200000)
- count = 4;
+ count = 4;
else if (uc < 0x4000000)
- count = 5;
+ count = 5;
else if (uc <= 0x7fffffff)
- count = 6;
+ count = 6;
#else
else if (uc < 0x110000)
- count = 4;
+ count = 4;
#endif
else
- return -1;
+ return -1;
if (n >= count)
- {
- switch (count) /* note: code falls through cases! */
- {
+ {
+ switch (count) /* note: code falls through cases! */
+ {
#if 0
- case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000;
- case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000;
+ case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000;
+ case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000;
#endif
- case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
- case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
- case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
- /*case 1:*/ s[0] = uc;
- }
- return count;
- }
+ case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
+ case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
+ case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
+ /*case 1:*/ s[0] = uc;
+ }
+ return count;
+ }
}
return -2;
}