Skip to content

Commit f88eec0

Browse files
committed
makeqstrdata.py: Add support for strings with backslash escapes.
1 parent 2686f9b commit f88eec0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

py/makeqstrdata.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
codepoint2name[ord('}')] = 'brace_close'
3030
codepoint2name[ord('*')] = 'star'
3131
codepoint2name[ord('!')] = 'bang'
32+
codepoint2name[ord('\\')] = 'backslash'
3233

3334
# this must match the equivalent function in qstr.c
3435
def compute_hash(qstr):
@@ -87,7 +88,8 @@ def do_work(infiles):
8788
# go through each qstr and print it out
8889
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
8990
qhash = compute_hash(qstr)
90-
qlen = len(qstr)
91+
# Calculate len of str, taking escapes into account
92+
qlen = len(qstr.replace("\\\\", "-").replace("\\", ""))
9193
qdata = qstr.replace('"', '\\"')
9294
if qlen >= cfg_max_len:
9395
print('qstr is too long:', qstr)

0 commit comments

Comments
 (0)