changeset 14456:abce45d2a253

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.
author Bruno Haible <bruno@clisp.org>
date Mon, 21 Mar 2011 23:10:13 +0100
parents 51b56c6309e5
children ee101cad02be
files ChangeLog lib/unictype/joininggroup_byname.c lib/unictype/joininggroup_byname.gperf modules/unictype/joininggroup-byname
diffstat 4 files changed, 173 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-03-21  Bruno Haible  <bruno@clisp.org>
 
+	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.
+
 	Tests for module 'unictype/joininggroup-name'.
 	* modules/unictype/joininggroup-name-tests: New file.
 	* tests/unictype/test-joininggroup_name.c: New file.
new file mode 100644
--- /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;
+}
new file mode 100644
--- /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
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-byname
@@ -0,0 +1,35 @@
+Description:
+Find a Unicode character Arabic joining group, given its name.
+
+Files:
+lib/unictype/joininggroup_byname.c
+lib/unictype/joininggroup_byname.gperf
+
+Depends-on:
+unictype/base
+gperf
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joininggroup-byname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGGROUP_BYNAME
+lib_SOURCES += unictype/joininggroup_byname.c
+endif
+
+unictype/joininggroup_byname.h: unictype/joininggroup_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/joininggroup_byname.gperf > $(srcdir)/unictype/joininggroup_byname.h-t
+	mv $(srcdir)/unictype/joininggroup_byname.h-t $(srcdir)/unictype/joininggroup_byname.h
+BUILT_SOURCES        += unictype/joininggroup_byname.h
+MOSTLYCLEANFILES     += unictype/joininggroup_byname.h-t
+MAINTAINERCLEANFILES += unictype/joininggroup_byname.h
+EXTRA_DIST           += unictype/joininggroup_byname.h
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible