Index: base/shell/cmd/console.c =================================================================== --- base/shell/cmd/console.c (révision 67011) +++ base/shell/cmd/console.c (copie de travail) @@ -137,15 +137,19 @@ static VOID ConWrite(TCHAR *str, DWORD len, DWORD nStdHandle) { - DWORD dwWritten; + DWORD dwNumBytes = 0; HANDLE hOutput = GetStdHandle(nStdHandle); PVOID p; + /* If we don't write anything, just return */ + if (!str || len == 0) + return; + /* Check whether we are writing to a console and if so, write to it */ if (IsConsoleHandle(hOutput)) { - if (WriteConsole(hOutput, str, len, &dwWritten, NULL)) - return; + WriteConsole(hOutput, str, len, &dwNumBytes, NULL); + return; } /* We're writing to a file or pipe instead of the console. Convert the @@ -170,24 +174,28 @@ * * This fixes output in files and serial console. */ - while (str && *(PWCHAR)str && len > 0) + while (len > 0) { - p = wcspbrk((PWCHAR)str, L"\r\n"); - if (p) + /* Find the next possible \r or \n */ + p = str; + while (*(PWCHAR)p != L'\r' && *(PWCHAR)p != L'\n' && len > 0) { - len -= ((PWCHAR)p - (PWCHAR)str) + 1; - WriteFile(hOutput, str, ((PWCHAR)p - (PWCHAR)str) * sizeof(WCHAR), &dwWritten, NULL); - WriteFile(hOutput, L"\r\n", 2 * sizeof(WCHAR), &dwWritten, NULL); - str = (PVOID)((PWCHAR)p + 1); + p = (PVOID)((PWCHAR)p + 1); + len--; } - else + dwNumBytes = ((PWCHAR)p - (PWCHAR)str) * sizeof(WCHAR); + WriteFile(hOutput, str, dwNumBytes, &dwNumBytes, NULL); + + // if (len > 0) + if (*(PWCHAR)p == L'\r' || *(PWCHAR)p == L'\n') { - WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); - break; + WriteFile(hOutput, L"\r\n", 2 * sizeof(WCHAR), &dwNumBytes, NULL); + str = (PVOID)((PWCHAR)p + 1); + len--; } } - // WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); + // WriteFile(hOutput, str, len * sizeof(WCHAR), &dwNumBytes, NULL); #ifndef _UNICODE cmd_free(buffer); #endif @@ -212,24 +220,28 @@ * * This fixes output in files and serial console. */ - while (str && *(PCHAR)str && len > 0) + while (len > 0) { - p = strpbrk((PCHAR)str, "\r\n"); - if (p) + /* Find the next possible \r or \n */ + p = str; + while (*(PCHAR)p != '\r' && *(PCHAR)p != '\n' && len > 0) { - len -= ((PCHAR)p - (PCHAR)str) + 1; - WriteFile(hOutput, str, ((PCHAR)p - (PCHAR)str), &dwWritten, NULL); - WriteFile(hOutput, "\r\n", 2, &dwWritten, NULL); - str = (PVOID)((PCHAR)p + 1); + p = (PVOID)((PCHAR)p + 1); + len--; } - else + dwNumBytes = ((PCHAR)p - (PCHAR)str) * sizeof(CHAR); + WriteFile(hOutput, str, dwNumBytes, &dwNumBytes, NULL); + + // if (len > 0) + if (*(PCHAR)p == '\r' || *(PCHAR)p == '\n') { - WriteFile(hOutput, str, len, &dwWritten, NULL); - break; + WriteFile(hOutput, "\r\n", 2, &dwNumBytes, NULL); + str = (PVOID)((PCHAR)p + 1); + len--; } } - // WriteFile(hOutput, str, len, &dwWritten, NULL); + // WriteFile(hOutput, str, len, &dwNumBytes, NULL); #ifdef _UNICODE cmd_free(buffer); #endif Index: base/shell/cmd/parser.c =================================================================== --- base/shell/cmd/parser.c (révision 67001) +++ base/shell/cmd/parser.c (copie de travail) @@ -762,6 +762,18 @@ ConOutPrintf(_T("%s"), Buf); if (SubstituteForVars(Cmd->Command.Rest, Buf)) ConOutPrintf(_T("%s"), Buf); + + // Wine "I-don't-know-what-I'm-doing-but-I-copy" hack... + // (from programs/cmd/wcmdmain.c!WCMD_ReadAndParseLine line 1861) + + /* I don't know why Windows puts a space here but it does */ + /* Except for lines starting with 'echo.' or 'echo:'. Ask MS why */ + if (_tcsnicmp(Cmd->Command.First, _T("echo."), 5) != 0 && + _tcsnicmp(Cmd->Command.First, _T("echo:"), 5) != 0) + { + ConOutChar(_T(' ')); + } + break; case C_QUIET: return;