Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / ctype / mkcaseconv
bloba455aed16ef633e26dbce3dd8542cbc660ebf520
1 #! /bin/sh -f
3 # generate a table for Unicode case conversion; entries:
4 # struct caseconv_entry defined in towctrans_l.c
6 if [ -r UnicodeData.txt ]
7 then UnicodeData=UnicodeData.txt
8 elif [ -r /usr/share/unicode/ucd/UnicodeData.txt ]
9 then UnicodeData=/usr/share/unicode/ucd/UnicodeData.txt
10 else echo UnicodeData.txt not found >&2
11 exit 1
14 LC_ALL=C
15 export LC_ALL
17 compact=true
19 #0041;LATIN CAPITAL LETTER A;Lu;0;L;;;;;N;;;;0061;
20 #0061;LATIN SMALL LETTER A;Ll;0;L;;;;;N;;;0041;;0041
21 #0130;LATIN CAPITAL LETTER I WITH DOT ABOVE;Lu;0;L;0049 0307;;;;N;LATIN CAPITAL LETTER I DOT;;;0069;
22 #01C4;LATIN CAPITAL LETTER DZ WITH CARON;Lu;0;L;<compat> 0044 017D;;;;N;LATIN CAPITAL LETTER D Z HACEK;;;01C6;01C5
23 #01C5;LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON;Lt;0;L;<compat> 0044 017E;;;;N;LATIN LETTER CAPITAL D SMALL Z HACEK;;01C4;01C6;01C5
24 #01C6;LATIN SMALL LETTER DZ WITH CARON;Ll;0;L;<compat> 0064 017E;;;;N;LATIN SMALL LETTER D Z HACEK;;01C4;;01C5
26 tr -d '\015' < $UnicodeData |
27 sed \
28 -e 's,^\([^;]*\);[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;\([^;][^;]*\);\([^;]*\);\([^;]*\)$,src \1 upper "\2" lower "\3" title "\4",' \
29 -e t \
30 -e 's,^\([^;]*\);[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;\([^;]*\);\([^;][^;]*\);\([^;]*\)$,src \1 upper "\2" lower "\3" title "\4",' \
31 -e t \
32 -e 's,^\([^;]*\);[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;\([^;]*\);\([^;]*\);\([^;][^;]*\)$,src \1 upper "\2" lower "\3" title "\4",' \
33 -e t \
34 -e d |
35 (#src 01C5 upper "01C4" lower "01C6" title "01C5"
36 if $compact
37 then
39 cat <<\/EOS
40 src () {
41 if [ -n "$3" ]
42 then tohi=$(( 0x0$3 - 0x0$1 ))
43 else tohi=0
45 if [ -n "$5" ]
46 then tolo=$(( 0x0$5 - 0x0$1 ))
47 else tolo=0
49 case "$tolo.$tohi" in
50 0.0) true;;
51 0.*)
52 case "$1.$tohi" in
53 *[02468ACE].1) echo "'#error' U+$1 ODDSML";;
54 *[02468ACE].-1) echo " 0x$1 TO1 ODDCAP";;
55 *[13579BDF].1) echo "'#error' U+$1 EVENSML";;
56 *[13579BDF].-1) echo " 0x$1 TO1 EVENCAP";;
57 *) echo " 0x$1 TOUP $tohi";;
58 esac;;
59 *.0)
60 case "$1.$tolo" in
61 *[02468ACE].1) echo " 0x$1 TO1 EVENCAP";;
62 *[02468ACE].-1) echo "'#error' U+$1 EVENSML";;
63 *[13579BDF].1) echo " 0x$1 TO1 ODDCAP";;
64 *[13579BDF].-1) echo "'#error' U+$1 ODDSML";;
65 *) echo " 0x$1 TOLO $tolo";;
66 esac;;
67 *) case "$tolo.$tohi" in
68 1.-1) echo " 0x$1 TOBOTH 0";;
69 *) echo "'#error' U+$1";;
70 esac;;
71 esac
73 /EOS
74 cat
75 ) | sh |
76 uniq -f1 --group=append | sed -e "s,^$,range," -e t -e "s,^,item ," |
78 cat <<\/EOS
79 first=
80 diff=-1
81 max=255
82 range () {
83 # $diff == $(($last - $first))
84 if [ "$diff" -ge 0 ]
85 then # we have items at all
86 echo " {$first, $diff, $v2, $v3},"
88 first=
89 diff=-1
91 item () {
92 if [ "$1" = "#error" ]
93 then echo "$*"
94 return
97 if [ $diff -eq $max ]
98 then range
99 elif [ -n "$first" ]
100 then if [ $(( $1 )) -ne $(( ${last-0} + 1 )) ]
101 then range
105 if [ -z "$first" ]
106 then first=$1
107 v2=$2
108 v3=$3
111 last=$1
112 diff=$(( $diff + 1 ))
114 /EOS
116 ) | sh
117 elif false
118 then
119 sed -e 's/src \([^ ]*\) upper "\([^ ]*\)" lower "\([^ ]*\)" title "\([^ ]*\)"/ {0x\1, 0x\2 - 0x\1, 0x\3 - 0x\1},/' \
120 -e 's/0x - 0x[^ ,}]*/0/g' -e 's/0x}/0}/' \
121 -e 's/\(0x[0-9A-F][0-9A-F]*\) - \(0x[0-9A-F][0-9A-F]*\)/$((`printf %d \1` - `printf %d \2`))/g' \
122 -e 's/^/echo "/' -e 's/$/"/' |
124 else
125 sed -e 's/src \([^ ]*\) upper "\([^ ]*\)" lower "\([^ ]*\)" title "\([^ ]*\)"/ {0x\1, 0x\2 - 0x\1, 0x\3 - 0x\1},/' \
126 -e 's/0x - 0x[^ ,}]*/0/g' -e 's/0x}/0}/'
128 ) > caseconv.t