Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
f88eec0d
Commit
f88eec0d
authored
Apr 02, 2015
by
Paul Sokolovsky
Browse files
makeqstrdata.py: Add support for strings with backslash escapes.
parent
2686f9b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/makeqstrdata.py
View file @
f88eec0d
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment