[PATCH] implicit Unicode data tables generation

Thomas Wolff towo@towo.net
Fri Mar 9 07:46:00 GMT 2018


Am 08.03.2018 um 23:09 schrieb Thomas Wolff:
> Am 08.03.2018 um 09:07 schrieb Corinna Vinschen:
>> On Mar  8 00:27, Thomas Wolff wrote:
>>> 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;
>> Look at ctype/Makefile.am, last line:
>>
>> $(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
>>
>> This should work for this case here, too.
> Thanks, the following rules actually trigger the dependencies:
> (string)
> $(lpfx)wcwidth.$(oext): wcwidth.c ambiguous.t combining.t wide.t
> (ctype)
> $(lpfx)categories.$(oext): categories.c categories.t
> $(lpfx)towctrans_l.$(oext): towctrans_l.c caseconv.t
>
> but they cause obscure compilation errors:
> In file included from /usr/include/sys/config.h:234:0,
>                  from /usr/include/_ansi.h:11,
>                  from ../../../.././newlib/libc/string/wcwidth.c:91:
> /usr/include/cygwin/config.h:40:29: fatal error: ../tlsoffsets64.h: No 
> such file or directory
>  #include "../tlsoffsets64.h"
>                              ^
> (Maybe it's just one of these volatile errors that occasionally occur 
> when building cygwin?)
> I'll try on another system, or else just provide the patch for Brian 
> (who requested the implicit approach) to work this out...
> Thomas
Replacement patch for further analysis attached.
-------------- 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
+
+$(lpfx)categories.$(oext): categories.c categories.t
+
+$(lpfx)towctrans_l.$(oext): towctrans_l.c 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
+
+$(lpfx)categories.$(oext): categories.c categories.t
+
+$(lpfx)towctrans_l.$(oext): towctrans_l.c 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
+
+$(lpfx)wcwidth.$(oext): wcwidth.c ambiguous.t combining.t 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
+
+$(lpfx)wcwidth.$(oext): wcwidth.c ambiguous.t combining.t 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