aboutsummaryrefslogtreecommitdiff
path: root/gen/prop/nfkc_scf
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-20 01:44:38 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-20 01:44:38 +0200
commit5758d012c11b2dc73fd86e44cc41774c2239ca9b (patch)
tree5229d3e04e41fde073113adc5792570d96250dc2 /gen/prop/nfkc_scf
parent4086aeb61b73edb580edf16d50e77422f0bbcfa1 (diff)
Add uprop_get_nfkc_scf()
Diffstat (limited to 'gen/prop/nfkc_scf')
-rwxr-xr-xgen/prop/nfkc_scf49
1 files changed, 49 insertions, 0 deletions
diff --git a/gen/prop/nfkc_scf b/gen/prop/nfkc_scf
new file mode 100755
index 0000000..30895c2
--- /dev/null
+++ b/gen/prop/nfkc_scf
@@ -0,0 +1,49 @@
+#!/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