[PATCH] implicit Unicode data tables generation
Thomas Wolff
towo@towo.net
Wed Mar 7 23:27:00 GMT 2018
This patch adds rules to generate Unicode data tables for
libc/string/wcwidth, libc/ctype/tow* and libc/ctype/isw* implicitly,
however, the build process is not yet covered.
The rules define how the necessary data tables are built,
but additional dependencies are missing to get the rules actually invoked,
like:
(string/Makefile.am)
wcwidth.c:Â Â Â $(srcdir)/ambiguous.t $(srcdir)/combining.t $(srcdir)/wide.t
(ctype/Makefile.am)
categories.c:Â Â $(srcdir)/categories.t
towctrans_l.c:Â $(srcdir)/caseconv.t
I tried some variations (like $(srcdir)/wcwidth.c:..., lib_a-wcwidth.o:...,
and even an additional dummy wcwidth.h) but it did not work;
I do not know how to specify an additional target for lib_a-wcwidth.o
(make would say âoverriding recipeâ and âignoring old recipeâ)
and I have no idea how to fiddle that into Makefile.am anyway,
so if anyone wants to advocate for the implicit approach, please
add that part.
-------------- next part --------------
From 4b2a7314ec85cd714910cb04ffce92d1cb203054 Mon Sep 17 00:00:00 2001
From: Thomas Wolff <towo@towo.net>
Date: Thu, 8 Mar 2018 00:10:41 +0100
Subject: [PATCH] make rules for implicit Unicode data tables generation
Dependency rules to generate Unicode data tables
for libc functions wcwidth, tow* and isw*.
---
newlib/libc/ctype/Makefile.am | 20 ++++++++++++++++++++
newlib/libc/ctype/Makefile.in | 20 ++++++++++++++++++++
newlib/libc/string/Makefile.am | 24 ++++++++++++++++++++++++
newlib/libc/string/Makefile.in | 24 ++++++++++++++++++++++++
4 files changed, 88 insertions(+)
diff --git a/newlib/libc/ctype/Makefile.am b/newlib/libc/ctype/Makefile.am
index fa6a70d..714b333 100644
--- a/newlib/libc/ctype/Makefile.am
+++ b/newlib/libc/ctype/Makefile.am
@@ -135,3 +135,23 @@ CHEWOUT_FILES= \
CHAPTERS = ctype.tex
$(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
+
+#############################################################################
+# Unicode data
+
+$(srcdir)/%.txt:
+ cd $(srcdir); test -r $(notdir $@) || ln -s /usr/share/unicode/ucd/$(notdir $@) .
+
+#############################################################################
+# case conversion and character category data for libc/ctype/??w*.c
+
+categories.c: $(srcdir)/categories.t
+
+towctrans_l.c: $(srcdir)/caseconv.t
+
+$(srcdir)/categories.t: $(srcdir)/UnicodeData.txt
+ cd $(srcdir); sh ./mkcategories
+
+$(srcdir)/caseconv.t: $(srcdir)/UnicodeData.txt
+ cd $(srcdir); sh ./mkcaseconv
+
diff --git a/newlib/libc/ctype/Makefile.in b/newlib/libc/ctype/Makefile.in
index 9932a94..ffcb384 100644
--- a/newlib/libc/ctype/Makefile.in
+++ b/newlib/libc/ctype/Makefile.in
@@ -1158,3 +1158,23 @@ $(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+
+#############################################################################
+# Unicode data
+
+$(srcdir)/%.txt:
+ cd $(srcdir); test -r $(notdir $@) || ln -s /usr/share/unicode/ucd/$(notdir $@) .
+
+#############################################################################
+# case conversion and character category data for libc/ctype/??w*.c
+
+categories.c: $(srcdir)/categories.t
+
+towctrans_l.c: $(srcdir)/caseconv.t
+
+$(srcdir)/categories.t: $(srcdir)/UnicodeData.txt
+ cd $(srcdir); sh ./mkcategories
+
+$(srcdir)/caseconv.t: $(srcdir)/UnicodeData.txt
+ cd $(srcdir); sh ./mkcaseconv
+
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index 49de080..2617112 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -168,3 +168,27 @@ wcscasecmp_l.def wcscoll_l.def wcsncasecmp_l.def wcsxfrm_l.def \
strverscmp.def strnstr.def wmempcpy.def
CHAPTERS = strings.tex wcstrings.tex
+
+#############################################################################
+# Unicode data
+
+$(srcdir)/%.txt:
+ cd $(srcdir); test -r $(notdir $@) || ln -s /usr/share/unicode/ucd/$(notdir $@) .
+
+#############################################################################
+# width data for libc/string/wcwidth.c
+
+wcwidth.c: $(srcdir)/ambiguous.t $(srcdir)/combining.t $(srcdir)/wide.t
+
+$(srcdir)/combining.t: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt
+ cd $(srcdir); ./uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B +D7B0-D7C6 +D7CB-D7FB c > combining.t
+
+$(srcdir)/WIDTH-A: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt $(srcdir)/EastAsianWidth.txt
+ cd $(srcdir); sh ./mkwidthA
+
+$(srcdir)/ambiguous.t: $(srcdir)/WIDTH-A $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt
+ cd $(srcdir); ./uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c > ambiguous.t
+
+$(srcdir)/wide.t: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt $(srcdir)/EastAsianWidth.txt
+ cd $(srcdir); sh ./mkwide
+
diff --git a/newlib/libc/string/Makefile.in b/newlib/libc/string/Makefile.in
index eb8fafc..3758f71 100644
--- a/newlib/libc/string/Makefile.in
+++ b/newlib/libc/string/Makefile.in
@@ -1416,3 +1416,27 @@ docbook: $(DOCBOOK_OUT_FILES)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+
+#############################################################################
+# Unicode data
+
+$(srcdir)/%.txt:
+ cd $(srcdir); test -r $(notdir $@) || ln -s /usr/share/unicode/ucd/$(notdir $@) .
+
+#############################################################################
+# width data for libc/string/wcwidth.c
+
+wcwidth.c: $(srcdir)/ambiguous.t $(srcdir)/combining.t $(srcdir)/wide.t
+
+$(srcdir)/combining.t: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt
+ cd $(srcdir); ./uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B +D7B0-D7C6 +D7CB-D7FB c > combining.t
+
+$(srcdir)/WIDTH-A: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt $(srcdir)/EastAsianWidth.txt
+ cd $(srcdir); sh ./mkwidthA
+
+$(srcdir)/ambiguous.t: $(srcdir)/WIDTH-A $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt
+ cd $(srcdir); ./uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c > ambiguous.t
+
+$(srcdir)/wide.t: $(srcdir)/UnicodeData.txt $(srcdir)/Blocks.txt $(srcdir)/EastAsianWidth.txt
+ cd $(srcdir); sh ./mkwide
+
--
2.16.2
More information about the Newlib
mailing list