From 57b8e5a49801661495b14ddc33c4775c7844e174 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 12 Nov 2013 08:47:49 -0800 Subject: ignore first L when demangling, literalness is irrelevant to the main name --- src/preamble.js | 4 +++- tests/test_other.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/preamble.js b/src/preamble.js index e552f782..27016c14 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -709,6 +709,7 @@ function demangle(func) { i++; // skip E return parts; } + var first = true; function parse(rawList, limit, allowVoid) { // main parser limit = limit || Infinity; var ret = '', list = []; @@ -723,7 +724,7 @@ function demangle(func) { if (limit === 0) return rawList ? [name] : name; } else { // not namespaced - if (func[i] === 'K') i++; // ignore const + if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L' var size = parseInt(func.substr(i)); if (size) { var pre = size.toString().length; @@ -731,6 +732,7 @@ function demangle(func) { i += pre + size; } } + first = false; if (func[i] === 'I') { i++; var iList = parse(true); diff --git a/tests/test_other.py b/tests/test_other.py index a2a1448f..3a781042 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1927,6 +1927,7 @@ done. EM_ASM(Module.print(demangle('_main'))); EM_ASM(Module.print(demangle('__Z2f2v'))); EM_ASM(Module.print(demangle('__Z12abcdabcdabcdi'))); + EM_ASM(Module.print(demangle('__ZL12abcdabcdabcdi'))); EM_ASM(Module.print(demangle('__Z4testcsifdPvPiPc'))); EM_ASM(Module.print(demangle('__ZN4test5moarrEcslfdPvPiPc'))); EM_ASM(Module.print(demangle('__ZN4Waka1f12a234123412345pointEv'))); @@ -1949,6 +1950,7 @@ done. _main f2() abcdabcdabcd(int) +abcdabcdabcd(int) test(char, short, int, float, double, void*, int*, char*) test::moarr(char, short, long, float, double, void*, int*, char*) Waka::f::a23412341234::point() -- cgit v1.2.3-18-g5258