diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-01-11 23:32:06 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-01-11 23:32:06 +0000 |
commit | 8a29081dcee9900a8a699c444f25cc1c02143444 (patch) | |
tree | a7b26c88c6408d544df1c6b32e6edb48db1eea6e | |
parent | 02978cc55435171f25353191da572a3ad4ccfef7 (diff) | |
download | portage-8a29081dcee9900a8a699c444f25cc1c02143444.tar.gz portage-8a29081dcee9900a8a699c444f25cc1c02143444.tar.bz2 portage-8a29081dcee9900a8a699c444f25cc1c02143444.zip |
Fix unicode quote handling to work with python3.
svn path=/main/trunk/; revision=15195
-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) |