summaryrefslogtreecommitdiff
path: root/lib/unictype
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-03-21 23:10:13 +0100
committerBruno Haible <bruno@clisp.org>2011-03-21 23:10:13 +0100
commita0d399b353149b49168bbe3385ca15a58da73d85 (patch)
tree202551b033e3a31c0fce71ba89d491b85cc65ffe /lib/unictype
parent7cd4c661c22c16e59371706998561c66fbabaa3a (diff)
downloadgnulib-a0d399b353149b49168bbe3385ca15a58da73d85.tar.gz
New module 'unictype/joininggroup-byname'.
* modules/unictype/joininggroup-byname: New file. * lib/unictype/joininggroup_byname.c: New file. * lib/unictype/joininggroup_byname.gperf: New file.
Diffstat (limited to 'lib/unictype')
-rw-r--r--lib/unictype/joininggroup_byname.c63
-rw-r--r--lib/unictype/joininggroup_byname.gperf70
2 files changed, 133 insertions, 0 deletions
diff --git a/lib/unictype/joininggroup_byname.c b/lib/unictype/joininggroup_byname.c
new file mode 100644
index 0000000000..ca9f1a6594
--- /dev/null
+++ b/lib/unictype/joininggroup_byname.c
@@ -0,0 +1,63 @@
+/* Arabic joining group of Unicode characters.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unictype.h"
+
+#include <string.h>
+
+#include "unictype/joininggroup_byname.h"
+
+int
+uc_joining_group_byname (const char *joining_group_name)
+{
+ size_t len;
+
+ len = strlen (joining_group_name);
+ if (len <= MAX_WORD_LENGTH)
+ {
+ char buf[MAX_WORD_LENGTH + 1];
+ const struct named_joining_group *found;
+
+ /* Copy joining_group_name into buf, converting '_' to ' '. */
+ {
+ const char *p = joining_group_name;
+ char *q = buf;
+
+ for (;; p++, q++)
+ {
+ char c = *p;
+
+ if (c == '_')
+ c = ' ';
+ *q = c;
+ if (c == '\0')
+ break;
+ }
+ }
+ /* Here q == buf + len. */
+
+ /* Do a hash table lookup, with case-insensitive comparison. */
+ found = uc_joining_group_lookup (buf, len);
+ if (found != NULL)
+ return found->joining_group;
+ }
+ /* Invalid joining group name. */
+ return -1;
+}
diff --git a/lib/unictype/joininggroup_byname.gperf b/lib/unictype/joininggroup_byname.gperf
new file mode 100644
index 0000000000..518d1c9cd0
--- /dev/null
+++ b/lib/unictype/joininggroup_byname.gperf
@@ -0,0 +1,70 @@
+/* Arabic joining group of Unicode characters. */
+struct named_joining_group { int name; int joining_group; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name joining_group_hash
+%define lookup-function-name uc_joining_group_lookup
+%readonly-tables
+%global-table
+%define word-array-name joining_group_names
+%pic
+%define string-pool-name joining_group_stringpool
+%%
+No Joining Group, UC_JOINING_GROUP_NONE
+Ain, UC_JOINING_GROUP_AIN
+Alaph, UC_JOINING_GROUP_ALAPH
+Alef, UC_JOINING_GROUP_ALEF
+Beh, UC_JOINING_GROUP_BEH
+Beth, UC_JOINING_GROUP_BETH
+Burushaski Yeh Barree, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE
+Dal, UC_JOINING_GROUP_DAL
+Dalath Rish, UC_JOINING_GROUP_DALATH_RISH
+E, UC_JOINING_GROUP_E
+Farsi Yeh, UC_JOINING_GROUP_FARSI_YEH
+Fe, UC_JOINING_GROUP_FE
+Feh, UC_JOINING_GROUP_FEH
+Final Semkath, UC_JOINING_GROUP_FINAL_SEMKATH
+Gaf, UC_JOINING_GROUP_GAF
+Gamal, UC_JOINING_GROUP_GAMAL
+Hah, UC_JOINING_GROUP_HAH
+He, UC_JOINING_GROUP_HE
+Heh, UC_JOINING_GROUP_HEH
+Heh Goal, UC_JOINING_GROUP_HEH_GOAL
+Heth, UC_JOINING_GROUP_HETH
+Kaf, UC_JOINING_GROUP_KAF
+Kaph, UC_JOINING_GROUP_KAPH
+Khaph, UC_JOINING_GROUP_KHAPH
+Knotted Heh, UC_JOINING_GROUP_KNOTTED_HEH
+Lam, UC_JOINING_GROUP_LAM
+Lamadh, UC_JOINING_GROUP_LAMADH
+Meem, UC_JOINING_GROUP_MEEM
+Mim, UC_JOINING_GROUP_MIM
+Noon, UC_JOINING_GROUP_NOON
+Nun, UC_JOINING_GROUP_NUN
+Nya, UC_JOINING_GROUP_NYA
+Pe, UC_JOINING_GROUP_PE
+Qaf, UC_JOINING_GROUP_QAF
+Qaph, UC_JOINING_GROUP_QAPH
+Reh, UC_JOINING_GROUP_REH
+Reversed Pe, UC_JOINING_GROUP_REVERSED_PE
+Sad, UC_JOINING_GROUP_SAD
+Sadhe, UC_JOINING_GROUP_SADHE
+Seen, UC_JOINING_GROUP_SEEN
+Semkath, UC_JOINING_GROUP_SEMKATH
+Shin, UC_JOINING_GROUP_SHIN
+Swash Kaf, UC_JOINING_GROUP_SWASH_KAF
+Syriac Waw, UC_JOINING_GROUP_SYRIAC_WAW
+Tah, UC_JOINING_GROUP_TAH
+Taw, UC_JOINING_GROUP_TAW
+Teh Marbuta, UC_JOINING_GROUP_TEH_MARBUTA
+Teh Marbuta Goal, UC_JOINING_GROUP_TEH_MARBUTA_GOAL
+Teth, UC_JOINING_GROUP_TETH
+Waw, UC_JOINING_GROUP_WAW
+Yeh, UC_JOINING_GROUP_YEH
+Yeh Barree, UC_JOINING_GROUP_YEH_BARREE
+Yeh with tail, UC_JOINING_GROUP_YEH_WITH_TAIL
+Yudh, UC_JOINING_GROUP_YUDH
+Yudh He, UC_JOINING_GROUP_YUDH_HE
+Zain, UC_JOINING_GROUP_ZAIN
+Zhain, UC_JOINING_GROUP_ZHAIN