aboutsummaryrefslogtreecommitdiff
path: root/gen/prop
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-11 18:00:57 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-11 18:00:57 +0200
commit0b18a690933f15c624dc0a2ecac419d963e90b29 (patch)
treec7f22f6e927b04d5c07a93e92c89071e289631c0 /gen/prop
parentd9dda44ced75c07b4e5b2897b74ca97ac7205ca7 (diff)
Add uprop_get_na()
Diffstat (limited to 'gen/prop')
-rwxr-xr-xgen/prop/na38
1 files changed, 38 insertions, 0 deletions
diff --git a/gen/prop/na b/gen/prop/na
new file mode 100755
index 0000000..5aa24e3
--- /dev/null
+++ b/gen/prop/na
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+set -e
+cd "${0%/*}/../.."
+exec >lib/unicode/prop/uprop_get_na.c
+
+gawk '
+BEGIN {
+ FS = ";"
+
+ print "/* This file is autogenerated by gen/prop/nv; DO NOT EDIT. */"
+ print ""
+ print "#include \"macros.h\""
+ print "#include \"rune.h\""
+ print "#include \"unicode/prop.h\""
+ print ""
+ print "#define _(...) \\"
+ print "\t{(const char8_t []){__VA_ARGS__}, sizeof((const char8_t []){__VA_ARGS__})}"
+ print ""
+ print "static const struct u8view lookup[] = {"
+}
+
+$2 !~ /^</ {
+ gsub(/./, "\x27&\x27, ", $2)
+ sub(/, $/, "", $2)
+ printf "\t[RUNE_C(0x%06X)] = _(%s),\n", strtonum("0X" $1), $2
+}
+
+END {
+ print "};"
+ print ""
+ print "struct u8view"
+ print "uprop_get_na(rune ch)"
+ print "{"
+ print "\treturn ch < lengthof(lookup) ? lookup[ch] : (struct u8view){};"
+ print "}"
+}
+' data/UnicodeData.txt