aboutsummaryrefslogtreecommitdiff
path: root/clang/tools
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-02 13:59:03 +0000
committerDaniel Jasper <djasper@google.com>2013-10-02 13:59:03 +0000
commit164c8e181068880f825baebf76e384e51f20c9c7 (patch)
tree3c897c418a7bd30e38b136ec25743801b7141647 /clang/tools
parent8358c414777075972af342cf7f9f5f8ae222a36d (diff)
downloadllvm-164c8e181068880f825baebf76e384e51f20c9c7.zip
llvm-164c8e181068880f825baebf76e384e51f20c9c7.tar.gz
llvm-164c8e181068880f825baebf76e384e51f20c9c7.tar.bz2
clang-format: Fix clang-format-diff.py according to diff specification.
Patch by Alp Toker. Many thanks! Original descriptions: clang-format-diff incorrectly modifies unchanged lines due to an error in diff parsing. The unified diff format has a default line change count of 1, and 0 may be specified to indicate that no lines have been added. This patch updates the parser to accurately reflect the diff specification. This also has the benefit of stabilising the operation so it will produce the same output when run multiple times on the same changeset, which was previously not the case. No tests added because this script is not currently tested (though we should look into that!) llvm-svn: 191820
Diffstat (limited to 'clang/tools')
-rwxr-xr-xclang/tools/clang-format/clang-format-diff.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index 7c14178..90723d2 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -60,9 +60,12 @@ def main():
match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
- end_line = start_line
+ line_count = 1
if match.group(3):
- end_line = start_line + int(match.group(3))
+ line_count = int(match.group(3))
+ if line_count == 0:
+ continue
+ end_line = start_line + line_count - 1;
lines_by_file.setdefault(filename, []).extend(
['-lines', str(start_line) + ':' + str(end_line)])