mirror of
https://github.com/ioquake/jedi-academy.git
synced 2025-03-13 22:31:55 +00:00
add Cmd_TokenizeStringIgnoreQuotes modelled after ioquake3
This commit is contained in:
parent
8349abd8bb
commit
c9da283d84
2 changed files with 21 additions and 3 deletions
|
@ -395,7 +395,7 @@ are inserted in the apropriate place, The argv array
|
|||
will point into this temporary buffer.
|
||||
============
|
||||
*/
|
||||
void Cmd_TokenizeString( const char *text_in ) {
|
||||
void Cmd_TokenizeString2( const char *text_in, qboolean ignoreQuotes ) {
|
||||
const char *text;
|
||||
char *textOut;
|
||||
|
||||
|
@ -443,7 +443,8 @@ void Cmd_TokenizeString( const char *text_in ) {
|
|||
}
|
||||
|
||||
// handle quoted strings
|
||||
if ( *text == '"' ) {
|
||||
// NOTE TTimo this doesn't handle \" escaping
|
||||
if ( !ignoreQuotes && *text == '"' ) {
|
||||
cmd_argv[cmd_argc] = textOut;
|
||||
cmd_argc++;
|
||||
text++;
|
||||
|
@ -465,7 +466,7 @@ void Cmd_TokenizeString( const char *text_in ) {
|
|||
// skip until whitespace, quote, or command
|
||||
while ( *(const unsigned char* /*eurofix*/)text > ' ' )
|
||||
{
|
||||
if ( text[0] == '"' ) {
|
||||
if ( !ignoreQuotes && text[0] == '"' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -490,7 +491,23 @@ void Cmd_TokenizeString( const char *text_in ) {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cmd_TokenizeString
|
||||
============
|
||||
*/
|
||||
void Cmd_TokenizeString( const char *text_in ) {
|
||||
Cmd_TokenizeString2( text_in, qfalse );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cmd_TokenizeStringIgnoreQuotes
|
||||
============
|
||||
*/
|
||||
void Cmd_TokenizeStringIgnoreQuotes( const char *text_in ) {
|
||||
Cmd_TokenizeString2( text_in, qtrue );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
|
|
|
@ -387,6 +387,7 @@ void Cmd_ArgsBuffer( char *buffer, int bufferLength );
|
|||
// if arg > argc, so string operations are allways safe.
|
||||
|
||||
void Cmd_TokenizeString( const char *text );
|
||||
void Cmd_TokenizeStringIgnoreQuotes( const char *text );
|
||||
// Takes a null terminated string. Does not need to be /n terminated.
|
||||
// breaks the string up into arg tokens.
|
||||
|
||||
|
|
Loading…
Reference in a new issue