Bug 807525 - Have embedjs.py append newlines when not present. (r=till)
authorShu-yu Guo <shu@rfrn.org>
Thu, 01 Nov 2012 23:40:38 -0700
changeset 116783 d74f2e8a34f260c15a4580f7d9a99b9146578d1c
parent 116782 8bf2f8cb5e73f166ee32153fd51820b27185c3b5
child 116784 b92109c50c1c1b8ed754bc5a6e340da68f5c47e1
push idunknown
push userunknown
push dateunknown
reviewerstill
bugs807525
milestone19.0a1
Bug 807525 - Have embedjs.py append newlines when not present. (r=till)
js/src/builtin/embedjs.py
--- a/js/src/builtin/embedjs.py
+++ b/js/src/builtin/embedjs.py
@@ -12,17 +12,17 @@ from __future__ import with_statement
 import re, sys, os, js2c, fileinput
 
 def replaceErrorMsgs(source_files, messages_file, output_file):
     messages = buildMessagesTable(messages_file)
     with open(output_file, 'w') as output:
         if len(source_files) == 0:
             return
         for line in fileinput.input(source_files):
-            output.write(replaceMessages(line, messages))
+            output.write(replaceMessages(line if line[-1] == '\n' else line + '\n', messages))
 
 def buildMessagesTable(messages_file):
     table = {}
     pattern = re.compile(r"MSG_DEF\(([\w_]+),\s*(\d+)")
     for line in fileinput.input(messages_file):
         match = pattern.match(line)
         if match:
             table[match.group(1)] = match.group(2)
@@ -43,9 +43,9 @@ def main():
     messages_file = sys.argv[2]
     macros_file = sys.argv[3]
     source_files = sys.argv[4:]
     combined_file = 'selfhosted.js'
     replaceErrorMsgs(source_files, messages_file, combined_file)
     js2c.JS2C([combined_file, macros_file], [output_file], { 'TYPE': 'CORE', 'COMPRESSION': 'off', 'DEBUG':debug })
 
 if __name__ == "__main__":
-    main()
\ No newline at end of file
+    main()