summaryrefslogtreecommitdiff
path: root/gettext-tools/libgettextpo/unistr
diff options
context:
space:
mode:
Diffstat (limited to 'gettext-tools/libgettextpo/unistr')
-rw-r--r--gettext-tools/libgettextpo/unistr/u16-mbtouc-aux.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u16-mbtouc.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-check.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mblen.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mbtouc-aux.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe-aux.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mbtouc.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-mbtoucr.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-next.c37
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-prev.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-strmbtouc.c130
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-uctomb-aux.c2
-rw-r--r--gettext-tools/libgettextpo/unistr/u8-uctomb.c2
14 files changed, 179 insertions, 12 deletions
diff --git a/gettext-tools/libgettextpo/unistr/u16-mbtouc-aux.c b/gettext-tools/libgettextpo/unistr/u16-mbtouc-aux.c
index 9f68c29..2e8487d 100644
--- a/gettext-tools/libgettextpo/unistr/u16-mbtouc-aux.c
+++ b/gettext-tools/libgettextpo/unistr/u16-mbtouc-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-16 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u16-mbtouc.c b/gettext-tools/libgettextpo/unistr/u16-mbtouc.c
index d0b3dec..75a2521 100644
--- a/gettext-tools/libgettextpo/unistr/u16-mbtouc.c
+++ b/gettext-tools/libgettextpo/unistr/u16-mbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-16 string.
- Copyright (C) 1999-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-check.c b/gettext-tools/libgettextpo/unistr/u8-check.c
index 818b2e1..9c4a75c 100644
--- a/gettext-tools/libgettextpo/unistr/u8-check.c
+++ b/gettext-tools/libgettextpo/unistr/u8-check.c
@@ -1,5 +1,5 @@
/* Check UTF-8 string.
- Copyright (C) 2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2015 Free 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/gettext-tools/libgettextpo/unistr/u8-mblen.c b/gettext-tools/libgettextpo/unistr/u8-mblen.c
index 05e2cef..32d960c 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mblen.c
+++ b/gettext-tools/libgettextpo/unistr/u8-mblen.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2014 Free Software
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2015 Free Software
Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
diff --git a/gettext-tools/libgettextpo/unistr/u8-mbtouc-aux.c b/gettext-tools/libgettextpo/unistr/u8-mbtouc-aux.c
index c6f4245..a751844 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mbtouc-aux.c
+++ b/gettext-tools/libgettextpo/unistr/u8-mbtouc-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-8 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe-aux.c b/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe-aux.c
index f60b37e..ae46311 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe-aux.c
+++ b/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe-aux.c
@@ -1,5 +1,5 @@
/* Conversion UTF-8 to UCS-4.
- Copyright (C) 2001-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe.c b/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe.c
index 18040b5..e27dd69 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe.c
+++ b/gettext-tools/libgettextpo/unistr/u8-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-mbtouc.c b/gettext-tools/libgettextpo/unistr/u8-mbtouc.c
index 78c8f0e..2e9aced 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mbtouc.c
+++ b/gettext-tools/libgettextpo/unistr/u8-mbtouc.c
@@ -1,5 +1,5 @@
/* Look at first character in UTF-8 string.
- Copyright (C) 1999-2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-mbtoucr.c b/gettext-tools/libgettextpo/unistr/u8-mbtoucr.c
index b11543a..9cc1500 100644
--- a/gettext-tools/libgettextpo/unistr/u8-mbtoucr.c
+++ b/gettext-tools/libgettextpo/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, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2006-2007, 2009-2015 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
diff --git a/gettext-tools/libgettextpo/unistr/u8-next.c b/gettext-tools/libgettextpo/unistr/u8-next.c
new file mode 100644
index 0000000..a1492b0
--- /dev/null
+++ b/gettext-tools/libgettextpo/unistr/u8-next.c
@@ -0,0 +1,37 @@
+/* Iterate over next character in UTF-8 string.
+ Copyright (C) 2002, 2006, 2009-2015 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2002.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistr.h"
+
+const uint8_t *
+u8_next (ucs4_t *puc, const uint8_t *s)
+{
+ int count;
+
+ count = u8_strmbtouc (puc, s);
+ if (count > 0)
+ return s + count;
+ else
+ {
+ if (count < 0)
+ *puc = 0xfffd;
+ return NULL;
+ }
+}
diff --git a/gettext-tools/libgettextpo/unistr/u8-prev.c b/gettext-tools/libgettextpo/unistr/u8-prev.c
index 6ccdfbd..20c8844 100644
--- a/gettext-tools/libgettextpo/unistr/u8-prev.c
+++ b/gettext-tools/libgettextpo/unistr/u8-prev.c
@@ -1,5 +1,5 @@
/* Iterate over previous character in UTF-8 string.
- Copyright (C) 2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2015 Free 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/gettext-tools/libgettextpo/unistr/u8-strmbtouc.c b/gettext-tools/libgettextpo/unistr/u8-strmbtouc.c
new file mode 100644
index 0000000..a67a202
--- /dev/null
+++ b/gettext-tools/libgettextpo/unistr/u8-strmbtouc.c
@@ -0,0 +1,130 @@
+/* Look at first character in UTF-8 string.
+ Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2015 Free Software
+ Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2002.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistr.h"
+
+int
+u8_strmbtouc (ucs4_t *puc, const uint8_t *s)
+{
+ /* Keep in sync with unistr.h and u8-mbtouc-aux.c. */
+ uint8_t c = *s;
+
+ if (c < 0x80)
+ {
+ *puc = c;
+ return (c != 0 ? 1 : 0);
+ }
+ if (c >= 0xc2)
+ {
+ if (c < 0xe0)
+ {
+#if CONFIG_UNICODE_SAFETY
+ if ((s[1] ^ 0x80) < 0x40)
+#else
+ if (s[1] != 0)
+#endif
+ {
+ *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))
+#else
+ 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;
+ }
+ }
+ 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 1
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+#endif
+ )
+#else
+ 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;
+ }
+ }
+#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))
+#else
+ 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;
+ }
+ }
+ 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))
+#else
+ 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;
+ }
+ }
+#endif
+ }
+ /* invalid or incomplete multibyte character */
+ return -1;
+}
diff --git a/gettext-tools/libgettextpo/unistr/u8-uctomb-aux.c b/gettext-tools/libgettextpo/unistr/u8-uctomb-aux.c
index 8fdd88b..65445be 100644
--- a/gettext-tools/libgettextpo/unistr/u8-uctomb-aux.c
+++ b/gettext-tools/libgettextpo/unistr/u8-uctomb-aux.c
@@ -1,5 +1,5 @@
/* Conversion UCS-4 to UTF-8.
- Copyright (C) 2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2015 Free 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/gettext-tools/libgettextpo/unistr/u8-uctomb.c b/gettext-tools/libgettextpo/unistr/u8-uctomb.c
index df9b227..a8250f4 100644
--- a/gettext-tools/libgettextpo/unistr/u8-uctomb.c
+++ b/gettext-tools/libgettextpo/unistr/u8-uctomb.c
@@ -1,5 +1,5 @@
/* Store a character in UTF-8 string.
- Copyright (C) 2002, 2005-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005-2006, 2009-2015 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it