Commit d8c471ff authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] change formatter to emit LF newlines on Windows

Otherwise, it will always replace LF with CRLF, which is not what you
want if you follow the Chromium instructions for Windows, that is,
configure git with core.autocrlf = false.

Change-Id: I30fcfc471cde79d5c80d05ce582a8507cf5810b5
Reviewed-on: https://chromium-review.googlesource.com/c/1345150Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57691}
parent 7d9f525b
...@@ -9,6 +9,7 @@ the source and header files directly in V8's src directory.""" ...@@ -9,6 +9,7 @@ the source and header files directly in V8's src directory."""
import subprocess import subprocess
import sys import sys
import re import re
import io
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
def preprocess(input): def preprocess(input):
...@@ -82,13 +83,13 @@ def postprocess(output): ...@@ -82,13 +83,13 @@ def postprocess(output):
return output return output
def process(filename, only_lint, use_stdout): def process(filename, only_lint, use_stdout):
with open(filename, 'r') as content_file: with io.open(filename, 'r') as content_file:
content = content_file.read() content = content_file.read()
original_input = content original_input = content
p = Popen(['clang-format', '-assume-filename=.ts'], stdin=PIPE, stdout=PIPE, stderr=PIPE) p = Popen(['clang-format', '-assume-filename=.ts'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = p.communicate(preprocess(content)) output, err = p.communicate(preprocess(content).encode('utf-8'))
output = postprocess(output) output = postprocess(output)
rc = p.returncode rc = p.returncode
if (rc <> 0): if (rc <> 0):
...@@ -101,8 +102,8 @@ def process(filename, only_lint, use_stdout): ...@@ -101,8 +102,8 @@ def process(filename, only_lint, use_stdout):
elif use_stdout: elif use_stdout:
print output print output
else: else:
output_file = open(filename, 'w') output_file = io.open(filename, 'w', newline="\n")
output_file.write(output); output_file.write(output.decode('utf-8'));
output_file.close() output_file.close()
def print_usage(): def print_usage():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment