diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-08 22:34:51 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-08 22:35:19 +0200 |
commit | bf212e80fb0f1d83902de520e9cee098187383f7 (patch) | |
tree | 11687caa11566aa67e03798e20441726fa2c3172 /gen/prop | |
parent | 9e5f709d2b191e42c1c4227260794928331de187 (diff) |
Tweaks to uprop_get_*()
Diffstat (limited to 'gen/prop')
-rwxr-xr-x | gen/prop/gc | 85 | ||||
-rwxr-xr-x | gen/prop/nv | 2 |
2 files changed, 34 insertions, 53 deletions
diff --git a/gen/prop/gc b/gen/prop/gc index 48c6659..219df8a 100755 --- a/gen/prop/gc +++ b/gen/prop/gc @@ -2,56 +2,19 @@ set -e cd "${0%/*}/../.." -exec >include/unicode/__gc.h - -cat <<C -/* This file is autogenerated by gen/prop/gc; DO NOT EDIT. */ - -#ifndef MLIB_UNICODE_PROP___GC_H -#define MLIB_UNICODE_PROP___GC_H - -#include "unicode/prop.h" - -static const enum uprop_gc __mlib_gc_lat1_lt[] = { -C +exec >lib/unicode/prop/uprop_get_gc.c gawk ' BEGIN { FS = ";" -} - -{ - s = "GC_" toupper($3) - lo = strtonum("0X" $1) - - if ($2 ~ /First/) { - getline - hi = strtonum("0X" $1) - } else - hi = lo - - for (i = lo; i <= hi; i++) - props[i] = s -} - -END { - for (i = 0; i <= 0xFF; i++) - print props[i] "," -} -' data/UnicodeData.txt | paste -d' ' - - - - - - - - | sed 's/^/\t/' - -cat <<C -}; - -static const struct { - rune lo, hi; - enum uprop_gc val; -} __mlib_gc_lt[] = { -C -gawk ' -BEGIN { - FS = ";" + print "/* This file is autogenerated by gen/prop/gc; DO NOT EDIT. */" + print "" + print "#include \"__bsearch.h\"" + print "#include \"macros.h\"" + print "#include \"rune.h\"" + print "#include \"unicode/prop.h\"" + print "" } { @@ -69,6 +32,20 @@ BEGIN { } END { + print "static constexpr enum uprop_gc lookup_lat1[] = {" + for (i = 0; i < 0x100; i++) { + if (i % 8 == 0) + printf "\t" + printf "%5s,%s", props[i], i % 8 == 7 ? "\n" : " " + } + print "};" + print "" + print "static const struct {" + print "\trune lo, hi;" + print "\tenum uprop_gc val;" + print "} lookup[] = {" + print "" + for (i = 0x100; i <= 0x10FFFF; i++) { if (!props[i]) continue @@ -77,11 +54,15 @@ END { i++ printf "\t{RUNE_C(0x%06X), RUNE_C(0x%06X), %s},\n", lo, i, props[lo] } -} -' data/UnicodeData.txt | sort -cat <<C -}; - -#endif /* !MLIB_UNICODE_PROP___GC_H */ -C + print "};" + print "" + print "__MLIB_DEFINE_BSEARCH(enum uprop_gc, lookup, GC_CN)" + print "" + print "enum uprop_gc" + print "uprop_get_gc(rune ch)" + print "{" + print "\treturn ch < lengthof(lookup_lat1) ? lookup_lat1[ch] : mlib_lookup(ch);" + print "}" +} +' data/UnicodeData.txt diff --git a/gen/prop/nv b/gen/prop/nv index 7510704..4d81fa9 100755 --- a/gen/prop/nv +++ b/gen/prop/nv @@ -26,7 +26,7 @@ BEGIN { for (i = lo; i <= hi; i++) { gsub(/^; /, "", $3) - if ($3 ~ /\//) + if ($3 ~ /[^.]\//) sub(/\//, "./", $3) props[i] = $3 } |