summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/check-implicit-pointer-usage.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py
index 179e73d23..ebd4c3629 100755
--- a/bin/check-implicit-pointer-usage.py
+++ b/bin/check-implicit-pointer-usage.py
@@ -21,7 +21,7 @@ import sys
implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
+ "of function [`']([^']*)'")
-pointer_pattern = re.compile(
+pointer_pattern = (
"([^:]*):(\d+): warning: "
+ "("
+ "(assignment"
@@ -32,6 +32,16 @@ pointer_pattern = re.compile(
+ ") makes pointer from integer without a cast"
+ "|"
+ "cast to pointer from integer of different size)")
+
+if sys.hexversion < 0x3000000:
+ pointer_pattern = unicode(pointer_pattern, encoding='utf_8')
+ unicode_quote_open = unicode('\xE2\x80\x98', encoding='utf_8')
+ unicode_quote_close = unicode('\xE2\x80\x99', encoding='utf_8')
+else:
+ unicode_quote_open = '\u2018'
+ unicode_quote_close = '\u2019'
+pointer_pattern = re.compile(pointer_pattern)
+
last_implicit_filename = ""
last_implicit_linenum = -1
last_implicit_func = ""
@@ -40,11 +50,13 @@ while True:
if sys.hexversion >= 0x3000000:
line = sys.stdin.buffer.readline().decode('utf_8', 'replace')
else:
- line = sys.stdin.readline()
- if line == '':
+ line = unicode(sys.stdin.readline(),
+ encoding='utf_8', errors='replace')
+ if not line:
break
# translate unicode open/close quotes to ascii ones
- line = line.replace("\xE2\x80\x98", "`").replace("\xE2\x80\x99", "'")
+ line = line.replace(unicode_quote_open, "`")
+ line = line.replace(unicode_quote_close, "'")
m = implicit_pattern.match(line)
if m:
last_implicit_filename = m.group(1)