Skip to content
Snippets Groups Projects
Commit 1b6d6e50 authored by James Woodcock's avatar James Woodcock Committed by Michael Stefaniuc
Browse files

msvcrt: Gets() should handle EOF on stdin gracefully.


Signed-off-by: default avatarJames Woodcock <james_woodcock@yahoo.co.uk>
Signed-off-by: default avatarPiotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard's avatarAlexandre Julliard <julliard@winehq.org>
(cherry picked from commit 91c72ce7)
Signed-off-by: default avatarMichael Stefaniuc <mstefani@winehq.org>
parent e96dc46d
No related branches found
No related tags found
No related merge requests found
......@@ -4719,10 +4719,16 @@ char * CDECL MSVCRT_gets(char *buf)
if(cc != '\r')
*buf++ = (char)cc;
}
MSVCRT__unlock_file(MSVCRT_stdin);
if ((cc == MSVCRT_EOF) && (buf_start == buf))
{
TRACE(":nothing read\n");
return NULL;
}
*buf = '\0';
TRACE("got '%s'\n", buf_start);
MSVCRT__unlock_file(MSVCRT_stdin);
return buf_start;
}
......@@ -4741,10 +4747,16 @@ MSVCRT_wchar_t* CDECL MSVCRT__getws(MSVCRT_wchar_t* buf)
if (cc != '\r')
*buf++ = (MSVCRT_wchar_t)cc;
}
MSVCRT__unlock_file(MSVCRT_stdin);
if ((cc == MSVCRT_WEOF) && (ws == buf))
{
TRACE(":nothing read\n");
return NULL;
}
*buf = '\0';
TRACE("got %s\n", debugstr_w(ws));
MSVCRT__unlock_file(MSVCRT_stdin);
return ws;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment