James Woodcock : msvcrt: Gets() should handle EOF on stdin gracefully.
Alexandre Julliard
julliard at winehq.org
Wed Mar 7 17:14:06 CST 2018
Module: wine
Branch: master
Commit: 91c72ce7def5ccec3ea7f759111b0d6fb96d722b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=91c72ce7def5ccec3ea7f759111b0d6fb96d722b
Author: James Woodcock <james_woodcock at yahoo.co.uk>
Date: Tue Mar 6 22:16:28 2018 -0600
msvcrt: Gets() should handle EOF on stdin gracefully.
Signed-off-by: James Woodcock <james_woodcock at yahoo.co.uk>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/file.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 7022e48..6b295cf 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -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;
}
More information about the wine-cvs
mailing list