@@ -88,9 +88,9 @@ def main():
8888 sys .exit (bad )
8989
9090# Change this regular expression to select a different set of files
91- Wanted = '^[a-zA-Z0-9_]+\.[ch]$'
91+ Wanted = r '^[a-zA-Z0-9_]+\.[ch]$'
9292def wanted (name ):
93- return re .match (Wanted , name ) >= 0
93+ return re .match (Wanted , name )
9494
9595def recursedown (dirname ):
9696 dbg ('recursedown(%r)\n ' % (dirname ,))
@@ -168,6 +168,7 @@ def fix(filename):
168168 if filename == '-' : return 0 # Done in filter mode
169169 f .close ()
170170 if not g : return 0 # No changes
171+ g .close ()
171172
172173 # Finishing touch -- move files
173174
@@ -193,21 +194,21 @@ def fix(filename):
193194
194195# Tokenizing ANSI C (partly)
195196
196- Identifier = '\ (struct \ )?[a-zA-Z_][a-zA-Z0-9_]+'
197- String = '"\ ([^\n \\ "]\ |\\ \\ .\ )*"'
198- Char = ' \' \ ([^\n \\ \' ]\ |\\ \\ .\)* \' '
199- CommentStart = '/\*'
200- CommentEnd = '\*/'
197+ Identifier = '(struct )?[a-zA-Z_][a-zA-Z0-9_]+'
198+ String = r'" ([^\n\\"]|\\. )*"'
199+ Char = r"' ([^\n\\'] |\\.)*'"
200+ CommentStart = r '/\*'
201+ CommentEnd = r '\*/'
201202
202203Hexnumber = '0[xX][0-9a-fA-F]*[uUlL]*'
203204Octnumber = '0[0-7]*[uUlL]*'
204205Decnumber = '[1-9][0-9]*[uUlL]*'
205- Intnumber = Hexnumber + '\ |' + Octnumber + '\ |' + Decnumber
206+ Intnumber = Hexnumber + '|' + Octnumber + '|' + Decnumber
206207Exponent = '[eE][-+]?[0-9]+'
207- Pointfloat = '\ ([0-9]+\.[0-9]*\ |\.[0-9]+\)\ (' + Exponent + '\ )?'
208+ Pointfloat = r' ([0-9]+\.[0-9]*|\.[0-9]+) (' + Exponent + r' )?'
208209Expfloat = '[0-9]+' + Exponent
209- Floatnumber = Pointfloat + '\ |' + Expfloat
210- Number = Floatnumber + '\ |' + Intnumber
210+ Floatnumber = Pointfloat + '|' + Expfloat
211+ Number = Floatnumber + '|' + Intnumber
211212
212213# Anything else is an operator -- don't list this explicitly because of '/*'
213214
@@ -225,15 +226,16 @@ def initfixline():
225226
226227def fixline (line ):
227228 global Program
228- ## print '-->', repr(line)
229+ ## print( '-->', repr(line) )
229230 i = 0
230231 while i < len (line ):
231- i = Program .search (line , i )
232- if i < 0 : break
233- found = Program .group (0 )
234- ## if Program is InsideCommentProgram: print '...',
235- ## else: print ' ',
236- ## print found
232+ match = Program .search (line , i )
233+ if match is None : break
234+ i = match .start ()
235+ found = match .group (0 )
236+ ## if Program is InsideCommentProgram: print(end='... ')
237+ ## else: print(end=' ')
238+ ## print(found)
237239 if len (found ) == 2 :
238240 if found == '/*' :
239241 Program = InsideCommentProgram
@@ -247,15 +249,15 @@ def fixline(line):
247249 print ('Found in comment:' , found )
248250 i = i + n
249251 continue
250- if NotInComment . has_key ( found ) :
251- ## print 'Ignored in comment:',
252- ## print found, '-->', subst
253- ## print 'Line:', line,
252+ if found in NotInComment :
253+ ## print(end= 'Ignored in comment: ')
254+ ## print( found, '-->', subst)
255+ ## print( 'Line:', line, end='')
254256 subst = found
255257## else:
256- ## print 'Substituting in comment:',
257- ## print found, '-->', subst
258- ## print 'Line:', line,
258+ ## print(end= 'Substituting in comment: ')
259+ ## print( found, '-->', subst)
260+ ## print( 'Line:', line, end='')
259261 line = line [:i ] + subst + line [i + n :]
260262 n = len (subst )
261263 i = i + n
0 commit comments