aboutsummaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
Diffstat (limited to 'gen')
-rwxr-xr-xgen/prop/gc87
1 files changed, 87 insertions, 0 deletions
diff --git a/gen/prop/gc b/gen/prop/gc
new file mode 100755
index 0000000..48c6659
--- /dev/null
+++ b/gen/prop/gc
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+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
+
+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 = ";"
+}
+
+{
+ 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 = 0x100; i <= 0x10FFFF; i++) {
+ if (!props[i])
+ continue
+ lo = i
+ while (props[lo] == props[i + 1])
+ 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