Fix Debian bug #271287

git-svn-id: svn+ssh://svn.code.sf.net/p/flawfinder/code/trunk@6 5c01084b-1f27-0410-9f85-80411afe95dc
This commit is contained in:
dwheeler 2007-01-16 03:35:20 +00:00
parent cb2dfc307e
commit 47c7711a79
2 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2007-01-15 cmorgan <cmorgan47, at earthlink dooot net>
* Fixed Debian bug #271287 (flawfinder). See:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=271287
Fixed skipping newlines when line ended with \,
which caused incorrect line number reporting.
Skip multiple whitespace at one time.
2007-01-15 David A. Wheeler <dwheeler, at, dwheeler.com>
* Modified Sebastien Tandel's code so that it also supports GNU diff
(his code worked only for svn diff)

View File

@ -1204,6 +1204,7 @@ def process_directive():
numberset=string.hexdigits+"_x.Ee"
# Patterns for various circumstances:
p_whitespace = re.compile( r'[ \t\v\f]+' )
p_include = re.compile( r'#\s*include\s+(<.*?>|".*?")' )
p_digits = re.compile( r'[0-9]' )
p_alphaunder = re.compile( r'[A-Za-z_]' ) # Alpha chars and underline.
@ -1274,6 +1275,12 @@ def process_c_file(f, patch_infos):
# It doesn't bother to tokenize anything else, since it's not used.
# The following is a state machine with 3 states: incomment, instring,
# and "normal", and a separate state "linebegin" if at BOL.
# Skip any whitespace
m = p_whitespace.match(text,i)
if m:
i = m.end(0)
c = text[i]
if linebegin: # If at beginning of line, see if #include is there.
linebegin = 0
@ -1291,8 +1298,6 @@ def process_c_file(f, patch_infos):
i = i +1
continue
i = i + 1 # From here on, text[i] points to next character.
# Skip whitespace:
if (c == " ") or (c == "\t") or (c == "\v") or (c == "\f"): continue
if i < len(text): nextc = text[i]
else: nextc = ''
if incomment:
@ -1300,7 +1305,7 @@ def process_c_file(f, patch_infos):
i = i + 1
incomment = 0
elif instring:
if c == '\\': i = i + 1
if c == '\\' and (nextc != "\n"): i = i + 1
elif c == '"' and instring == 1: instring = 0
elif c == "'" and instring == 2: instring = 0
else: