aboutsummaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-21 11:44:29 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-21 11:44:29 +0200
commitfa5e50f0cf7d42a61fbe513eae28cba97a01f18c (patch)
tree9ad971c92368105d1491a2ce347a4a40ad1c0002 /gen
parent5758d012c11b2dc73fd86e44cc41774c2239ca9b (diff)
Add uprop_get_nfkc_cf()
Diffstat (limited to 'gen')
-rwxr-xr-xgen/prop/nfkc_Xcf65
-rwxr-xr-xgen/prop/nfkc_scf49
2 files changed, 65 insertions, 49 deletions
diff --git a/gen/prop/nfkc_Xcf b/gen/prop/nfkc_Xcf
new file mode 100755
index 0000000..ba5a905
--- /dev/null
+++ b/gen/prop/nfkc_Xcf
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+set -e
+cd "${0%/*}/../.."
+
+for x in cf scf
+do
+ gawk -v s=$x '
+ BEGIN {
+ FS = "( *; *| *#.*)"
+
+ print "/* This file is autogenerated by gen/prop/nfkc_Xcf; DO NOT EDIT. */"
+ print ""
+ print "#include \"_bsearch.h\""
+ print "#include \"macros.h\""
+ print "#include \"rune.h\""
+ print "#include \"unicode/prop.h\""
+ print ""
+ print "#define M(...) ((struct rview)_(__VA_ARGS__))"
+ print "#define _(...) \\"
+ print "\t{(const rune []){__VA_ARGS__}, lengthof(((const rune []){__VA_ARGS__}))}"
+ print ""
+ print "static const struct {"
+ print "\trune lo, hi;"
+ print "\tstruct rview val;"
+ print "} lookup[] = {"
+ }
+
+ $2 == "NFKC_" toupper(s) {
+ n = split($1, xs, /\.\./)
+ lo = strtonum("0X" xs[1])
+ hi = strtonum("0X" xs[n])
+
+ for (i = lo; i <= hi; i++)
+ props[i] = $3 ? $3 : "-"
+ }
+
+ END {
+ for (i = 0; i <= 0x10FFFD; i++) {
+ if (!props[i])
+ continue
+ for (lo = i; props[lo] == props[i + 1]; i++)
+ ;
+ printf "\t{RUNE_C(0x%06X), RUNE_C(0x%06X), _(", lo, i
+ n = split(props[i] == "-" ? "" : props[i], xs, / /)
+ for (j = 1; j <= n; j++) {
+ printf "RUNE_C(0x%s)", xs[j]
+ if (j < n)
+ printf ", "
+ }
+ print ")},"
+ }
+
+ print "};"
+ print ""
+ print "_MLIB_DEFINE_BSEARCH(struct rview, lookup, M(ch))"
+ print ""
+ print "struct rview"
+ print "uprop_get_nfkc_" s "(rune ch)"
+ print "{"
+ print "\treturn ch < lookup[0].lo ? M(ch) : mlib_lookup(ch);"
+ print "}"
+ }
+ ' data/DerivedNormalizationProps >lib/unicode/prop/uprop_get_nfkc_${x}.c
+done
diff --git a/gen/prop/nfkc_scf b/gen/prop/nfkc_scf
deleted file mode 100755
index 30895c2..0000000
--- a/gen/prop/nfkc_scf
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh
-
-set -e
-cd "${0%/*}/../.."
-exec >lib/unicode/prop/uprop_get_nfkc_scf.c
-
-gawk '
-BEGIN {
- FS = "( *; *| *#.*)"
-
- print "#include \"_bsearch.h\""
- print "#include \"macros.h\""
- print "#include \"rune.h\""
- print "#include \"unicode/prop.h\""
- print ""
- print "#define M(...) ((struct rview)_(__VA_ARGS__))"
- print "#define _(...) \\"
- print "\t{(const rune []){__VA_ARGS__}, lengthof(((const rune []){__VA_ARGS__}))}"
- print ""
- print "static const struct {"
- print "\trune lo, hi;"
- print "\tstruct rview val;"
- print "} lookup[] = {"
-}
-
-$2 == "NFKC_SCF" {
- n = split($1, xs, /\.\./)
- printf "\t{RUNE_C(0x%s), RUNE_C(0x%s), _(", xs[1], xs[n]
- n = split($3, xs, / /)
- for (i = 1; i <= n; i++) {
- printf "RUNE_C(0x%s)", xs[i]
- if (i < n)
- printf ", "
- }
- print ")},"
-}
-
-END {
- print "};"
- print ""
- print "_MLIB_DEFINE_BSEARCH(struct rview, lookup, M(ch))"
- print ""
- print "struct rview"
- print "uprop_get_nfkc_scf(rune ch)"
- print "{"
- print "\treturn ch < lookup[0].lo ? M(ch) : mlib_lookup(ch);"
- print "}"
-}
-' data/DerivedNormalizationProps