Skip to content

Commit fe75c7a

Browse files
committed
Merge branch 'windows_r_r_n_fix' of https://github.com/juj/emscripten into incoming
2 parents eef66eb + 5f47a12 commit fe75c7a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/jsifier.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ function JSify(data, functionsOnly) {
8787
}
8888

8989
function processLibraryFunction(snippet, ident, finalName) {
90-
snippet = snippet.toString();
90+
// It is possible that when printing the function as a string on Windows, the js interpreter we are in returns the string with Windows
91+
// line endings \r\n. This is undesirable, since line endings are managed in the form \n in the output for binary file writes, so
92+
// make sure the endings are uniform.
93+
snippet = snippet.toString().replace(/\r\n/gm,"\n");
9194
assert(snippet.indexOf('XXX missing C define') == -1,
9295
'Trying to include a library function with missing C defines: ' + finalName + ' | ' + snippet);
9396

tools/line_endings.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ def check_line_endings(filename, print_errors=True):
1313
if print_errors: print >> sys.stderr, "Unable to read file '" + filename + "', or file was empty!"
1414
return 1
1515

16-
if "\r\r\n" in data:
17-
if print_errors: print >> sys.stderr, "File '" + filename + "' contains BAD line endings of form \\r\\r\\n!"
16+
bad_line_ending_index = data.find("\r\r\n")
17+
if bad_line_ending_index != -1:
18+
if print_errors:
19+
print >> sys.stderr, "File '" + filename + "' contains BAD line endings of form \\r\\r\\n!"
20+
bad_line = data[max(0,bad_line_ending_index-50):min(len(data), bad_line_ending_index+50)]
21+
bad_line = bad_line.replace('\r', '\\r').replace('\n', '\\n')
22+
print >> sys.stderr, "Content around the location: '" + bad_line + "'"
1823
return 1 # Bad line endings in file, return a non-zero process exit code.
1924

2025
has_dos_line_endings = False

0 commit comments

Comments
 (0)