1 |
Author: zmedico |
2 |
Date: 2010-01-29 18:48:21 +0000 (Fri, 29 Jan 2010) |
3 |
New Revision: 15249 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.7/bin/check-implicit-pointer-usage.py |
7 |
Log: |
8 |
Fix unicode quote handling to work with python3. (trunk r15195) |
9 |
|
10 |
Modified: main/branches/2.1.7/bin/check-implicit-pointer-usage.py |
11 |
=================================================================== |
12 |
--- main/branches/2.1.7/bin/check-implicit-pointer-usage.py 2010-01-29 18:48:08 UTC (rev 15248) |
13 |
+++ main/branches/2.1.7/bin/check-implicit-pointer-usage.py 2010-01-29 18:48:21 UTC (rev 15249) |
14 |
@@ -21,7 +21,7 @@ |
15 |
|
16 |
implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration " |
17 |
+ "of function [`']([^']*)'") |
18 |
-pointer_pattern = re.compile( |
19 |
+pointer_pattern = ( |
20 |
"([^:]*):(\d+): warning: " |
21 |
+ "(" |
22 |
+ "(assignment" |
23 |
@@ -32,6 +32,16 @@ |
24 |
+ ") makes pointer from integer without a cast" |
25 |
+ "|" |
26 |
+ "cast to pointer from integer of different size)") |
27 |
+ |
28 |
+if sys.hexversion < 0x3000000: |
29 |
+ pointer_pattern = unicode(pointer_pattern, encoding='utf_8') |
30 |
+ unicode_quote_open = unicode('\xE2\x80\x98', encoding='utf_8') |
31 |
+ unicode_quote_close = unicode('\xE2\x80\x99', encoding='utf_8') |
32 |
+else: |
33 |
+ unicode_quote_open = '\u2018' |
34 |
+ unicode_quote_close = '\u2019' |
35 |
+pointer_pattern = re.compile(pointer_pattern) |
36 |
+ |
37 |
last_implicit_filename = "" |
38 |
last_implicit_linenum = -1 |
39 |
last_implicit_func = "" |
40 |
@@ -40,11 +50,13 @@ |
41 |
if sys.hexversion >= 0x3000000: |
42 |
line = sys.stdin.buffer.readline().decode('utf_8', 'replace') |
43 |
else: |
44 |
- line = sys.stdin.readline() |
45 |
- if line == '': |
46 |
+ line = unicode(sys.stdin.readline(), |
47 |
+ encoding='utf_8', errors='replace') |
48 |
+ if not line: |
49 |
break |
50 |
# translate unicode open/close quotes to ascii ones |
51 |
- line = line.replace("\xE2\x80\x98", "`").replace("\xE2\x80\x99", "'") |
52 |
+ line = line.replace(unicode_quote_open, "`") |
53 |
+ line = line.replace(unicode_quote_close, "'") |
54 |
m = implicit_pattern.match(line) |
55 |
if m: |
56 |
last_implicit_filename = m.group(1) |