cmd: Don't use WCMD_is_console_handle.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-12-01 17:25:25 +01:00 committed by Alexandre Julliard
parent 54035a2101
commit 2ecb871310
3 changed files with 4 additions and 10 deletions

View File

@ -249,7 +249,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
/* We can't use the native f* functions because of the filename syntax differences
between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
if (!WCMD_is_console_handle(h)) {
if (!ReadConsoleW(h, buf, noChars, &charsRead, NULL)) {
LARGE_INTEGER filepos;
char *bufA;
UINT cp;
@ -282,8 +282,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
heap_free(bufA);
}
else {
status = WCMD_ReadFile(h, buf, noChars, &charsRead);
if (!status || charsRead == 0) return NULL;
if (!charsRead) return NULL;
/* Find first EOL */
for (i = 0; i < charsRead; i++) {

View File

@ -105,10 +105,6 @@ void WCMD_version (void);
int WCMD_volume (BOOL set_label, const WCHAR *args);
void WCMD_mklink(WCHAR *args);
static inline BOOL WCMD_is_console_handle(HANDLE h)
{
return (((DWORD_PTR)h) & 3) == 3;
}
WCHAR *WCMD_fgets (WCHAR *buf, DWORD n, HANDLE stream);
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, BOOL raw, BOOL wholecmdline);
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, BOOL raw,

View File

@ -221,9 +221,8 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, LPDWO
DWORD numRead;
char *buffer;
if (WCMD_is_console_handle(hIn))
/* Try to read from console as Unicode */
return ReadConsoleW(hIn, intoBuf, maxChars, charsRead, NULL);
/* Try to read from console as Unicode */
if (ReadConsoleW(hIn, intoBuf, maxChars, charsRead, NULL)) return TRUE;
/* We assume it's a file handle and read then convert from assumed OEM codepage */
if (!(buffer = get_file_buffer()))