| Index: runtime/tools/create_string_literal.py
|
| ===================================================================
|
| --- runtime/tools/create_string_literal.py (revision 4233)
|
| +++ runtime/tools/create_string_literal.py (working copy)
|
| @@ -13,21 +13,32 @@
|
|
|
|
|
| def makeString(input_files):
|
| + printable = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\
|
| +!#$%&'()*+,-./:;<=>?@[]^_`{|}~ "
|
| result = ' '
|
| + lineNumber = 1
|
| for string_file in input_files:
|
| if string_file.endswith('dart'):
|
| fileHandle = open(string_file, 'rb')
|
| - lineCounter = 0
|
| - result += ' // ' + string_file + '\n '
|
| + quoted = False
|
| + result += '\n // ----- ' + string_file + ' -----\n\n'
|
| for byte in fileHandle.read():
|
| - result += ' %d,' % ord(byte)
|
| - lineCounter += 1
|
| - if lineCounter == 10:
|
| - result += '\n '
|
| - lineCounter = 0
|
| - if lineCounter != 0:
|
| - result += '\n '
|
| - result += ' // Terminating null character.\n 0'
|
| + if not quoted:
|
| + result += ' "'
|
| + quoted = True
|
| + if byte in printable:
|
| + result += byte
|
| + elif byte == '\n':
|
| + if lineNumber % 10 == 0:
|
| + result += '\\n" /* L%d */\n' % lineNumber
|
| + else:
|
| + result += '\\n"\n'
|
| + lineNumber += 1
|
| + quoted = False
|
| + elif byte == '\"':
|
| + result += '\\"'
|
| + else:
|
| + result += '\\x%02x' % ord(byte)
|
| return result
|
|
|
|
|
|
|