From a0d399b353149b49168bbe3385ca15a58da73d85 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 21 Mar 2011 23:10:13 +0100 Subject: [PATCH] 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. --- ChangeLog | 5 +++ lib/unictype/joininggroup_byname.c | 63 ++++++++++++++++++++++++++++++ lib/unictype/joininggroup_byname.gperf | 70 ++++++++++++++++++++++++++++++++++ modules/unictype/joininggroup-byname | 35 +++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 lib/unictype/joininggroup_byname.c create mode 100644 lib/unictype/joininggroup_byname.gperf create mode 100644 modules/unictype/joininggroup-byname diff --git a/ChangeLog b/ChangeLog index 41112925e..704fce712 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-03-21 Bruno Haible + 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. diff --git a/lib/unictype/joininggroup_byname.c b/lib/unictype/joininggroup_byname.c new file mode 100644 index 000000000..ca9f1a659 --- /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 , 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 . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include + +#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 000000000..518d1c9cd --- /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 diff --git a/modules/unictype/joininggroup-byname b/modules/unictype/joininggroup-byname new file mode 100644 index 000000000..7aff01e4d --- /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 -- 2.11.0