Skip to content

Commit

Permalink
Fix multiple lines and ignore double %
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterL73 authored and Fuzzbawls committed Nov 25, 2017
1 parent 9eead5a commit e940f9d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions contrib/devtools/logprint-scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def countRelevantCommas(line):
lineCounter = 1

tempLine = ""
tempCount = 0

for row in rows:
# Collapse multiple lines into one
Expand Down Expand Up @@ -68,11 +69,12 @@ def countRelevantCommas(line):
numExtraPercents = tempLine.count('%', commaAfterEndSpecifierStringIndex)

# Subtract extra from total count. This is the number of expected specifiers
numPercents = tempLine.count('%') - numExtraPercents
# ignore %%
numPercents = tempLine.count('%') - numExtraPercents - 2*tempLine.count('%%')

if numPercents != numCommas:
print "Incorrect number of arguments for LogPrint(f) statement found."
print(str(file) + ":" + str(lineCounter))
print(str(file) + ":" + str(lineCounter - tempCount))
print "Line = " + tempLine
print("numRelevantCommas = " + str(numCommas) + ", numRelevantPercents = " + str(numPercents))
print ""
Expand All @@ -81,9 +83,15 @@ def countRelevantCommas(line):

# Done with this multiline, clear tempLine
tempLine = ""

tempLine = ""
lineCounter +=1
tempCount = 0
else:
tempCount += 1
else:
# No LogPrint, clear tempLine
tempLine = ""
tempCount = 0

lineCounter += 1

print("# of incorrect instances: " + str(incorrectInstanceCounter))

Expand Down

0 comments on commit e940f9d

Please sign in to comment.