2 """getctype.py - Generate the svn_ctype character classification table.
7 # Table of ASCII character names
8 names
= ('nul', 'soh', 'stx', 'etx', 'eot', 'enq', 'ack', 'bel',
9 'bs', 'ht', 'nl', 'vt', 'np', 'cr', 'so', 'si',
10 'dle', 'dc1', 'dc2', 'dc3', 'dc4', 'nak', 'syn', 'etb',
11 'can', 'em', 'sub', 'esc', 'fs', 'gs', 'rs', 'us',
12 'sp', '!', '"', '#', '$', '%', '&', '\'',
13 '(', ')', '*', '+', ',', '-', '.', '/',
14 '0', '1', '2', '3', '4', '5', '6', '7',
15 '8', '9', ':', ';', '<', '=', '>', '?',
16 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
17 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
18 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
19 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
20 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
21 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
22 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
23 'x', 'y', 'z', '{', '|', '}', '~', 'del')
25 # All whitespace characters:
26 # horizontal tab, vertical tab, new line, form feed, carriage return, space
27 whitespace
= (9, 10, 11, 12, 13, 32)
29 # Bytes not valid in UTF-8 sequences
30 utf8_invalid
= (0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF)
32 print ' /* **** DO NOT EDIT! ****'
33 print ' This table was generated by genctype.py, make changes there. */'
40 bits
.append('SVN_CTYPE_ASCII')
42 if len(names
[c
]) == 1:
43 name
= string
.center(names
[c
], 3)
45 name
= string
.ljust(names
[c
], 3)
48 if c
< 32 or c
== 127:
49 bits
.append('SVN_CTYPE_CNTRL')
51 # Whitespace characters
53 bits
.append('SVN_CTYPE_SPACE')
56 if c
>= 33 and c
< 48 \
57 or c
>= 58 and c
< 65 \
58 or c
>= 91 and c
< 97 \
59 or c
>= 123 and c
< 127:
60 bits
.append('SVN_CTYPE_PUNCT')
63 elif c
>= 48 and c
< 58:
64 bits
.append('SVN_CTYPE_DIGIT')
67 elif c
>= 65 and c
< 91:
68 bits
.append('SVN_CTYPE_UPPER')
71 bits
.append('SVN_CTYPE_XALPHA')
74 elif c
>= 97 and c
< 123:
75 bits
.append('SVN_CTYPE_LOWER')
78 bits
.append('SVN_CTYPE_XALPHA')
80 # UTF-8 multibyte sequences
84 # Lead bytes (start of sequence)
85 if c
> 0xC0 and c
< 0xFE and c
not in utf8_invalid
:
86 bits
.append('SVN_CTYPE_UTF8LEAD')
89 elif (c
& 0xC0) == 0x80:
90 bits
.append('SVN_CTYPE_UTF8CONT')
95 flags
= string
.join(bits
, ' | ')
96 print ' /* %s */ %s,' % (name
, flags
)