From: Laszlo Nagy Date: Wed, 8 Mar 2017 09:27:53 +0000 (+0000) Subject: [scan-build-py] fix some line separator issues X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e75ac3026cb54e661e4ef6ec37a5a69f5c8e552a;p=clang [scan-build-py] fix some line separator issues Differential Revision: https://reviews.llvm.org/D30600 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297266 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/scan-build-py/libear/__init__.py b/tools/scan-build-py/libear/__init__.py index 3e1c13cf2b..421e2e74f0 100644 --- a/tools/scan-build-py/libear/__init__.py +++ b/tools/scan-build-py/libear/__init__.py @@ -207,9 +207,9 @@ class Configure(object): if m: key = m.group(1) if key not in definitions or not definitions[key]: - return '/* #undef {} */\n'.format(key) + return '/* #undef {0} */{1}'.format(key, os.linesep) else: - return '#define {}\n'.format(key) + return '#define {0}{1}'.format(key, os.linesep) return line with open(template, 'r') as src_handle: diff --git a/tools/scan-build-py/libscanbuild/report.py b/tools/scan-build-py/libscanbuild/report.py index 83b581b79f..08170093f7 100644 --- a/tools/scan-build-py/libscanbuild/report.py +++ b/tools/scan-build-py/libscanbuild/report.py @@ -336,11 +336,12 @@ def parse_crash(filename): match = re.match(r'(.*)\.info\.txt', filename) name = match.group(1) if match else None - with open(filename) as handler: - lines = handler.readlines() + with open(filename, mode='rb') as handler: + # this is a workaround to fix windows read '\r\n' as new lines. + lines = [line.decode().rstrip() for line in handler.readlines()] return { - 'source': lines[0].rstrip(), - 'problem': lines[1].rstrip(), + 'source': lines[0], + 'problem': lines[1], 'file': name, 'info': name + '.info.txt', 'stderr': name + '.stderr.txt'