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
This commit is contained in:
Magnus Olsen 2005-09-03 19:59:51 +00:00
parent 040c539dd5
commit ada0f8dfe8
2 changed files with 19 additions and 11 deletions

View file

@ -381,10 +381,10 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
while ((--nBufferLength > 0) && while ((--nBufferLength > 0) &&
ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead) ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead)
{ {
if (ch == '\r') if ((ch == '\n') || (ch == '\r'))
{ {
/* overread '\n' */ /* read it*/
ReadFile (hFile, &ch, 1, &dwRead, NULL); lpString[len++] = ch;
break; break;
} }
lpString[len++] = ch; lpString[len++] = ch;

View file

@ -192,8 +192,7 @@ VOID PrintPrompt(VOID)
#ifdef INCLUDE_CMD_PROMPT #ifdef INCLUDE_CMD_PROMPT
INT cmd_prompt (LPTSTR cmd, LPTSTR param) INT cmd_prompt (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR szParam;
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
ConOutResPaging(TRUE,STRING_PROMPT_HELP1); 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 so even if param is null you _must_ still set prompt
to the default. There seems to be some kinda difference to the default. There seems to be some kinda difference
between winxp and 2k in this matter and this way will 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
if (param[0] != _T('\0')) and will later change to dymatic buffer */
_tcscpy(szParam,param);
else
_tcscpy(szParam,_T("$P$G"));
/* set PROMPT environment variable */ /* set PROMPT environment variable */
if (!SetEnvironmentVariable (_T("PROMPT"), szParam)) if (param[0] != _T('\0'))
{
if (!SetEnvironmentVariable (_T("PROMPT"), param))
return 1; return 1;
}
else
{
TCHAR szParam[5];
_tcscpy(szParam,_T("$P$G"));
if (!SetEnvironmentVariable (_T("PROMPT"),szParam))
return 1;
}
return 0; return 0;
} }