Skip to content

Commit accfb24

Browse files
authored
Remove unneeded normalize_line_endings function. NFC (#19526)
Now that we use using python3 all inputs will be converted internally to `\n` when files are read in. Unless we are reading text files in binary mode the `\r\n` ending will never exist in python, and since strings (unicode) and binary are different types now we know that we are not dealing with binary here.
1 parent 71634e0 commit accfb24

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

emscripten.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from tools import webassembly
2828
from tools import extract_metadata
2929
from tools.utils import exit_with_error, path_from_root
30-
from tools.shared import DEBUG, WINDOWS, asmjs_mangle
30+
from tools.shared import DEBUG, asmjs_mangle
3131
from tools.shared import treat_as_user_function, strip_prefix
3232
from tools.settings import settings
3333

@@ -55,9 +55,8 @@ def compute_minimal_runtime_initializer_and_exports(post, exports, receiving):
5555

5656

5757
def write_output_file(outfile, module):
58-
for i in range(len(module)): # do this loop carefully to save memory
59-
module[i] = normalize_line_endings(module[i])
60-
outfile.write(module[i])
58+
for chunk in module:
59+
outfile.write(chunk)
6160

6261

6362
def maybe_disable_filesystem(imports):
@@ -422,7 +421,7 @@ def emscript(in_wasm, out_wasm, outfile_js, memfile, js_syms):
422421
'// === Body ===\n\n' + extra_code + '\n')
423422

424423
with open(outfile_js, 'w', encoding='utf-8') as out:
425-
out.write(normalize_line_endings(pre))
424+
out.write(pre)
426425
pre = None
427426

428427
receiving = create_receiving(exports)
@@ -436,7 +435,7 @@ def emscript(in_wasm, out_wasm, outfile_js, memfile, js_syms):
436435

437436
write_output_file(out, module)
438437

439-
out.write(normalize_line_endings(post))
438+
out.write(post)
440439
module = None
441440

442441

@@ -927,15 +926,5 @@ def create_wasm64_wrappers(metadata):
927926
return wasm64_wrappers
928927

929928

930-
def normalize_line_endings(text):
931-
"""Normalize to UNIX line endings.
932-
933-
On Windows, writing to text file will duplicate \r\n to \r\r\n otherwise.
934-
"""
935-
if WINDOWS:
936-
return text.replace('\r\n', '\n')
937-
return text
938-
939-
940929
def run(in_wasm, out_wasm, outfile_js, memfile, js_syms):
941930
emscript(in_wasm, out_wasm, outfile_js, memfile, js_syms)

0 commit comments

Comments
 (0)