Skip to content

fix_string_meminit_windows #3854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tools/eliminator/node_modules/uglify-js/lib/process.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions tools/line_endings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,30 @@ def check_line_endings(filename, print_errors=True):

has_dos_line_endings = False
has_unix_line_endings = False
dos_line_ending_example = ''
dos_line_ending_count = 0
unix_line_ending_example = ''
unix_line_ending_count = 0
if '\r\n' in data:
dos_line_ending_example = data[max(0, data.find('\r\n') - 50):min(len(data), data.find('\r\n')+50)].replace('\r', '\\r').replace('\n', '\\n')
dos_line_ending_count = data.count('\r\n')
has_dos_line_endings = True
data = data.replace('\r\n', 'A') # Replace all DOS line endings with some other character, and continue testing what's left.
if '\n' in data:
unix_line_ending_example = data[max(0, data.find('\n') - 50):min(len(data), data.find('\n')+50)].replace('\r', '\\r').replace('\n', '\\n')
unix_line_ending_count = data.count('\n')
has_unix_line_endings = True
if '\r' in data:
if print_errors: print >> sys.stderr, 'File \'' + filename + '\' contains OLD OSX line endings "\\r"'
old_osx_line_ending_example = data[max(0, data.find('\r') - 50):min(len(data), data.find('\r')+50)].replace('\r', '\\r').replace('\n', '\\n')
if print_errors:
print >> sys.stderr, 'File \'' + filename + '\' contains OLD OSX line endings "\\r"'
print >> sys.stderr, "Content around an OLD OSX line ending location: '" + old_osx_line_ending_example + "'"
return 1 # Return a non-zero process exit code since we don't want to use the old OSX (9.x) line endings anywhere.
if has_dos_line_endings and has_unix_line_endings:
if print_errors: print >> sys.stderr, 'File \'' + filename + '\' contains both DOS "\\r\\n" and UNIX "\\n" line endings!'
if print_errors:
print >> sys.stderr, 'File \'' + filename + '\' contains both DOS "\\r\\n" and UNIX "\\n" line endings! (' + str(dos_line_ending_count) + ' DOS line endings, ' + str(unix_line_ending_count) + ' UNIX line endings)'
print >> sys.stderr, "Content around a DOS line ending location: '" + dos_line_ending_example + "'"
print >> sys.stderr, "Content around an UNIX line ending location: '" + unix_line_ending_example + "'"
return 1 # Mixed line endings
else: return 0

Expand Down
3 changes: 2 additions & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,8 +1938,9 @@ def generate_string_initializer(s):
s = ''.join(map(chr, s))
s = s.replace('\\', '\\\\').replace("'", "\\'")
s = s.replace('\n', '\\n').replace('\r', '\\r')
# Escape the ^Z (= 0x1a = substitute) ASCII character and all characters higher than 7-bit ASCII.
def escape(x): return '\\x{:02x}'.format(ord(x.group()))
return re.sub('[\x80-\xff]', escape, s)
return re.sub('[\x1a\x80-\xff]', escape, s)

def execute(cmd, *args, **kw):
try:
Expand Down