From 9708b5367efd5b2a0f5fab2d39fd1a0544dbccfb Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Mon, 9 Mar 2020 19:00:02 +0200 Subject: [PATCH] Fix wasm core spec 1.1 names test --- platforms/app/main.c | 6 +++--- test/run-spec-test.py | 19 +++++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/platforms/app/main.c b/platforms/app/main.c index 3f5568b..1ec6fa6 100644 --- a/platforms/app/main.c +++ b/platforms/app/main.c @@ -156,8 +156,8 @@ void unescape(char* buff) case 't': *outp++ = '\t'; break; case 'x': { char hex[3] = { *(buff+2), *(buff+3), '\0' }; - *outp++ = strtol(hex, NULL, 16); - buff += 2; + *outp = strtol(hex, NULL, 16); + buff += 2; outp += 1; break; } // Otherwise just pass the letter @@ -284,7 +284,7 @@ int main (int i_argc, const char* i_argv[]) while (argRepl) { - char cmd_buff[1024] = { 0, }; + char cmd_buff[2048] = { 0, }; char* argv[32] = { 0, }; fprintf(stdout, "wasm3> "); fflush(stdout); diff --git a/test/run-spec-test.py b/test/run-spec-test.py index fb7ee80..e36f140 100755 --- a/test/run-spec-test.py +++ b/test/run-spec-test.py @@ -89,23 +89,14 @@ def binaryToFloat(num, t): else: fatal(f"Unknown type '{t}'") -def escape(s): - c = ord(s) - - if c < 128 and s.isprintable() and not s in " \n\r\t\\": - return s - - if c <= 0xff: - return r'\x{0:02x}'.format(c) - elif c <= 0xffff: - return r'\u{0:04x}'.format(c) - else: - return r'\U{0:08x}'.format(c) - def escape_str(s): if s == "": return r'\x00' - return ''.join(escape(c) for c in s) + + if all((ord(c) < 128 and c.isprintable() and not c in " \n\r\t\\") for c in s): + return s + + return '\\x' + '\\x'.join('{0:02x}'.format(x) for x in s.encode('utf-8')) # # Value format options