diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-11 18:27:41 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-11 18:27:41 +0200 |
commit | fcebbdb6a88c544a4c1e41039ce1ffb662e22cfa (patch) | |
tree | d61416f20ae52232ba3e088398567837fcb1861a /gen/prop/na1 | |
parent | 28bdc257232da80ae68b52d7f3b8fbfb7f023ca2 (diff) |
Add uprop_get_na1()
Diffstat (limited to 'gen/prop/na1')
-rwxr-xr-x | gen/prop/na1 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gen/prop/na1 b/gen/prop/na1 new file mode 100755 index 0000000..7ed1a0a --- /dev/null +++ b/gen/prop/na1 @@ -0,0 +1,44 @@ +#!/bin/sh + +set -e +cd "${0%/*}/../.." +exec >lib/unicode/prop/uprop_get_na1.c + +gawk ' +BEGIN { + FS = ";" + + print "/* This file is autogenerated by gen/prop/na1; DO NOT EDIT. */" + print "" + print "#include \"__bsearch.h\"" + 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 {" + print "\trune k;" + print "\tstruct u8view v;" + print "} lookup[] = {" +} + +length($11) > 0 { + gsub(/./, "\x27&\x27, ", $11) + sub(/, $/, "", $11) + printf "\t{RUNE_C(0x%06X), _(%s)},\n", strtonum("0X" $1), $11 +} + +END { + print "};" + print "" + print "__MLIB_DEFINE_BSEARCH_KV(struct u8view, lookup, (struct u8view){})" + print "" + print "struct u8view" + print "uprop_get_na1(rune ch)" + print "{" + print "\treturn mlib_lookup_kv(ch);" + print "}" +} +' data/UnicodeData.txt |