From f7b7fb97d687e35422e32b018a4a887a2e3e53ef Mon Sep 17 00:00:00 2001 From: philippelatulippe Date: Sun, 24 Apr 2011 00:17:03 -0400 Subject: [PATCH] Fixes tab completion in the console --- .../Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp index 95ba9a2f..779c3994 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp @@ -41,6 +41,7 @@ const Int32 pfConsoleEngine::fMaxNumParams = 16; static const char kTokenSeparators[] = " =\r\n\t,"; static const char kTokenGrpSeps[] = " =\r\n._\t,"; +//WARNING: Potentially increments the pointer passed to it. static char *console_strtok( char *&line, hsBool haveCommand ) { char *begin = line; @@ -461,6 +462,7 @@ hsBool pfConsoleEngine::FindPartialCmd( char *line, hsBool findAgain, hsBool pr static pfConsoleCmd *lastCmd = nil; static pfConsoleCmdGroup *lastGroup = nil, *lastParentGroup = nil; static char newStr[ 256 ]; + static char *originalLine = line; /// Repeat search @@ -525,13 +527,12 @@ hsBool pfConsoleEngine::FindPartialCmd( char *line, hsBool findAgain, hsBool pr if( preserveParams ) { /// Preserve the rest of the string after the matched command - ptr = strtok( nil, "\0" ); - if( ptr != nil ) - strcat( newStr, ptr ); + if( line != nil ) + strcat( newStr, line ); } // Copy back! - strcpy( line, newStr ); + strcpy( originalLine, newStr ); return true; }