Skip to content

Commit 56e1f99

Browse files
committed
py/makeqstrdata.py: Add more allowed qstr characters; escape quot.
1 parent 01418e9 commit 56e1f99

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

py/makeqstrdata.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@
1313
codepoint2name[ord('-')] = 'hyphen';
1414

1515
# add some custom names to map characters that aren't in HTML
16+
codepoint2name[ord(' ')] = 'space'
17+
codepoint2name[ord('\'')] = 'squot'
18+
codepoint2name[ord(',')] = 'comma'
1619
codepoint2name[ord('.')] = 'dot'
1720
codepoint2name[ord(':')] = 'colon'
1821
codepoint2name[ord('/')] = 'slash'
1922
codepoint2name[ord('%')] = 'percent'
2023
codepoint2name[ord('#')] = 'hash'
24+
codepoint2name[ord('(')] = 'paren_open'
25+
codepoint2name[ord(')')] = 'paren_close'
26+
codepoint2name[ord('[')] = 'bracket_open'
27+
codepoint2name[ord(']')] = 'bracket_close'
2128
codepoint2name[ord('{')] = 'brace_open'
2229
codepoint2name[ord('}')] = 'brace_close'
2330
codepoint2name[ord('*')] = 'star'
31+
codepoint2name[ord('!')] = 'bang'
2432

2533
# this must match the equivalent function in qstr.c
2634
def compute_hash(qstr):
@@ -58,7 +66,8 @@ def do_work(infiles):
5866
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
5967
qhash = compute_hash(qstr)
6068
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))
6271

6372
return True
6473

0 commit comments

Comments
 (0)