Frédéric Delanoy frederic.delanoy@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.
2011/9/28 Alexandre Julliard julliard@winehq.org:
Frédéric Delanoy frederic.delanoy@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.
Yes, but it can fail for other reasons as well. If it really is a console handle, but ReadConsoleW fails, isn't it better to return failure early rather than trying to read from (assumed) file handle h?
Frédéric
Frédéric Delanoy frederic.delanoy@gmail.com writes:
Yes, but it can fail for other reasons as well. If it really is a console handle, but ReadConsoleW fails, isn't it better to return failure early rather than trying to read from (assumed) file handle h?
It probably doesn't matter much, but you can always check last error or something like that.