@@ -29,43 +29,15 @@ def compute_hash(qstr):
29
29
hash = (hash * 33 ) ^ ord (char )
30
30
return hash & 0xffff
31
31
32
- # given a list of (name,regex) pairs, find the first one that matches the given line
33
- def re_match_first (regexs , line ):
34
- for name , regex in regexs :
35
- match = re .match (regex , line )
36
- if match :
37
- return name , match
38
- return None , None
39
-
40
- # regexs to recognise lines that the CPP emits
41
- # use a list so that matching order is honoured
42
- cpp_regexs = [
43
- ('qstr' , r'Q\((.+)\)$' ),
44
- ('cdecl' , r'(typedef|extern) [A-Za-z0-9_* ]+;$' )
45
- ]
46
-
47
32
def do_work (infiles ):
48
33
# read the qstrs in from the input files
49
34
qstrs = {}
50
35
for infile in infiles :
51
36
with open (infile , 'rt' ) as f :
52
- line_number = 0
53
37
for line in f :
54
- line_number += 1
55
- line = line .strip ()
56
-
57
- # ignore blank lines, comments and preprocessor directives
58
- if len (line ) == 0 or line .startswith ('//' ) or line .startswith ('#' ):
59
- continue
60
-
61
- # work out what kind of line it is
62
- match_kind , match = re_match_first (cpp_regexs , line )
63
- if match_kind is None :
64
- # unknown line format
65
- print ('({}:{}) bad qstr format, got {}' .format (infile , line_number , line ), file = sys .stderr )
66
- return False
67
- elif match_kind != 'qstr' :
68
- # not a line with a qstr
38
+ # is this a QSTR line?
39
+ match = re .match (r'^Q\((.+)\)$' , line .strip ())
40
+ if not match :
69
41
continue
70
42
71
43
# get the qstr value
0 commit comments