From ada0f8dfe8b49181123030790b33ed66631199ef Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sat, 3 Sep 2005 19:59:51 +0000 Subject: [PATCH] fix type can handler \n at text output thx ravelo for the small patch. see file misc.c. prompt.c fix the szParam so it have a buffer set. and do not use szParam for param, the param length can in future very big. when dymatic buffer be implement at command line. svn path=/trunk/; revision=17625 --- reactos/subsys/system/cmd/misc.c | 6 +++--- reactos/subsys/system/cmd/prompt.c | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/reactos/subsys/system/cmd/misc.c b/reactos/subsys/system/cmd/misc.c index 84a489bca84..289b69638f7 100644 --- a/reactos/subsys/system/cmd/misc.c +++ b/reactos/subsys/system/cmd/misc.c @@ -381,10 +381,10 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength) while ((--nBufferLength > 0) && ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead) { - if (ch == '\r') + if ((ch == '\n') || (ch == '\r')) { - /* overread '\n' */ - ReadFile (hFile, &ch, 1, &dwRead, NULL); + /* read it*/ + lpString[len++] = ch; break; } lpString[len++] = ch; diff --git a/reactos/subsys/system/cmd/prompt.c b/reactos/subsys/system/cmd/prompt.c index 71a76de0d8d..4ef8814a779 100644 --- a/reactos/subsys/system/cmd/prompt.c +++ b/reactos/subsys/system/cmd/prompt.c @@ -192,8 +192,7 @@ VOID PrintPrompt(VOID) #ifdef INCLUDE_CMD_PROMPT INT cmd_prompt (LPTSTR cmd, LPTSTR param) -{ - LPTSTR szParam; +{ if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_PROMPT_HELP1); @@ -210,15 +209,24 @@ INT cmd_prompt (LPTSTR cmd, LPTSTR param) so even if param is null you _must_ still set prompt to the default. There seems to be some kinda difference between winxp and 2k in this matter and this way will - cover both. */ + cover both. Do not use fixed size of szParam for param the buffer are 8192bytes + and will later change to dymatic buffer */ + + /* set PROMPT environment variable */ if (param[0] != _T('\0')) - _tcscpy(szParam,param); + { + if (!SetEnvironmentVariable (_T("PROMPT"), param)) + return 1; + } else + { + TCHAR szParam[5]; _tcscpy(szParam,_T("$P$G")); + if (!SetEnvironmentVariable (_T("PROMPT"),szParam)) + return 1; + } - /* set PROMPT environment variable */ - if (!SetEnvironmentVariable (_T("PROMPT"), szParam)) - return 1; + return 0; } -- 2.17.1