maint: update copyright
[gnulib.git] / lib / unictype / combiningclass_name.c
1 /* Canonical combining classes of Unicode characters.
2    Copyright (C) 2002, 2006-2007, 2011-2014 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5    This program is free software: you can redistribute it and/or modify it
6    under the terms of the GNU Lesser General Public License as published
7    by the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #include <config.h>
19
20 /* Specification.  */
21 #include "unictype.h"
22
23 #include <stdlib.h>
24
25 static const signed char u_combining_class_index_part1[10] =
26 {
27    0, /* Not Reordered */
28    1, /* Overlay */
29   -1,
30   -1,
31   -1,
32   -1,
33   -1,
34    2, /* Nukta */
35    3, /* Kana Voicing */
36    4  /* Virama */
37 };
38 static const signed char u_combining_class_index_part2[241 - 200] =
39 {
40    5, /* Attached Below Left */
41   -1,
42    6, /* Attached Below */
43   -1,
44   -1,
45   -1,
46   -1,
47   -1,
48   -1,
49   -1,
50   -1,
51   -1,
52   -1,
53   -1,
54    7, /* Attached Above */
55   -1,
56    8, /* Attached Above Right */
57   -1,
58    9, /* Below Left */
59   -1,
60   10, /* Below */
61   -1,
62   11, /* Below Right */
63   -1,
64   12, /* Left */
65   -1,
66   13, /* Right */
67   -1,
68   14, /* Above Left */
69   -1,
70   15, /* Above */
71   -1,
72   16, /* Above Right */
73   17, /* Double Below */
74   18, /* Double Above */
75   -1,
76   -1,
77   -1,
78   -1,
79   -1,
80   19  /* Iota Subscript */
81 };
82
83 static const char u_combining_class_name[20][5] =
84 {
85   "NR",   /* Not Reordered */
86   "OV",   /* Overlay */
87   "NK",   /* Nukta */
88   "KV",   /* Kana Voicing */
89   "VR",   /* Virama */
90   "ATBL", /* Attached Below Left */
91   "ATB",  /* Attached Below */
92   "ATA",  /* Attached Above */
93   "ATAR", /* Attached Above Right */
94   "BL",   /* Below Left */
95   "B",    /* Below */
96   "BR",   /* Below Right */
97   "L",    /* Left */
98   "R",    /* Right */
99   "AL",   /* Above Left */
100   "A",    /* Above */
101   "AR",   /* Above Right */
102   "DB",   /* Double Below */
103   "DA",   /* Double Above */
104   "IS"    /* Iota Subscript */
105 };
106
107 const char *
108 uc_combining_class_name (int ccc)
109 {
110   if (ccc >= 0)
111     {
112       int index;
113
114       if (ccc < 10)
115         index = u_combining_class_index_part1[ccc];
116       else if (ccc >= 200 && ccc < 241)
117         index = u_combining_class_index_part2[ccc - 200];
118       else
119         return NULL;
120
121       if (index >= 0)
122         {
123           if (index < sizeof (u_combining_class_name) / sizeof (u_combining_class_name[0]))
124             return u_combining_class_name[index];
125           else
126             abort ();
127         }
128     }
129   return NULL;
130 }