|
1 #!/bin/bash |
|
2 |
|
3 declare -a names |
|
4 names=( LetterUppercase LetterLowercase LetterTitlecase LetterModifier \ |
|
5 LetterOther MarkNonSpacing MarkSpacingCombining MarkEnclosing \ |
|
6 NumberDecimalDigit NumberLetter NumberOther PunctuationConnector \ |
|
7 PunctuationDash PunctuationOpen PunctuationClose PunctuationInitial \ |
|
8 PunctuationFinal PunctuationOther SymbolMath SymbolCurrency \ |
|
9 SymbolModifier SymbolOther SeparatorSpace SeparatorLine \ |
|
10 SeparatorParagraph OtherControl OtherFormat OtherSurrogate \ |
|
11 OtherPrivateUse OtherNotAssigned ) |
|
12 declare -a codes |
|
13 codes=( Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po Sm Sc Sk So Zs \ |
|
14 Zl Zp Cc Cf Cs Co Cn ) |
|
15 |
|
16 cp Validate.h.pre ../test/Validate.h |
|
17 cp Validate.c.pre ../test/Validate.c |
|
18 |
|
19 # code generation |
|
20 for (( index=0; index < ${#codes[*]}; index=index + 1 )); do |
|
21 echo ${names[$index]} |
|
22 |
|
23 space="`echo ${names[$index]}|sed -e 's/^.\{7,7\}//' -e 's/./ /g'`" |
|
24 |
|
25 sed >../src/NW_Unicode_${names[$index]}.c <NW_Unicode_%NAME%.c.pre \ |
|
26 "s/%NAME%/${names[$index]}/g" |
|
27 sed <UnicodeData.txt 's/^\([^;]*\);[^;]*;\([^;]*\);.*$/\2;\1/' | \ |
|
28 sort | egrep "^${codes[$index]};" | sed 's/.*;//' | tee codes.${codes[$index]}.$$.bak | \ |
|
29 ./genRanges.exe | tee ranges.${codes[$index]}.$$.bak | sort >>../src/NW_Unicode_${names[$index]}.c |
|
30 sed >>../src/NW_Unicode_${names[$index]}.c <NW_Unicode_%NAME%.c.post \ |
|
31 -e "s/%NAME%/${names[$index]}/g" -e "s/%SPACE%/${space}/g" |
|
32 |
|
33 numLines=`wc -l ranges.${codes[$index]}.$$.bak|sed 's/^ *\([0-9]*\).*$/\1/'` |
|
34 if [ "${numLines}" == 0 ]; then |
|
35 sed >../src/NW_Unicode_${names[$index]}.c <NW_Unicode_%EMPTY%.c \ |
|
36 -e "s/%NAME%/${names[$index]}/g" -e "s/%SPACE%/${space}/g" |
|
37 fi |
|
38 |
|
39 sed >../include/NW_Unicode_${names[$index]}.h <NW_Unicode_%NAME%.h \ |
|
40 "s/%NAME%/${names[$index]}/g" |
|
41 sed >../include/NW_Unicode_${names[$index]}I.h <NW_Unicode_%NAME%I.h \ |
|
42 "s/%NAME%/${names[$index]}/g" |
|
43 |
|
44 sed >../test/Validate${names[$index]}.c <Validate%NAME%.c.pre "s/%NAME%/${names[$index]}/g" |
|
45 (for code in `cat codes.${codes[$index]}.$$.bak`; do echo -e " if (!ValidateCode (0x${code}, &NW_Unicode_${names[$index]}_Class)) {\n return NW_FALSE;\n }"; done) >>../test/Validate${names[$index]}.c |
|
46 sed >>../test/Validate${names[$index]}.c <Validate%NAME%.c.post "s/%NAME%/${names[$index]}/g" |
|
47 |
|
48 echo >>../test/Validate.h "#include \"NW_Unicode_${names[$index]}.h\"" |
|
49 echo >>../test/Validate.h "extern NW_Bool Validate${names[$index]} (void);" |
|
50 echo >>../test/Validate.h |
|
51 |
|
52 sleep 1 |
|
53 echo -e >>../test/Validate.c " if (!Validate${names[$index]} ()) {\n return NW_FALSE;\n }" |
|
54 |
|
55 rm ranges.${codes[$index]}.$$.bak codes.${codes[$index]}.$$.bak |
|
56 done |
|
57 |
|
58 cat Validate.h.post >>../test/Validate.h |
|
59 cat Validate.c.post >>../test/Validate.c |