[PATCH 1/2] cmd: Use terminated strings in WCMD_ReadAndParseLine()

Hugh McMaster hugh.mcmaster at outlook.com
Mon Apr 12 01:16:51 CDT 2021


On Mon, 12 Apr 2021 02:22:36 +0200, Gijs Vermeulen wrote:

> @@ -1870,10 +1865,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
>
>      /* Show prompt before batch line IF echo is on and in batch program */
>      if (context && echo_mode && *curPos && (*curPos != '@')) {
> -      static const WCHAR echoDot[] = {'e','c','h','o','.'};
> -      static const WCHAR echoCol[] = {'e','c','h','o',':'};
> -      static const WCHAR echoSlash[] = {'e','c','h','o','/'};
> -      const DWORD len = ARRAY_SIZE(echoDot);
> +      const DWORD len = ARRAY_SIZE(L"echo.") - 1;

This is very unusual. Why not just use lstrlenW(...)?

You should also look at calculating the string length within
WCMD_keyword_ws_found(), instead of passing the length as an argument.
But do this as a separate patch.

--
Hugh McMaster



More information about the wine-devel mailing list