From d85d99167939036d3ef0797a2819743ff3e00bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 27 May 2020 16:43:55 +0200 Subject: [PATCH] [CMD_ROSTEST] Sync batch.c with cmd_winetest' counterpart. --- modules/rostests/win32/cmd/batch.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/rostests/win32/cmd/batch.c b/modules/rostests/win32/cmd/batch.c index e6a77d95d77..10c30a1bbde 100644 --- a/modules/rostests/win32/cmd/batch.c +++ b/modules/rostests/win32/cmd/batch.c @@ -26,7 +26,7 @@ static char workdir[MAX_PATH]; static DWORD workdir_len; static char drive[2]; -static const DWORD drive_len = sizeof(drive)/sizeof(drive[0]); +static const DWORD drive_len = ARRAY_SIZE(drive); static char path[MAX_PATH]; static DWORD path_len; static char shortpath[MAX_PATH]; @@ -71,7 +71,11 @@ static const char* convert_input_data(const char *data, DWORD size, DWORD *new_s } *ptr = '\0'; +#ifdef __REACTOS__ *new_size = lstrlenA(new_data); +#else + *new_size = strlen(new_data); +#endif return new_data; } @@ -166,6 +170,7 @@ static const char *compare_line(const char *out_line, const char *out_end, const static const char path_cmd[] = {'@','p','a','t','h','@'}; static const char shortpath_cmd[] = {'@','s','h','o','r','t','p','a','t','h','@'}; static const char space_cmd[] = {'@','s','p','a','c','e','@'}; + static const char spaces_cmd[] = {'@','s','p','a','c','e','s','@'}; static const char tab_cmd[] = {'@','t','a','b','@'}; static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'}; @@ -224,6 +229,15 @@ static const char *compare_line(const char *out_line, const char *out_end, const } else { err = out_end; } + }else if(exp_ptr+sizeof(spaces_cmd) <= exp_end + && !memcmp(exp_ptr, spaces_cmd, sizeof(spaces_cmd))) { + exp_ptr += sizeof(spaces_cmd); + if(out_ptr < out_end && *out_ptr == ' ') { + while (out_ptr < out_end && *out_ptr == ' ') out_ptr++; + continue; + } else { + err = out_end; + } }else if(exp_ptr+sizeof(tab_cmd) <= exp_end && !memcmp(exp_ptr, tab_cmd, sizeof(tab_cmd))) { exp_ptr += sizeof(tab_cmd); @@ -251,10 +265,8 @@ static const char *compare_line(const char *out_line, const char *out_end, const while(exp_ptr+sizeof(or_broken_cmd) <= exp_end && memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) exp_ptr++; - if(!exp_ptr) - return err; - exp_ptr += sizeof(or_broken_cmd); + if (exp_ptr > exp_end) return err; out_ptr = out_line; err = NULL; continue; @@ -470,8 +482,7 @@ START_TEST(reactos) } else { path_len = 1; /* \ */ } - shortpath_len = GetShortPathNameA(path, shortpath, - sizeof(shortpath)/sizeof(shortpath[0])); + shortpath_len = GetShortPathNameA(path, shortpath, ARRAY_SIZE(shortpath)); argc = winetest_get_mainargs(&argv); if(argc > 2)