blob: 759a07d5e6fedec08006a38befb16c359b15c1db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#!/bin/sh
cache()
{
name="/tmp/librune/rtype/$(basename "$1")"
if test ! -f "$name"
then
mkdir -p /tmp/librune/rtype
wget -q "$1" -O "$name"
fi
}
cd "${0%/*}/.."
readonly URL1='https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt'
readonly URL2='https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt'
readonly URL3='https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt'
readonly URL4='https://www.unicode.org/Public/UCD/latest/ucd/DerivedNormalizationProps.txt'
readonly URL5='https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedBinaryProperties.txt'
cache "$URL1" &
cache "$URL2" &
cache "$URL3" &
cache "$URL4" &
cache "$URL5" &
wait
props1='
bidi_c=Bidi_Control
dash=Dash
dep=Deprecated
dia=Diacritic
ext=Extender
hex=Hex_Digit
idbo=IDS_Binary_Operator
id_compat_math_continue=ID_Compat_Math_Continue
id_compat_math_start=ID_Compat_Math_Start
ideo=Ideographic
loe=Logical_Order_Exception
pat_syn=Pattern_Syntax
pcm=Prepended_Concatenation_Mark
qmark=Quotation_Mark
radical=Radical
sd=Soft_Dotted
sterm=Sentence_Terminal
term=Terminal_Punctuation
uideo=Unified_Ideograph
vs=Variation_Selector
wspace=White_Space
'
props2='
alpha=Alphabetic
cased=Cased
ci=Case_Ignorable
cwcf=Changes_When_Casefolded
cwcm=Changes_When_Casemapped
cwl=Changes_When_Lowercased
cwt=Changes_When_Titlecased
cwu=Changes_When_Uppercased
di=Default_Ignorable_Code_Point
gr_base=Grapheme_Base
gr_ext=Grapheme_Extend
idc=ID_Continue
ids=ID_Start
incb=Indic_Conjunct_Break
lower=Lowercase
math=Math
upper=Uppercase
xidc=XID_Continue
xids=XID_Start
'
props3='
ebase=Emoji_Modifier_Base
ecomp=Emoji_Component
emod=Emoji_Modifier
emoji=Emoji
epres=Emoji_Presentation
extpic=Extended_Pictographic
'
props4='
cwkcf=Changes_When_NFKC_Casefolded
'
props5='
bidi_m=Bidi_Mirrored
'
manual='
ahex=ASCII_Hex_Digit
idst=IDS_Trinary_Operator
idsu=IDS_Unary_Operator
join_c=Join_Control
nchar=Noncharacter_Code_Point
pat_ws=Pattern_White_Space
ri=Regional_Indicator
'
gen()
{
local p=${1%%=*}
gawk -M -v prop=${1#*=} -v word=$2 -v short=$p \
-f gen/rtype-prop.awk /tmp/librune/rtype/$3 \
>lib/rtype/rprop_${2}_${p}.c
printf 'DONE rprop_%s_%s()\n' $2 $p >&2
}
for prop in $props1
do
gen $prop is PropList.txt &
done
for prop in $props2
do
gen $prop is DerivedCoreProperties.txt &
done
for prop in $props3
do
gen $prop is emoji-data.txt &
done
for prop in $props4
do
gen $prop is DerivedNormalizationProps.txt &
done
for prop in $props5
do
gen $prop is DerivedBinaryProperties.txt &
done
printf '[[unsequenced]] bool rprop_is_%s(rune);\n' \
$(printf '%s\n' $props1 $props2 $props3 $props4 $props5 | cut -d= -f1) \
| gawk '
/PROP PREDICATES END/ { no = 0 }
FILENAME != "-" && !no { print }
FILENAME == "-" { funcs[++i] = $0 }
/PROP PREDICATES START/ {
no = 1
asort(funcs)
for (i = 1; i <= length(funcs); i++)
print funcs[i]
}
' - include/rtype.h | sponge include/rtype.h
wait
for prop in $manual
do
shrt=${prop%%=*}
printf 'Function rprop_is_%s() implemented manually\n' $shrt >&2
done
|