From ce0457c030aa7446f9e94ccbcc51873ff36b6fdb Mon Sep 17 00:00:00 2001 From: Mohamed Fawzi Date: Wed, 30 Jan 2008 15:02:30 +0000 Subject: [PATCH] fixed extra | in regexp to split, follows includes svn-origin-rev: 6910 --- tools/normalizeFortranFile.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/normalizeFortranFile.py b/tools/normalizeFortranFile.py index bf62d670ce..1ce762acbe 100755 --- a/tools/normalizeFortranFile.py +++ b/tools/normalizeFortranFile.py @@ -183,12 +183,28 @@ def parseRoutine(inFile): routine['preDeclComments'].append("".join(lines)) elif comments: routine['declComments'].append(comments) + includeRe=re.compile(r"#? *include +[\"'](?P.+)[\"'] *$",re.IGNORECASE) while len(lines)>0: if endRe.match(jline): routine['end']=lines break routine['strippedCore'].append(jline) routine['core'].append("".join(lines)) + m=includeRe.match(lines[0]) + if m: + try: + subF=file(m.group('file')) + while 1: + (subjline,subcomments,sublines)=readFortranLine(inFile) + if not sublines: + break + routine['strippedCore'].append(subjline) + subF.close() + except: + import traceback + print "error trying to follow include ",m.group('file') + print "warning this might lead to the removal of used variables" + traceback.print_exc() (jline,comments,lines)=readFortranLine(inFile) return routine @@ -303,7 +319,7 @@ def writeInCols(dLine,indentCol,maxCol,indentAtt,file): The '&' of the continuation line is at maxCol. indentAtt is the actual intent, and the new indent is returned""" strRe=re.compile(r"('[^'\n]*'|\"[^\"\n]*\")") - nonWordRe=re.compile(r"(|\(/|/\)|[^-+a-zA-Z0-9_.])") + nonWordRe=re.compile(r"(\(/|/\)|[^-+a-zA-Z0-9_.])") maxSize=maxCol-indentCol-1 tol=min(maxSize/6,6)+indentCol for fragment in dLine: @@ -818,7 +834,7 @@ def rewriteFortranFile(inFile,outFile,logFile=sys.stdout,orig_filename=None): """rewrites the use statements and declarations of inFile to outFile. It sorts them and removes the repetitions.""" import os.path - moduleRe=re.compile(r" *module (?P[a-zA-Z_][a-zA-Z_0-9]*) *(?:!.*)?$", + moduleRe=re.compile(r" *(?:module|program) (?P[a-zA-Z_][a-zA-Z_0-9]*) *(?:!.*)?$", flags=re.IGNORECASE) commonUsesIncludeFilepath=os.path.join( os.path.split(os.path.abspath(inFile.name))[0],"cp_common_uses.h")