2323codepoint2name [ord (',' )] = 'comma'
2424codepoint2name [ord ('.' )] = 'dot'
2525codepoint2name [ord (':' )] = 'colon'
26+ codepoint2name [ord (';' )] = 'semicolon'
2627codepoint2name [ord ('/' )] = 'slash'
2728codepoint2name [ord ('%' )] = 'percent'
2829codepoint2name [ord ('#' )] = 'hash'
3637codepoint2name [ord ('!' )] = 'bang'
3738codepoint2name [ord ('\\ ' )] = 'backslash'
3839codepoint2name [ord ('+' )] = 'plus'
40+ codepoint2name [ord ('$' )] = 'dollar'
41+ codepoint2name [ord ('=' )] = 'equals'
42+ codepoint2name [ord ('?' )] = 'question'
43+ codepoint2name [ord ('@' )] = 'at_sign'
44+ codepoint2name [ord ('^' )] = 'caret'
45+ codepoint2name [ord ('|' )] = 'pipe'
46+ codepoint2name [ord ('~' )] = 'tilde'
3947
4048# this must match the equivalent function in qstr.c
4149def compute_hash (qstr , bytes_hash ):
@@ -46,7 +54,14 @@ def compute_hash(qstr, bytes_hash):
4654 return (hash & ((1 << (8 * bytes_hash )) - 1 )) or 1
4755
4856def qstr_escape (qst ):
49- return re .sub (r'[^A-Za-z0-9_]' , lambda s : "_" + codepoint2name [ord (s .group (0 ))] + '_' , qst )
57+ def esc_char (m ):
58+ c = ord (m .group (0 ))
59+ try :
60+ name = codepoint2name [c ]
61+ except KeyError :
62+ name = '0x%02x' % c
63+ return "_" + name + '_'
64+ return re .sub (r'[^A-Za-z0-9_]' , esc_char , qst )
5065
5166def parse_input_headers (infiles ):
5267 # read the qstrs in from the input files
0 commit comments