aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js3
-rw-r--r--tests/runner.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 5fcb6aa2..4c0b1974 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -161,7 +161,8 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions, givenGlobalVaria
return makeEmptyStruct(type);
} else if (value.text && value.text[0] == '"') {
value.text = value.text.substr(1, value.text.length-2);
- return JSON.stringify(parseLLVMString(value.text)) + ' /* ' + value.text + '*/';
+ return JSON.stringify(parseLLVMString(value.text)) +
+ ' /* ' + value.text.replace(/\*/g, '_') + ' */'; // make string safe for inclusion in comment
} else {
// Gets an array of constant items, separated by ',' tokens
function handleSegments(tokens) {
diff --git a/tests/runner.py b/tests/runner.py
index cc1b1309..ef6f024d 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -392,10 +392,12 @@ if 'benchmark' not in sys.argv:
const char *foolingthecompiler = "\\rabcd";
printf("%d\\n", strlen(foolingthecompiler)); // Tests parsing /0D in llvm - should not be a 0 (end string) then a D!
printf("%s\\n", NULL); // Should print '(null)', not the string at address 0, which is a real address for us!
+ printf("/* a comment */\\n"); // Should not break the generated code!
+ printf("// another\\n"); // Should not break the generated code!
return 0;
}
'''
- self.do_test(src, '*4*wowie*too*76*5*(null)*', ['wowie', 'too', '74'], lambda x: x.replace('\n', '*'))
+ self.do_test(src, '*4*wowie*too*76*5*(null)*/* a comment */*// another', ['wowie', 'too', '74'], lambda x: x.replace('\n', '*'))
def test_funcs(self):
src = '''