From 7b01a885219f9d3870cedcc5c049a80756271538 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 7 Mar 2009 11:24:50 +0100 Subject: [PATCH] New module 'uninorm/decomposing-form'. --- lib/uninorm.h | 4 ++++ lib/uninorm/decomposing-form.c | 29 +++++++++++++++++++++++++++++ lib/uninorm/nfc.c | 3 ++- lib/uninorm/nfd.c | 3 ++- lib/uninorm/nfkc.c | 3 ++- lib/uninorm/nfkd.c | 3 ++- lib/uninorm/normalize-internal.h | 2 ++ modules/uninorm/decomposing-form | 24 ++++++++++++++++++++++++ modules/uninorm/nfc | 1 + modules/uninorm/nfkc | 1 + 10 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 lib/uninorm/decomposing-form.c create mode 100644 modules/uninorm/decomposing-form diff --git a/lib/uninorm.h b/lib/uninorm.h index 15f1015b6..1750779fe 100644 --- a/lib/uninorm.h +++ b/lib/uninorm.h @@ -132,6 +132,10 @@ extern const struct unicode_normalization_form uninorm_nfkc; #define uninorm_is_composing(nf) \ ((* (const unsigned int *) (nf) >> 1) & 1) +/* Return the decomposing variant of a normalization form. + This maps NFC,NFD -> NFD and NFKC,NFKD -> NFKD. */ +extern uninorm_t uninorm_decomposing_form (uninorm_t nf); + /* Return the specified normalization form of a string. */ extern uint8_t * diff --git a/lib/uninorm/decomposing-form.c b/lib/uninorm/decomposing-form.c new file mode 100644 index 000000000..3b49cb8b4 --- /dev/null +++ b/lib/uninorm/decomposing-form.c @@ -0,0 +1,29 @@ +/* Decomposing variant of a normalization form. + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Bruno Haible , 2009. + + 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 "uninorm.h" + +#include "normalize-internal.h" + +uninorm_t +uninorm_decomposing_form (uninorm_t nf) +{ + return nf->decomposing_variant; +} diff --git a/lib/uninorm/nfc.c b/lib/uninorm/nfc.c index 6ba5a69cb..c205b1668 100644 --- a/lib/uninorm/nfc.c +++ b/lib/uninorm/nfc.c @@ -26,5 +26,6 @@ const struct unicode_normalization_form uninorm_nfc = { NF_IS_COMPOSING, uc_canonical_decomposition, - uc_composition + uc_composition, + &uninorm_nfd }; diff --git a/lib/uninorm/nfd.c b/lib/uninorm/nfd.c index 47f167717..54c98bc2f 100644 --- a/lib/uninorm/nfd.c +++ b/lib/uninorm/nfd.c @@ -26,5 +26,6 @@ const struct unicode_normalization_form uninorm_nfd = { 0, uc_canonical_decomposition, - NULL + NULL, + &uninorm_nfd }; diff --git a/lib/uninorm/nfkc.c b/lib/uninorm/nfkc.c index 1c4da900e..1fb52f13b 100644 --- a/lib/uninorm/nfkc.c +++ b/lib/uninorm/nfkc.c @@ -27,5 +27,6 @@ const struct unicode_normalization_form uninorm_nfkc = { NF_IS_COMPAT_DECOMPOSING | NF_IS_COMPOSING, uc_compat_decomposition, - uc_composition + uc_composition, + &uninorm_nfkd }; diff --git a/lib/uninorm/nfkd.c b/lib/uninorm/nfkd.c index 49a8ed0d9..871dd647d 100644 --- a/lib/uninorm/nfkd.c +++ b/lib/uninorm/nfkd.c @@ -27,5 +27,6 @@ const struct unicode_normalization_form uninorm_nfkd = { NF_IS_COMPAT_DECOMPOSING, uc_compat_decomposition, - NULL + NULL, + &uninorm_nfkd }; diff --git a/lib/uninorm/normalize-internal.h b/lib/uninorm/normalize-internal.h index 05338635a..0b346c658 100644 --- a/lib/uninorm/normalize-internal.h +++ b/lib/uninorm/normalize-internal.h @@ -32,4 +32,6 @@ struct unicode_normalization_form /* Function that combines two Unicode characters, a starter and another character. */ ucs4_t (*composer) (ucs4_t uc1, ucs4_t uc2); + /* Decomposing variant. */ + const struct unicode_normalization_form *decomposing_variant; }; diff --git a/modules/uninorm/decomposing-form b/modules/uninorm/decomposing-form new file mode 100644 index 000000000..3df8f9d3f --- /dev/null +++ b/modules/uninorm/decomposing-form @@ -0,0 +1,24 @@ +Description: +Decomposing variant of a normalization form. + +Files: +lib/uninorm/decomposing-form.c +lib/uninorm/normalize-internal.h + +Depends-on: +uninorm/base + +configure.ac: + +Makefile.am: +lib_SOURCES += uninorm/decomposing-form.c + +Include: +"uninorm.h" + +License: +LGPL + +Maintainer: +Bruno Haible + diff --git a/modules/uninorm/nfc b/modules/uninorm/nfc index 097d0ddf1..31417d388 100644 --- a/modules/uninorm/nfc +++ b/modules/uninorm/nfc @@ -9,6 +9,7 @@ Depends-on: uninorm/base uninorm/canonical-decomposition uninorm/composition +uninorm/nfd configure.ac: diff --git a/modules/uninorm/nfkc b/modules/uninorm/nfkc index ae31ad19e..408c8a10a 100644 --- a/modules/uninorm/nfkc +++ b/modules/uninorm/nfkc @@ -9,6 +9,7 @@ Depends-on: uninorm/base uninorm/compat-decomposition uninorm/composition +uninorm/nfkd configure.ac: -- 2.11.0