summaryrefslogtreecommitdiff
path: root/lib/unistr
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:17 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:17 +0200
commitbd6adfa17d453e4c486e36fed4c5779db90a8a0e (patch)
tree9798677560d5f99061afe9f0db105a8c97f2438a /lib/unistr
parent79ca645d222db2e158784642c3b464a47bea26f3 (diff)
parent3e0814cd9862b89c7a39672672937477bd87ddfb (diff)
Merge commit 'upstream/0.9.3'
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 ae3750c4..6058c4a5 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 dace3e2e..f36a8d03 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 c660eae0..6dad9525 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 739bfbb1..094a87fb 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 77b6788b..d8d58b0a 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 a093e7f6..de78a8eb 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 0486ef88..16966512 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 b13e816f..483f3c2a 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 09bf434c..4d6dd3c7 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 e86bbf99..84430fc9 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 af404a04..9ec5c601 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 153f60ec..b059aea4 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 de326563..77b95508 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 71e527a7..a92e1efa 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 51dcae00..a54d614c 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 40b442ec..e5c9a045 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 3d441b51..55a4f672 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 6a1d2ad2..9bcc3da3 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 2ff46182..34aabc53 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 6502ce4b..d6669af8 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 55b5a31d..df32be8b 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 7ed57d6f..7fdef578 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 380cec2c..4f18383b 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 2d7d797e..13deef4d 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 0130d271..b71c1c34 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 766dcd2d..8c2a8d6e 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 047977eb..33984f9c 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 13e04b81..614d24c4 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 d9abf464..27dcd5aa 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 6bb35ac8..9e7a93a1 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 881958e1..601d81d6 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 5f35b867..bee77fcf 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 9906e301..f2d72259 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 cc858d88..a5a3638b 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 2691db83..26b60890 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 a1bd8ee9..00b7b708 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 2bf8c619..f6efb888 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 7c49f72f..8245f11a 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 3beecf01..4c902ad2 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 9ef307f2..7bad3d61 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 2f39d74f..22a5d5fe 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 9207edc1..59467f7a 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 30ef7e30..49c616ef 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 bb88f1b5..8b358683 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 673152f9..1f8719fa 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 c161c65b..b781211a 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 280ba83e..5a504bf4 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 92c3e7ec..ecde75da 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 2f5ba435..b18bb374 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 22242c29..4a944513 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 9c05541c..da613c2e 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 e7f36250..f07ca0b9 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 78d482ee..9aa5d43c 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 9e14388c..70827160 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 7278b6f0..3ed59c37 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 65676aaa..bd2eb6f6 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 1cd80c41..49e6d58c 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 63605819..45353fa0 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 b3c7ab03..3cf3de2a 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 04ba8e69..ab812ebc 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 bc61233d..54a74d62 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 dd9b247d..f84c4655 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 2f39dcd7..3544cde3 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 38b27ec0..f92cc930 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 384452ba..e2acc9ee 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 6ac5ada5..cbc1abcf 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 87e91271..8c5f5180 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 5a594b25..19002889 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 a273b10b..36496f74 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 6924c482..32476025 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 f9c69608..b9ebefe0 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 2493b65a..747430be 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 d77fa8cf..cee0d939 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 a48c8b21..4530fe42 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 b7a5d185..0a71293e 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 4bd9e817..8dbbfe45 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 4eeef58c..05f7c774 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 7d7993cc..83f77820 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 d6c08f4b..6362d853 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 c529295c..987fb027 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 bc20c93f..f20b1b79 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 de10e09e..5c517cd1 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 0f9a1859..7fcb5979 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 5df82339..3cbfa924 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 19a08943..e55891e7 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 cd4737fd..4e26bb48 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 57a3a3cf..b5df7b7d 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 b82d5ede..5f336ce9 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 d5e1482c..97488553 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 e5001005..f3c70e6c 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 f93ab2ef..595d32e9 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 66e9393e..da4cc5aa 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 eb64cc2a..95d32abd 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 4dde3fff..54b78d7f 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 e94ac300..4c067b9d 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 86f895b5..c9260b0f 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 026ce50c..dcbb9352 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 c8f409bb..9a54f97e 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 2ead8f26..8102ac7f 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 9579a1b0..2c4b6bc8 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 b4641f33..f0030e5c 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 6f802029..e2571d5b 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 285746de..cad06fcc 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 3f219192..067122f0 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 3a32162c..be327703 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 4dce896b..36710d3c 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 583b3b66..3ac58b43 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 53897fc5..368042b0 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 2c4d7687..435d1be6 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 77b2402d..d021b1ab 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 99cee9f2..8a97db40 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 b2dcc5dc..18845165 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 bf3a55bc..2f29200e 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 e40613aa..833b3e18 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 1981befe..f6a20271 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 29af297f..9ddc42ea 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 53d02bf0..c9975896 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 43e4a360..47590e39 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 46615696..41583f96 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 ff624f17..96cd5b74 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 dd833524..a749c48c 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 5a30be8c..5c48411b 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 ecf4f80a..34249aa5 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 245d22ff..97a27f55 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 5bb4fd7a..3cca23b2 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 671e3d9f..4cc436a2 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 a5c15c5d..0faba413 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 87f254d7..a456beac 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 25ec5d37..2b54badf 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 370a7930..3be14c79 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 58b4b8c2..82a44147 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 ca08609e..9ffa135e 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 b93c8cb4..9662de58 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 a43b53fb..4b5b8e07 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 feaa8725..58a30772 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 cf5b9ceb..b8bebf0e 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 52db99d0..52242c58 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 bc2fdb0d..67016c65 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 d9654602..47803505 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 5aad7e76..286450be 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 f478fab6..5ef757bd 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 32ce7b88..e732ea2e 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 1538faa7..ec6dc278 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 309f3234..6d8e2971 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 582c8259..7747815b 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 b5cbf249..cce37adc 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 a8d3821d..e5c72037 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 03c66000..3745c2bd 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 2a0ad39e..de2a35e6 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 c42fa501..695921d6 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 33921669..fd33c05c 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;
}