[1/3] cmd: Avoid reading char by char from console (try 2)

Alexandre Julliard julliard at winehq.org
Wed Sep 28 05:16:43 CDT 2011


Frédéric Delanoy <frederic.delanoy at gmail.com> writes:

> @@ -181,13 +181,21 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end) {
>   * the LF (or CRLF) from the line.
>   */
>  
> -WCHAR *WCMD_fgets (WCHAR *s, int noChars, HANDLE h) {
> -
> -  DWORD bytes;
> -  BOOL status;
> +WCHAR *WCMD_fgets (WCHAR *s, int noChars, HANDLE h)
> +{
> +  DWORD bytes, charsRead, dummy;
> +  BOOL status, is_console_handle;
>    WCHAR *p;
>  
>    p = s;
> +  is_console_handle = !!GetConsoleMode(h, &dummy);
> +  if (is_console_handle) {
> +    status = ReadConsoleW(h, s, noChars, &charsRead, NULL);

ReadConsole will fail if it's not a console, the check is redundant.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list