changeset 11280:6f6a66491611

New module 'uninorm/decomposing-form'.
author Bruno Haible <bruno@clisp.org>
date Sat, 07 Mar 2009 11:24:50 +0100
parents a73b4f6432c4
children c4c11ef90aa0
files lib/uninorm.h lib/uninorm/decomposing-form.c lib/uninorm/nfc.c lib/uninorm/nfd.c lib/uninorm/nfkc.c lib/uninorm/nfkd.c lib/uninorm/normalize-internal.h modules/uninorm/decomposing-form modules/uninorm/nfc modules/uninorm/nfkc
diffstat 10 files changed, 69 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/uninorm.h
+++ b/lib/uninorm.h
@@ -132,6 +132,10 @@
 #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 *
new file mode 100644
--- /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 <bruno@clisp.org>, 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 <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "uninorm.h"
+
+#include "normalize-internal.h"
+
+uninorm_t
+uninorm_decomposing_form (uninorm_t nf)
+{
+  return nf->decomposing_variant;
+}
--- a/lib/uninorm/nfc.c
+++ b/lib/uninorm/nfc.c
@@ -26,5 +26,6 @@
   {
     NF_IS_COMPOSING,
     uc_canonical_decomposition,
-    uc_composition
+    uc_composition,
+    &uninorm_nfd
   };
--- a/lib/uninorm/nfd.c
+++ b/lib/uninorm/nfd.c
@@ -26,5 +26,6 @@
   {
     0,
     uc_canonical_decomposition,
-    NULL
+    NULL,
+    &uninorm_nfd
   };
--- a/lib/uninorm/nfkc.c
+++ b/lib/uninorm/nfkc.c
@@ -27,5 +27,6 @@
   {
     NF_IS_COMPAT_DECOMPOSING | NF_IS_COMPOSING,
     uc_compat_decomposition,
-    uc_composition
+    uc_composition,
+    &uninorm_nfkd
   };
--- a/lib/uninorm/nfkd.c
+++ b/lib/uninorm/nfkd.c
@@ -27,5 +27,6 @@
   {
     NF_IS_COMPAT_DECOMPOSING,
     uc_compat_decomposition,
-    NULL
+    NULL,
+    &uninorm_nfkd
   };
--- a/lib/uninorm/normalize-internal.h
+++ b/lib/uninorm/normalize-internal.h
@@ -32,4 +32,6 @@
   /* 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;
 };
new file mode 100644
--- /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
+
--- a/modules/uninorm/nfc
+++ b/modules/uninorm/nfc
@@ -9,6 +9,7 @@
 uninorm/base
 uninorm/canonical-decomposition
 uninorm/composition
+uninorm/nfd
 
 configure.ac:
 
--- a/modules/uninorm/nfkc
+++ b/modules/uninorm/nfkc
@@ -9,6 +9,7 @@
 uninorm/base
 uninorm/compat-decomposition
 uninorm/composition
+uninorm/nfkd
 
 configure.ac: