aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser.js20
-rw-r--r--tests/runner.py12
2 files changed, 27 insertions, 5 deletions
diff --git a/src/parser.js b/src/parser.js
index aa91b60b..c91d83da 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -341,6 +341,24 @@ function parseNumerical(value, type) {
return value;
}
+// \0Dsometext is really '\r', then sometext
+// This function returns an array of int values
+function parseLLVMString(str) {
+ var ret = [];
+ var i = 0;
+ while (i < str.length) {
+ var chr = str[i];
+ if (chr != '\\') {
+ ret.push(chr.charCodeAt(0));
+ i++;
+ } else {
+ ret.push(_HexToInt(str[i+1]+str[i+2]));
+ i += 3;
+ }
+ }
+ return ret;
+}
+
function getLabelIds(labels) {
return labels.map(function(label) { return label.ident });
}
@@ -1915,7 +1933,7 @@ function JSify(data) {
return makePointer(JSON.stringify(makeEmptyStruct(type)));
} else if (value.text[0] == '"') {
value.text = value.text.substr(1, value.text.length-2);
- return makePointer('intArrayFromString("' + value.text + '")');
+ return makePointer(JSON.stringify(parseLLVMString(value.text)));
} else {
// Gets an array of constant items, separated by ',' tokens
function handleSegments(tokens) {
diff --git a/tests/runner.py b/tests/runner.py
index e9ba880d..d81c1b57 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -224,16 +224,20 @@ class T(unittest.TestCase):
src = '''
#include <stdio.h>
#include <stdlib.h>
+ #include <string.h>
+
int main(int argc, char **argv)
{
printf("*%d", argc);
puts(argv[1]);
puts(argv[2]);
- printf("%d*", atoi(argv[3])+2);
+ printf("%d", atoi(argv[3])+2);
+ const char *foolingthecompiler = "\\rabcd";
+ printf("%d", strlen(foolingthecompiler)); // Tests parsing /0D in llvm - should not be a 0 (end string) then a D!
return 0;
}
'''
- self.do_test(src, '*4*wowie*too*76*', ['wowie', 'too', '74'], lambda x: x.replace('\n', '*'))
+ self.do_test(src, '*4*wowie*too*76*5*', ['wowie', 'too', '74'], lambda x: x.replace('\n', '*'))
def test_funcs(self):
src = '''
@@ -566,7 +570,7 @@ class T(unittest.TestCase):
return 0;
}
'''
- self.do_test(src, '*2,2,5,8,8*\n*8,8,5,8,8*\n*7,2,6,990,7,2*')
+ self.do_test(src, '*2,2,5,8,8****8,8,5,8,8****7,2,6,990,7,2*', [], lambda x: x.replace('\n', '*'))
def test_llvmswitch(self):
src = '''
@@ -666,7 +670,7 @@ class T(unittest.TestCase):
src = open(path_from_root(['tests', 'fasta.cpp']), 'r').read()
self.do_test(src, j, [str(i)], lambda x: x.replace('\n', '*'), no_python=True, no_build=i>1)
- def test_sauer(self):
+ def zzztest_sauer(self):
# XXX Warning: Running this in SpiderMonkey can lead to an extreme amount of memory being
# used, see Mozilla bug 593659.
assert PARSER_ENGINE != SPIDERMONKEY_ENGINE