|
13 | 13 | codepoint2name[ord('-')] = 'hyphen'; |
14 | 14 |
|
15 | 15 | # add some custom names to map characters that aren't in HTML |
| 16 | +codepoint2name[ord(' ')] = 'space' |
| 17 | +codepoint2name[ord('\'')] = 'squot' |
| 18 | +codepoint2name[ord(',')] = 'comma' |
16 | 19 | codepoint2name[ord('.')] = 'dot' |
17 | 20 | codepoint2name[ord(':')] = 'colon' |
18 | 21 | codepoint2name[ord('/')] = 'slash' |
19 | 22 | codepoint2name[ord('%')] = 'percent' |
20 | 23 | codepoint2name[ord('#')] = 'hash' |
| 24 | +codepoint2name[ord('(')] = 'paren_open' |
| 25 | +codepoint2name[ord(')')] = 'paren_close' |
| 26 | +codepoint2name[ord('[')] = 'bracket_open' |
| 27 | +codepoint2name[ord(']')] = 'bracket_close' |
21 | 28 | codepoint2name[ord('{')] = 'brace_open' |
22 | 29 | codepoint2name[ord('}')] = 'brace_close' |
23 | 30 | codepoint2name[ord('*')] = 'star' |
| 31 | +codepoint2name[ord('!')] = 'bang' |
24 | 32 |
|
25 | 33 | # this must match the equivalent function in qstr.c |
26 | 34 | def compute_hash(qstr): |
@@ -58,7 +66,8 @@ def do_work(infiles): |
58 | 66 | for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): |
59 | 67 | qhash = compute_hash(qstr) |
60 | 68 | qlen = len(qstr) |
61 | | - print('Q(%s, (const byte*)"\\x%02x\\x%02x\\x%02x\\x%02x" "%s")' % (ident, qhash & 0xff, (qhash >> 8) & 0xff, qlen & 0xff, (qlen >> 8) & 0xff, qstr)) |
| 69 | + qdata = qstr.replace('"', '\\"') |
| 70 | + print('Q(%s, (const byte*)"\\x%02x\\x%02x\\x%02x\\x%02x" "%s")' % (ident, qhash & 0xff, (qhash >> 8) & 0xff, qlen & 0xff, (qlen >> 8) & 0xff, qdata)) |
62 | 71 |
|
63 | 72 | return True |
64 | 73 |
|
|
0 commit comments