]> granicus.if.org Git - clang/commitdiff
[scan-build-py] fix some line separator issues
authorLaszlo Nagy <rizsotto.mailinglist@gmail.com>
Wed, 8 Mar 2017 09:27:53 +0000 (09:27 +0000)
committerLaszlo Nagy <rizsotto.mailinglist@gmail.com>
Wed, 8 Mar 2017 09:27:53 +0000 (09:27 +0000)
Differential Revision: https://reviews.llvm.org/D30600

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297266 91177308-0d34-0410-b5e6-96231b3b80d8

tools/scan-build-py/libear/__init__.py
tools/scan-build-py/libscanbuild/report.py

index 3e1c13cf2bfe027708501b3ccb52067db5644cb2..421e2e74f02327d4bf338c282f53e809c3dcc7d6 100644 (file)
@@ -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:
index 83b581b79fc17c237dfd438debc98ac0a76278f8..08170093f7079745bea53cd5a8dc994d9773f021 100644 (file)
@@ -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'