#!/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