]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/cns11643l1.h
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / iconvdata / cns11643l1.h
index aa78c26d6c3ac0dd926e3fddc393f1a7ea01ed75..ef9f547e7148fb568e6004e5ac7f2d1427764bf5 100644 (file)
@@ -1,22 +1,21 @@
 /* Access functions for CNS 11643, plane 1 handling.
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library 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
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdint.h>
 #include <gconv.h>
 extern const uint16_t __cns11643l1_to_ucs4_tab[];
 
 
-static inline wchar_t
-cns11643l1_to_ucs4 (const char **s, size_t avail, unsigned char offset)
+static inline uint32_t
+__attribute ((always_inline))
+cns11643l1_to_ucs4 (const unsigned char **s, size_t avail,
+                   unsigned char offset)
 {
   unsigned char ch = *(*s);
   unsigned char ch2;
   int idx;
 
   if (ch < offset || (ch - offset) <= 0x20 || (ch - offset) > 0x7d)
-    return UNKNOWN_10646_CHAR;
+    return __UNKNOWN_10646_CHAR;
 
   if (avail < 2)
     return 0;
 
   ch2 = (*s)[1];
   if ((ch2 - offset) <= 0x20 || (ch2 - offset) >= 0x7f)
-    return UNKNOWN_10646_CHAR;
+    return __UNKNOWN_10646_CHAR;
 
   idx = (ch - 0x21 - offset) * 94 + (ch2 - 0x21 - offset);
-  if (idx > 0x2196)
-    return UNKNOWN_10646_CHAR;
+  if (idx > 0x21f2)
+    return __UNKNOWN_10646_CHAR;
 
   (*s) += 2;
 
-  return __cns11643l1_to_ucs4_tab[idx] ?: ((*s) -= 2, UNKNOWN_10646_CHAR);
+  return __cns11643l1_to_ucs4_tab[idx] ?: ((*s) -= 2, __UNKNOWN_10646_CHAR);
 }
 
 
@@ -70,7 +71,8 @@ extern const char __cns11643l1_from_ucs4_tab14[][2];
 
 
 static inline size_t
-ucs4_to_cns11643l1 (wchar_t wch, char *s, size_t avail)
+__attribute ((always_inline))
+ucs4_to_cns11643l1 (uint32_t wch, unsigned char *s, size_t avail)
 {
   unsigned int ch = (unsigned int) wch;
   char buf[2];
@@ -86,8 +88,10 @@ ucs4_to_cns11643l1 (wchar_t wch, char *s, size_t avail)
       break;
     case 0x391 ... 0x3c9:
       cp = __cns11643l1_from_ucs4_tab3[ch - 0x391];
+      break;
     case 0x2013 ... 0x203e:
       cp = __cns11643l1_from_ucs4_tab4[ch - 0x2013];
+      break;
     case 0x2103:
       cp = "\x22\x6a";
       break;
@@ -105,7 +109,7 @@ ucs4_to_cns11643l1 (wchar_t wch, char *s, size_t avail)
       buf[0] = '\x26';
       buf[1] = '\x35' + (ch - 0x2170);
       break;
-    case 0x2190 ...0x2199:
+    case 0x2190 ... 0x2199:
       cp = __cns11643l1_from_ucs4_tab5[ch - 0x2190];
       break;
     case 0x2215 ... 0x2267:
@@ -134,7 +138,7 @@ ucs4_to_cns11643l1 (wchar_t wch, char *s, size_t avail)
       break;
     case 0x3105 ... 0x3129:
       buf[0] = '\x25';
-      buf[1] = '\x26' + (ch - 0x3105);
+      buf[1] = '\x47' + (ch - 0x3105);
       break;
     case 0x32a3:
       cp = "\x22\x21";
@@ -161,11 +165,11 @@ ucs4_to_cns11643l1 (wchar_t wch, char *s, size_t avail)
       cp = "\x22\x64";
       break;
     default:
-      buf[0] = '\0';
+      return __UNKNOWN_10646_CHAR;
     }
 
   if (cp[0] == '\0')
-    return UNKNOWN_10646_CHAR;
+    return __UNKNOWN_10646_CHAR;
 
   if (avail < 2)
     return 0;