diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-01-29 18:48:21 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-01-29 18:48:21 +0000 |
commit | eb245d02d14b851f38d700f63665f4e0024737c0 (patch) | |
tree | a410c059ed167f6b56e7f3ca0f1208443f7cd593 /bin | |
parent | b5f19ef7d57684a01f2a2c4395faa600251adf54 (diff) | |
download | portage-eb245d02d14b851f38d700f63665f4e0024737c0.tar.gz portage-eb245d02d14b851f38d700f63665f4e0024737c0.tar.bz2 portage-eb245d02d14b851f38d700f63665f4e0024737c0.zip |
Fix unicode quote handling to work with python3. (trunk r15195)
svn path=/main/branches/2.1.7/; revision=15249
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/check-implicit-pointer-usage.py | 20 |
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) |