clang-format-diff.py: pass through errors to stderr, not stdout
Also use write() for unified diff output to avoid further processing by the
print function (e.g. trailing newline).
git-svn-id: svn://svn.chromium.org/llvm-project/cfe/trunk/tools/clang-format@196484 0b72dbe1-c17f-4bc7-b9db-2b4152be0356
diff --git a/clang-format-diff.py b/clang-format-diff.py
index b042d95..a62cae8 100755
--- a/clang-format-diff.py
+++ b/clang-format-diff.py
@@ -85,11 +85,8 @@
if args.style:
command.extend(['-style', args.style])
p = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- stdin=subprocess.PIPE)
+ stderr=None, stdin=subprocess.PIPE)
stdout, stderr = p.communicate()
- if stderr:
- print stderr
if p.returncode != 0:
sys.exit(p.returncode);
@@ -102,7 +99,7 @@
'(before formatting)', '(after formatting)')
diff_string = string.join(diff, '')
if len(diff_string) > 0:
- print diff_string
+ sys.stdout.write(diff_string)
if __name__ == '__main__':
main()