From 0a1761b10b74f98607444abc6229e2bd856c8246 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Sun, 13 Aug 2017 10:11:58 -0400 Subject: [PATCH] Replace some string.find/rfind for Python 2/3 compatibility Signed-off-by: David A. Wheeler --- flawfinder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flawfinder b/flawfinder index b226a54..eb8730a 100755 --- a/flawfinder +++ b/flawfinder @@ -1336,7 +1336,7 @@ template_ruleset = { def find_column(text, position): "Find column number inside line." - newline = string.rfind(text, "\n", 0, position) + newline = text.rfind("\n", 0, position) if newline == -1: return position + 1 return position - newline @@ -1344,8 +1344,8 @@ def find_column(text, position): def get_context(text, position): "Get surrounding text line starting from text[position]" - linestart = string.rfind(text, "\n", 0, position + 1) + 1 - lineend = string.find(text, "\n", position, len(text)) + linestart = text.rfind("\n", 0, position + 1) + 1 + lineend = text.find("\n", position, len(text)) if lineend == -1: lineend = len(text) return text[linestart:lineend]