fchmod-tests, fchmodat tests, lchmod tests: Add more tests.
[gnulib.git] / lib / unictype / combiningclass_name.c
blob6e678cc5a75a7daea93ee8b9a7c946026381c16a
1 /* Canonical combining classes of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2011-2021 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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.
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.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #include <config.h>
20 /* Specification. */
21 #include "unictype.h"
23 #include <stdlib.h>
25 static const signed char u_combining_class_index_part1[10] =
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 */
38 static const signed char u_combining_class_index_part2[241 - 200] =
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 */
83 static const char u_combining_class_name[20][5] =
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 */
107 const char *
108 uc_combining_class_name (int ccc)
110 if (ccc >= 0)
112 int index;
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;
121 if (index >= 0)
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 ();
129 return NULL;