diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-04-02 01:09:24 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-04-02 01:10:11 +0300 |
commit | f88eec0de24277e8713ebdfe34e1e7b852a25731 (patch) | |
tree | c7e5bfbca9356838b717a282e8a993e588014973 /py/makeqstrdata.py | |
parent | 2686f9b3e8ada0f32a095ab552b0b64602a1225c (diff) | |
download | micropython-f88eec0de24277e8713ebdfe34e1e7b852a25731.tar.gz micropython-f88eec0de24277e8713ebdfe34e1e7b852a25731.zip |
makeqstrdata.py: Add support for strings with backslash escapes.
Diffstat (limited to 'py/makeqstrdata.py')
-rw-r--r-- | py/makeqstrdata.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 3c0fa512ef..3abf638e2b 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -29,6 +29,7 @@ codepoint2name[ord('{')] = 'brace_open' codepoint2name[ord('}')] = 'brace_close' codepoint2name[ord('*')] = 'star' codepoint2name[ord('!')] = 'bang' +codepoint2name[ord('\\')] = 'backslash' # this must match the equivalent function in qstr.c def compute_hash(qstr): @@ -87,7 +88,8 @@ def do_work(infiles): # go through each qstr and print it out for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): qhash = compute_hash(qstr) - qlen = len(qstr) + # Calculate len of str, taking escapes into account + qlen = len(qstr.replace("\\\\", "-").replace("\\", "")) qdata = qstr.replace('"', '\\"') if qlen >= cfg_max_len: print('qstr is too long:', qstr) |