From: Akihiro Sagawa sagawa.aki@gmail.com
--- programs/cmd/tests/batch.c | 31 ++++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd | 9 +++++++ programs/cmd/tests/test_builtins.cmd.exp | 2 ++ 3 files changed, 42 insertions(+)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c index 6bc5e916ea9..03a05f34215 100644 --- a/programs/cmd/tests/batch.c +++ b/programs/cmd/tests/batch.c @@ -31,11 +31,38 @@ static DWORD path_len; static char shortpath[MAX_PATH]; static DWORD shortpath_len;
+static BOOL parse_hexadecimal(const char *p, char *dest) +{ + unsigned char c; + if (*p++ != '@') return FALSE; + if (*p++ != '\') return FALSE; + if (*p++ != 'x') return FALSE; + + if (*p >= '0' && *p <= '9') c = *p - '0'; + else if (*p >= 'a' && *p <= 'f') c = *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') c = *p - 'A' + 10; + else return FALSE; + p++; + + c <<= 4; + + if (*p >= '0' && *p <= '9') c += *p - '0'; + else if (*p >= 'a' && *p <= 'f') c += *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') c += *p - 'A' + 10; + else return FALSE; + p++; + + if (*p != '@') return FALSE; + *dest = (char)c; + return TRUE; +} + /* Convert to DOS line endings, and substitute escaped whitespace chars with real ones */ static const char* convert_input_data(const char *data, DWORD size, DWORD *new_size) { static const char escaped_space[] = {'@','s','p','a','c','e','@'}; static const char escaped_tab[] = {'@','t','a','b','@'}; + static const char escaped_hexadecimal[] = {'@','\','x','.','.','@'}; DWORD i, eol_count = 0; char *ptr, *new_data;
@@ -60,6 +87,10 @@ static const char* convert_input_data(const char *data, DWORD size, DWORD *new_s && !memcmp(data + i, escaped_tab, sizeof(escaped_tab))) { *ptr++ = '\t'; i += sizeof(escaped_tab) - 1; + } else if (data + i + sizeof(escaped_hexadecimal) - 1 < data + size + && parse_hexadecimal(data + i, ptr)) { + ptr++; + i += sizeof(escaped_hexadecimal) - 1; } else { *ptr++ = data[i]; } diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 2d37bdc4c59..907b8d123f2 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -4130,6 +4130,15 @@ echo echo shouldnot >> foobar.bat call foobar.bat if exist foobar.bat (echo stillthere & erase /q foobar.bat >NUL)
+echo ------------ Testing updated code page execution ------------ +echo @echo off>utf8.cmd +echo chcp 65001>>utf8.cmd +echo set utf8=@\xE3@@\xA1@@\xA1@@\xE3@@\xA1@@\xA1@>>utf8.cmd +echo if not "%%utf8:~0,2%%"=="%%utf8%%" exit 1 >>utf8.cmd +start /wait cmd /cutf8.cmd +if not errorlevel 1 echo Success +del utf8.cmd + echo ------------ Testing combined CALLs/GOTOs ------------ echo @echo off>foo.cmd echo goto :eof>>foot.cmd diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 6137c594359..46d045f3eb0 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -2122,6 +2122,8 @@ Normal+tab+garbage Success @todo_wine@Success ---- Testing nasty bits ---- +------------ Testing updated code page execution ------------ +@todo_wine@Success ------------ Testing combined CALLs/GOTOs ------------ world cheball