/* read in a command line */
-TCHAR * ReadCommand (LPTSTR str, INT maxlen)
+VOID ReadCommand (LPTSTR str, INT maxlen)
{
SHORT orgx; /* origin x/y */
SHORT orgy;
default:
#ifdef _UNICODE
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
- charcount ++;
- str = realloc(str, charcount);
-
- if ((ch >= 32 && ch <= 255))
+ if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
#else
- ch = ir.Event.KeyEvent.uChar.AsciiChar;
- str = realloc(str, 2 + current * sizeof(TCHAR));
-
- if ((UCHAR)ch >= 32 )
+ ch = ir.Event.KeyEvent.uChar.AsciiChar;
+ if ((UCHAR)ch >= 32 && (charcount != (maxlen - 2)))
#endif /* _UNICODE */
{
/* insert character into string... */
/* If this character insertion will cause screen scrolling,
* adjust the saved origin of the command prompt. */
tempscreen = _tcslen(str + current) + curx;
- str = realloc(str, tempscreen * sizeof(TCHAR));
-
if ((tempscreen % maxx) == (maxx - 1) &&
(tempscreen / maxx) + cury == (maxy - 1))
{
cury--;
}
-
-
for (count = charcount; count > current; count--)
str[count] = str[count - 1];
str[current++] = ch;
while (ir.Event.KeyEvent.wVirtualKeyCode != VK_RETURN);
SetCursorType (bInsert, TRUE);
-
- return str;
}