Ran autopep8.
This commit is contained in:
parent
7ef02a7469
commit
07b43c6929
|
@ -578,10 +578,11 @@ class CppCheckFormatter(argparse.HelpFormatter):
|
||||||
'''
|
'''
|
||||||
Properly formats multiline argument helps
|
Properly formats multiline argument helps
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def _split_lines(self, text, width):
|
def _split_lines(self, text, width):
|
||||||
# this is the RawTextHelpFormatter._split_lines
|
# this is the RawTextHelpFormatter._split_lines
|
||||||
if text.startswith('R|'):
|
if text.startswith('R|'):
|
||||||
return text[2:].splitlines()
|
return text[2:].splitlines()
|
||||||
return argparse.HelpFormatter._split_lines(self, text, width)
|
return argparse.HelpFormatter._split_lines(self, text, width)
|
||||||
|
|
||||||
def ArgumentParser():
|
def ArgumentParser():
|
||||||
|
@ -591,20 +592,20 @@ def ArgumentParser():
|
||||||
'''
|
'''
|
||||||
parser = argparse.ArgumentParser(formatter_class=CppCheckFormatter)
|
parser = argparse.ArgumentParser(formatter_class=CppCheckFormatter)
|
||||||
parser.add_argument('-t', '--template', metavar='<text>',
|
parser.add_argument('-t', '--template', metavar='<text>',
|
||||||
default='{callstack}: ({severity}) {message}',
|
default='{callstack}: ({severity}) {message}',
|
||||||
help="R|Format the error messages. E.g.\n" \
|
help="R|Format the error messages. E.g.\n"
|
||||||
"'{file}:{line},{severity},{id},{message}' or\n" \
|
"'{file}:{line},{severity},{id},{message}' or\n"
|
||||||
"'{file}({line}):({severity}) {message}' or\n" \
|
"'{file}({line}):({severity}) {message}' or\n"
|
||||||
"'{callstack} {message}'\n" \
|
"'{callstack} {message}'\n"
|
||||||
"Pre-defined templates: gcc, vs, edit")
|
"Pre-defined templates: gcc, vs, edit")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
# Format an error message.
|
# Format an error message.
|
||||||
|
|
||||||
def reportError(template, callstack=[], severity='', message='', id=''):
|
def reportError(template, callstack=[], severity='', message='', id=''):
|
||||||
'''
|
'''
|
||||||
Format an error message according to the template.
|
Format an error message according to the template.
|
||||||
|
|
||||||
:param template: format string, or 'gcc', 'vs' or 'edit'.
|
:param template: format string, or 'gcc', 'vs' or 'edit'.
|
||||||
:param callstack: e.g. [['file1.cpp',10],['file2.h','20'], ... ]
|
:param callstack: e.g. [['file1.cpp',10],['file2.h','20'], ... ]
|
||||||
:param severity: e.g. 'error', 'warning' ...
|
:param severity: e.g. 'error', 'warning' ...
|
||||||
|
@ -619,9 +620,9 @@ def reportError(template, callstack=[], severity='', message='', id=''):
|
||||||
elif template == 'edit':
|
elif template == 'edit':
|
||||||
template = '{file} +{line}: {severity}: {message}'
|
template = '{file} +{line}: {severity}: {message}'
|
||||||
# compute 'callstack}, {file} and {line} replacements
|
# compute 'callstack}, {file} and {line} replacements
|
||||||
stack = ' -> '.join(['['+f+':'+str(l)+']' for (f,l) in callstack])
|
stack = ' -> '.join(['[' + f + ':' + str(l) + ']' for (f, l) in callstack])
|
||||||
file = callstack[-1][0]
|
file = callstack[-1][0]
|
||||||
line = str(callstack[-1][1])
|
line = str(callstack[-1][1])
|
||||||
# format message
|
# format message
|
||||||
return template.format(callstack=stack, file=file, line=line,
|
return template.format(callstack=stack, file=file, line=line,
|
||||||
severity=severity, message=message, id=id)
|
severity=severity, message=message, id=id)
|
||||||
|
|
|
@ -198,7 +198,7 @@ def find_dump_files(paths):
|
||||||
for (top, subdirs, files) in os.walk(path):
|
for (top, subdirs, files) in os.walk(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith('.dump'):
|
if file.endswith('.dump'):
|
||||||
f = top+'/'+file
|
f = top + '/' + file
|
||||||
if not f in dumpfiles:
|
if not f in dumpfiles:
|
||||||
dumpfiles.append(f)
|
dumpfiles.append(f)
|
||||||
dumpfiles.sort()
|
dumpfiles.sort()
|
||||||
|
@ -212,9 +212,9 @@ def find_dump_files(paths):
|
||||||
|
|
||||||
parser = cppcheckdata.ArgumentParser()
|
parser = cppcheckdata.ArgumentParser()
|
||||||
parser.add_argument('-q', '--quiet', action='store_true',
|
parser.add_argument('-q', '--quiet', action='store_true',
|
||||||
help='do not print "Checking ..." lines')
|
help='do not print "Checking ..." lines')
|
||||||
parser.add_argument('paths', nargs='+', metavar='path',
|
parser.add_argument('paths', nargs='+', metavar='path',
|
||||||
help='path to dump file or directory')
|
help='path to dump file or directory')
|
||||||
|
|
||||||
# parse command line
|
# parse command line
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ for dumpfile in dumpfiles:
|
||||||
safe = int(srclinenr)
|
safe = int(srclinenr)
|
||||||
# warn about _TIME_BITS not being defined
|
# warn about _TIME_BITS not being defined
|
||||||
if time_bits_defined == False:
|
if time_bits_defined == False:
|
||||||
reportDirDiag(args.template,
|
reportDirDiag(args.template,
|
||||||
cfg, srcfile, srclinenr, directive, 'warning',
|
cfg, srcfile, srclinenr, directive, 'warning',
|
||||||
'_USE_TIME_BITS64 is defined but _TIME_BITS was not')
|
'_USE_TIME_BITS64 is defined but _TIME_BITS was not')
|
||||||
elif re_undef_use_time_bits64.match(directive.str):
|
elif re_undef_use_time_bits64.match(directive.str):
|
||||||
|
|
|
@ -150,7 +150,7 @@ def scanarchive(filepath, jobs):
|
||||||
|
|
||||||
removeLargeFiles('')
|
removeLargeFiles('')
|
||||||
|
|
||||||
print(strfCurrTime('[%H:%M] cppcheck ' ) + filename)
|
print(strfCurrTime('[%H:%M] cppcheck ') + filename)
|
||||||
|
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
['nice',
|
['nice',
|
||||||
|
|
380
tools/reduce.py
380
tools/reduce.py
|
@ -9,224 +9,224 @@ SEGFAULT = False
|
||||||
FILE = None
|
FILE = None
|
||||||
BACKUPFILE = None
|
BACKUPFILE = None
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg.startswith('--cmd='):
|
if arg.startswith('--cmd='):
|
||||||
CMD = arg[arg.find('=')+1:]
|
CMD = arg[arg.find('=') + 1:]
|
||||||
elif arg.startswith('--expected='):
|
elif arg.startswith('--expected='):
|
||||||
EXPECTED = arg[arg.find('=')+1:]
|
EXPECTED = arg[arg.find('=') + 1:]
|
||||||
elif arg.startswith('--file='):
|
elif arg.startswith('--file='):
|
||||||
FILE = arg[arg.find('=')+1:]
|
FILE = arg[arg.find('=') + 1:]
|
||||||
BACKUPFILE = FILE + '.bak'
|
BACKUPFILE = FILE + '.bak'
|
||||||
elif arg == '--segfault':
|
elif arg == '--segfault':
|
||||||
SEGFAULT = True
|
SEGFAULT = True
|
||||||
|
|
||||||
if CMD is None:
|
if CMD is None:
|
||||||
print('Abort: No --cmd')
|
print('Abort: No --cmd')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if SEGFAULT == False and EXPECTED is None:
|
if SEGFAULT == False and EXPECTED is None:
|
||||||
print('Abort: No --expected')
|
print('Abort: No --expected')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if FILE is None:
|
if FILE is None:
|
||||||
print('Abort: No --file')
|
print('Abort: No --file')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print('CMD='+CMD)
|
print('CMD=' + CMD)
|
||||||
if SEGFAULT:
|
if SEGFAULT:
|
||||||
print('EXPECTED=SEGFAULT')
|
print('EXPECTED=SEGFAULT')
|
||||||
else:
|
else:
|
||||||
print('EXPECTED='+EXPECTED)
|
print('EXPECTED=' + EXPECTED)
|
||||||
print('FILE='+FILE)
|
print('FILE=' + FILE)
|
||||||
|
|
||||||
def runtool():
|
def runtool():
|
||||||
p = subprocess.Popen(CMD.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(CMD.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
comm = p.communicate()
|
comm = p.communicate()
|
||||||
if SEGFAULT:
|
if SEGFAULT:
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
return True
|
return True
|
||||||
elif p.returncode == 0:
|
elif p.returncode == 0:
|
||||||
out = comm[0] + '\n' + comm[1]
|
out = comm[0] + '\n' + comm[1]
|
||||||
if (out.find('error:') < 0) and (out.find(EXPECTED) > 0):
|
if (out.find('error:') < 0) and (out.find(EXPECTED) > 0):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def writefile(filename, filedata):
|
def writefile(filename, filedata):
|
||||||
f = open(filename, 'wt')
|
f = open(filename, 'wt')
|
||||||
for line in filedata:
|
for line in filedata:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def replaceandrun(what, filedata, i, line):
|
def replaceandrun(what, filedata, i, line):
|
||||||
print(what + ' ' + str(i+1) + '/' + str(len(filedata)) + '..')
|
print(what + ' ' + str(i + 1) + '/' + str(len(filedata)) + '..')
|
||||||
bak = filedata[i]
|
bak = filedata[i]
|
||||||
filedata[i] = line
|
filedata[i] = line
|
||||||
writefile(FILE, filedata)
|
writefile(FILE, filedata)
|
||||||
if runtool() == True:
|
if runtool() == True:
|
||||||
print('pass')
|
print('pass')
|
||||||
writefile(BACKUPFILE, filedata)
|
writefile(BACKUPFILE, filedata)
|
||||||
return True
|
return True
|
||||||
print('fail')
|
print('fail')
|
||||||
filedata[i] = bak
|
filedata[i] = bak
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def replaceandrun2(what, filedata, i, line1, line2):
|
def replaceandrun2(what, filedata, i, line1, line2):
|
||||||
print(what + ' ' + str(i+1) + '/' + str(len(filedata)) + '..')
|
print(what + ' ' + str(i + 1) + '/' + str(len(filedata)) + '..')
|
||||||
bak1 = filedata[i]
|
bak1 = filedata[i]
|
||||||
bak2 = filedata[i+1]
|
bak2 = filedata[i + 1]
|
||||||
filedata[i] = line1
|
filedata[i] = line1
|
||||||
filedata[i+1] = line2
|
filedata[i + 1] = line2
|
||||||
writefile(FILE, filedata)
|
writefile(FILE, filedata)
|
||||||
if runtool() == True:
|
if runtool() == True:
|
||||||
print('pass')
|
print('pass')
|
||||||
writefile(BACKUPFILE, filedata)
|
writefile(BACKUPFILE, filedata)
|
||||||
else:
|
else:
|
||||||
print('fail')
|
print('fail')
|
||||||
filedata[i] = bak1
|
filedata[i] = bak1
|
||||||
filedata[i+1] = bak2
|
filedata[i + 1] = bak2
|
||||||
|
|
||||||
def clearandrun(what, filedata, i1, i2):
|
def clearandrun(what, filedata, i1, i2):
|
||||||
print(what + ' ' + str(i1+1) + '/' + str(len(filedata)) + '..')
|
print(what + ' ' + str(i1 + 1) + '/' + str(len(filedata)) + '..')
|
||||||
filedata2 = list(filedata)
|
filedata2 = list(filedata)
|
||||||
i = i1
|
i = i1
|
||||||
while i <= i2 and i < len(filedata2):
|
while i <= i2 and i < len(filedata2):
|
||||||
filedata2[i] = ''
|
filedata2[i] = ''
|
||||||
i = i + 1
|
i = i + 1
|
||||||
writefile(FILE, filedata2)
|
writefile(FILE, filedata2)
|
||||||
if runtool() == True:
|
if runtool() == True:
|
||||||
print('pass')
|
print('pass')
|
||||||
writefile(BACKUPFILE, filedata2)
|
writefile(BACKUPFILE, filedata2)
|
||||||
return filedata2
|
return filedata2
|
||||||
print('fail')
|
print('fail')
|
||||||
return filedata
|
return filedata
|
||||||
|
|
||||||
def removecomments(filedata):
|
def removecomments(filedata):
|
||||||
for i in range(len(filedata)):
|
for i in range(len(filedata)):
|
||||||
line = filedata[i]
|
line = filedata[i]
|
||||||
if line.find('//') >= 0:
|
if line.find('//') >= 0:
|
||||||
replaceandrun('remove comment', filedata, i, line[:line.find('//')].rstrip())
|
replaceandrun('remove comment', filedata, i, line[:line.find('//')].rstrip())
|
||||||
|
|
||||||
def checkpar(line):
|
def checkpar(line):
|
||||||
par = 0
|
par = 0
|
||||||
for c in line:
|
for c in line:
|
||||||
if c=='(' or c=='[':
|
if c == '(' or c == '[':
|
||||||
par = par + 1
|
par = par + 1
|
||||||
elif c==')' or c==']':
|
elif c == ')' or c == ']':
|
||||||
par = par - 1
|
par = par - 1
|
||||||
if par<0:
|
if par < 0:
|
||||||
return False
|
return False
|
||||||
return par == 0
|
return par == 0
|
||||||
|
|
||||||
def combinelines(filedata):
|
def combinelines(filedata):
|
||||||
if len(filedata) < 3:
|
if len(filedata) < 3:
|
||||||
return
|
return
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
for i in range(len(filedata)-1):
|
for i in range(len(filedata) - 1):
|
||||||
fd1 = filedata[i].rstrip()
|
fd1 = filedata[i].rstrip()
|
||||||
if fd1.endswith(','):
|
if fd1.endswith(','):
|
||||||
fd2 = filedata[i+1].lstrip()
|
fd2 = filedata[i + 1].lstrip()
|
||||||
if fd2 != '':
|
if fd2 != '':
|
||||||
lines.append(i)
|
lines.append(i)
|
||||||
|
|
||||||
chunksize = len(lines)
|
chunksize = len(lines)
|
||||||
while chunksize > 10:
|
while chunksize > 10:
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(lines):
|
while i < len(lines):
|
||||||
i1 = i
|
i1 = i
|
||||||
i2 = i + chunksize
|
i2 = i + chunksize
|
||||||
i = i2
|
i = i2
|
||||||
if i2 > len(lines):
|
if i2 > len(lines):
|
||||||
i2 = len(lines)
|
i2 = len(lines)
|
||||||
|
|
||||||
filedata2 = list(filedata)
|
filedata2 = list(filedata)
|
||||||
for line in lines[i1:i2]:
|
for line in lines[i1:i2]:
|
||||||
filedata2[line] = filedata2[line].rstrip() + filedata2[line+1].lstrip()
|
filedata2[line] = filedata2[line].rstrip() + filedata2[line + 1].lstrip()
|
||||||
filedata2[line+1] = ''
|
filedata2[line + 1] = ''
|
||||||
|
|
||||||
if replaceandrun('combine lines', filedata2, lines[i1]+1, ''):
|
if replaceandrun('combine lines', filedata2, lines[i1] + 1, ''):
|
||||||
filedata = filedata2
|
filedata = filedata2
|
||||||
lines[i1:i2] = []
|
lines[i1:i2] = []
|
||||||
i = i1
|
i = i1
|
||||||
|
|
||||||
chunksize = chunksize / 2
|
chunksize = chunksize / 2
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
fd1 = filedata[line].rstrip()
|
fd1 = filedata[line].rstrip()
|
||||||
fd2 = filedata[line+1].lstrip()
|
fd2 = filedata[line + 1].lstrip()
|
||||||
replaceandrun2('combine lines', filedata, line, fd1+fd2, '')
|
replaceandrun2('combine lines', filedata, line, fd1 + fd2, '')
|
||||||
|
|
||||||
def removedirectives(filedata):
|
def removedirectives(filedata):
|
||||||
for i in range(len(filedata)):
|
for i in range(len(filedata)):
|
||||||
if filedata[i].lstrip().startswith('#'):
|
if filedata[i].lstrip().startswith('#'):
|
||||||
replaceandrun('remove preprocessor directive', filedata, i, '')
|
replaceandrun('remove preprocessor directive', filedata, i, '')
|
||||||
|
|
||||||
def removeblocks(filedata):
|
def removeblocks(filedata):
|
||||||
if len(filedata) < 3:
|
if len(filedata) < 3:
|
||||||
|
return filedata
|
||||||
|
|
||||||
|
for i in range(len(filedata)):
|
||||||
|
strippedline = filedata[i].strip()
|
||||||
|
if len(strippedline) == 0:
|
||||||
|
continue
|
||||||
|
if ';{}'.find(strippedline[-1]) < 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
i1 = i + 1
|
||||||
|
while i1 < len(filedata) and filedata[i1].startswith('#'):
|
||||||
|
i1 = i1 + 1
|
||||||
|
|
||||||
|
i2 = i1
|
||||||
|
indent = 0
|
||||||
|
while i2 < len(filedata):
|
||||||
|
for c in filedata[i2]:
|
||||||
|
if c == '}':
|
||||||
|
indent = indent - 1
|
||||||
|
if indent == 0:
|
||||||
|
indent = -100
|
||||||
|
elif c == '{':
|
||||||
|
indent = indent + 1
|
||||||
|
if indent < 0:
|
||||||
|
break
|
||||||
|
i2 = i2 + 1
|
||||||
|
if indent == -100:
|
||||||
|
indent = 0
|
||||||
|
if i2 == i1 or i2 >= len(filedata):
|
||||||
|
continue
|
||||||
|
if filedata[i2].strip() != '}' and filedata[i2].strip() != '};':
|
||||||
|
continue
|
||||||
|
if indent < 0:
|
||||||
|
i2 = i2 - 1
|
||||||
|
filedata = clearandrun('remove codeblock', filedata, i1, i2)
|
||||||
|
|
||||||
return filedata
|
return filedata
|
||||||
|
|
||||||
for i in range(len(filedata)):
|
|
||||||
strippedline = filedata[i].strip()
|
|
||||||
if len(strippedline)==0:
|
|
||||||
continue
|
|
||||||
if ';{}'.find(strippedline[-1]) < 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
i1 = i + 1
|
|
||||||
while i1 < len(filedata) and filedata[i1].startswith('#'):
|
|
||||||
i1 = i1 + 1
|
|
||||||
|
|
||||||
i2 = i1
|
|
||||||
indent = 0
|
|
||||||
while i2 < len(filedata):
|
|
||||||
for c in filedata[i2]:
|
|
||||||
if c == '}':
|
|
||||||
indent = indent - 1
|
|
||||||
if indent == 0:
|
|
||||||
indent = -100
|
|
||||||
elif c == '{':
|
|
||||||
indent = indent + 1
|
|
||||||
if indent < 0:
|
|
||||||
break
|
|
||||||
i2 = i2 + 1
|
|
||||||
if indent == -100:
|
|
||||||
indent = 0
|
|
||||||
if i2 == i1 or i2 >= len(filedata):
|
|
||||||
continue
|
|
||||||
if filedata[i2].strip() != '}' and filedata[i2].strip() != '};':
|
|
||||||
continue
|
|
||||||
if indent < 0:
|
|
||||||
i2 = i2 - 1
|
|
||||||
filedata = clearandrun('remove codeblock', filedata, i1, i2)
|
|
||||||
|
|
||||||
return filedata
|
|
||||||
|
|
||||||
def removeline(filedata):
|
def removeline(filedata):
|
||||||
stmt = True
|
stmt = True
|
||||||
for i in range(len(filedata)):
|
for i in range(len(filedata)):
|
||||||
line = filedata[i]
|
line = filedata[i]
|
||||||
strippedline = line.strip()
|
strippedline = line.strip()
|
||||||
|
|
||||||
if len(strippedline) == 0:
|
if len(strippedline) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if stmt and strippedline[-1]==';' and checkpar(line) and line.find('{')<0 and line.find('}')<0:
|
if stmt and strippedline[-1] == ';' and checkpar(line) and line.find('{') < 0 and line.find('}') < 0:
|
||||||
replaceandrun('remove line', filedata, i, '')
|
replaceandrun('remove line', filedata, i, '')
|
||||||
|
|
||||||
elif stmt and strippedline.find('{') > 0 and strippedline.find('}') == len(strippedline) - 1:
|
elif stmt and strippedline.find('{') > 0 and strippedline.find('}') == len(strippedline) - 1:
|
||||||
replaceandrun('remove line', filedata, i, '')
|
replaceandrun('remove line', filedata, i, '')
|
||||||
|
|
||||||
if ';{}'.find(strippedline[-1]) >= 0:
|
if ';{}'.find(strippedline[-1]) >= 0:
|
||||||
stmt = True
|
stmt = True
|
||||||
else:
|
else:
|
||||||
stmt = False
|
stmt = False
|
||||||
|
|
||||||
|
|
||||||
# reduce..
|
# reduce..
|
||||||
print('Make sure error can be reproduced...')
|
print('Make sure error can be reproduced...')
|
||||||
if runtool() == False:
|
if runtool() == False:
|
||||||
print("Cannot reproduce")
|
print("Cannot reproduce")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
f = open(FILE, 'rt')
|
f = open(FILE, 'rt')
|
||||||
filedata = f.readlines()
|
filedata = f.readlines()
|
||||||
|
@ -235,31 +235,31 @@ f.close()
|
||||||
writefile(BACKUPFILE, filedata)
|
writefile(BACKUPFILE, filedata)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
filedata1 = list(filedata)
|
filedata1 = list(filedata)
|
||||||
|
|
||||||
print('remove comments...')
|
print('remove comments...')
|
||||||
removecomments(filedata)
|
removecomments(filedata)
|
||||||
|
|
||||||
print('remove preprocessor directives...')
|
print('remove preprocessor directives...')
|
||||||
removedirectives(filedata)
|
removedirectives(filedata)
|
||||||
|
|
||||||
print('remove blocks...')
|
print('remove blocks...')
|
||||||
filedata = removeblocks(filedata)
|
filedata = removeblocks(filedata)
|
||||||
|
|
||||||
print('combine lines..')
|
print('combine lines..')
|
||||||
combinelines(filedata)
|
combinelines(filedata)
|
||||||
|
|
||||||
print('remove line...')
|
print('remove line...')
|
||||||
removeline(filedata)
|
removeline(filedata)
|
||||||
|
|
||||||
# if filedata and filedata2 are identical then stop
|
# if filedata and filedata2 are identical then stop
|
||||||
if len(filedata1) == len(filedata):
|
if len(filedata1) == len(filedata):
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(filedata1):
|
while i < len(filedata1):
|
||||||
if filedata[i] != filedata1[i]:
|
if filedata[i] != filedata1[i]:
|
||||||
break
|
break
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if i == len(filedata1):
|
if i == len(filedata1):
|
||||||
break
|
break
|
||||||
|
|
||||||
writefile(FILE, filedata)
|
writefile(FILE, filedata)
|
||||||
|
|
|
@ -10,12 +10,12 @@ import sys
|
||||||
START = 0
|
START = 0
|
||||||
PASSWORD = ''
|
PASSWORD = ''
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if len(arg)==1:
|
if len(arg) == 1:
|
||||||
START = '0123456789abcdefghijklmnopqrstuvwxyz'.find(arg)
|
START = '0123456789abcdefghijklmnopqrstuvwxyz'.find(arg)
|
||||||
if START < 0:
|
if START < 0:
|
||||||
START = 0
|
START = 0
|
||||||
else:
|
else:
|
||||||
PASSWORD = arg
|
PASSWORD = arg
|
||||||
|
|
||||||
# Upload file to sourceforge web server using scp
|
# Upload file to sourceforge web server using scp
|
||||||
def upload(file_to_upload, destination):
|
def upload(file_to_upload, destination):
|
||||||
|
|
|
@ -21,20 +21,20 @@ import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print('revisions not specified')
|
print('revisions not specified')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
res = re.match(r'([0-9]+):([0-9]+)', sys.argv[1])
|
res = re.match(r'([0-9]+):([0-9]+)', sys.argv[1])
|
||||||
if res is None:
|
if res is None:
|
||||||
print('invalid format, 11111:22222')
|
print('invalid format, 11111:22222')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
rev1 = int(res.group(1))
|
rev1 = int(res.group(1))
|
||||||
rev2 = int(res.group(2))
|
rev2 = int(res.group(2))
|
||||||
|
|
||||||
if rev1>rev2 or rev1<10000 or rev2>20000 or rev2-rev1>500:
|
if rev1 > rev2 or rev1 < 10000 or rev2 > 20000 or rev2 - rev1 > 500:
|
||||||
print('range, aborting')
|
print('range, aborting')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print('Revisions: ' + str(rev1) + ':' + str(rev2))
|
print('Revisions: ' + str(rev1) + ':' + str(rev2))
|
||||||
|
|
||||||
|
@ -42,17 +42,16 @@ f = open('results.txt', 'wt')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
for rev in range(rev1,rev2):
|
for rev in range(rev1, rev2):
|
||||||
subprocess.call(['svn', 'revert', '-R', '.'])
|
subprocess.call(['svn', 'revert', '-R', '.'])
|
||||||
subprocess.call(['svn', 'up', '-r' + str(rev)])
|
subprocess.call(['svn', 'up', '-r' + str(rev)])
|
||||||
for vcxproj in glob.glob('*/*.vcxproj'):
|
for vcxproj in glob.glob('*/*.vcxproj'):
|
||||||
subprocess.call([r'c:\cygwin64\bin\sed.exe', '-i', 's/140/120/', vcxproj])
|
subprocess.call([r'c:\cygwin64\bin\sed.exe', '-i', 's/140/120/', vcxproj])
|
||||||
subprocess.call('msbuild cppcheck.sln /t:build /p:configuration=Release,platform=x64'.split())
|
subprocess.call('msbuild cppcheck.sln /t:build /p:configuration=Release,platform=x64'.split())
|
||||||
print('Revision:' + str(rev))
|
print('Revision:' + str(rev))
|
||||||
p = subprocess.Popen(r'bin\cppcheck.exe src -q --showtime=summary'.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(r'bin\cppcheck.exe src -q --showtime=summary'.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
comm = p.communicate()
|
comm = p.communicate()
|
||||||
f = open('results.txt', 'at')
|
f = open('results.txt', 'at')
|
||||||
f.write('\nREV ' + str(rev) + '\n')
|
f.write('\nREV ' + str(rev) + '\n')
|
||||||
f.write(comm[0].decode('utf-8'))
|
f.write(comm[0].decode('utf-8'))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue