From e856bce4e99fb37810534f213b9466d6e19b0058 Mon Sep 17 00:00:00 2001 From: Duong Do Minh Chau Date: Sun, 26 Apr 2020 20:40:16 +0700 Subject: [PATCH] Treat ' as digit separator when file extension is .cpp, .cxx, .cc --- flawfinder | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/flawfinder b/flawfinder index 60a2c1a..cee78ee 100755 --- a/flawfinder +++ b/flawfinder @@ -1461,6 +1461,7 @@ def process_c_file(f, patch_infos): linenumber = 1 ignoreline = -1 + cpplanguage = f.endswith(".cpp") or f.endswith(".cxx") or f.endswith(".cc") incomment = 0 instring = 0 linebegin = 1 @@ -1644,9 +1645,12 @@ def process_c_file(f, patch_infos): startpos + max_lookahead] hit.hook(hit) elif p_digits.match(c): - while i < len(text) and p_digits.match( - text[i]): # Process a number. - i += 1 + while i < len(text): # Process a number. + # C does not have digit separator + if p_digits.match(text[i]) or (cpplanguage and text[i] == "'"): + i += 1 + else: + break # else some other character, which we ignore. # End of loop through text. Wrap up. if codeinline: