mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
moved str_skip_to_whitespace function
This commit is contained in:
parent
8ca6a28088
commit
af56496281
|
@ -1146,6 +1146,13 @@ void str_sanitize(char *str_in)
|
|||
}
|
||||
}
|
||||
|
||||
char *str_skip_to_whitespace(char *str)
|
||||
{
|
||||
while(*str && (*str != ' ' && *str != '\t' && *str != '\n'))
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
char *str_skip_whitespaces(char *str)
|
||||
{
|
||||
while(*str && (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r'))
|
||||
|
|
|
@ -756,6 +756,22 @@ void str_sanitize_cc(char *str);
|
|||
*/
|
||||
void str_sanitize(char *str);
|
||||
|
||||
/*
|
||||
Function: str_skip_to_whitespace
|
||||
Skips leading non-whitespace characters(all but ' ', '\t', '\n', '\r').
|
||||
|
||||
Parameters:
|
||||
str - Pointer to the string.
|
||||
|
||||
Returns:
|
||||
Pointer to the first whitespace character found
|
||||
within the string.
|
||||
|
||||
Remarks:
|
||||
- The strings are treated as zero-termineted strings.
|
||||
*/
|
||||
char *str_skip_to_whitespace(char *str);
|
||||
|
||||
/*
|
||||
Function: str_skip_whitespaces
|
||||
Skips leading whitespace characters(' ', '\t', '\n', '\r').
|
||||
|
|
|
@ -29,12 +29,6 @@ float CConsole::CResult::GetFloat(unsigned Index)
|
|||
}
|
||||
|
||||
// the maximum number of tokens occurs in a string of length CONSOLE_MAX_STR_LENGTH with tokens size 1 separated by single spaces
|
||||
static char *SkipToBlank(char *pStr)
|
||||
{
|
||||
while(*pStr && (*pStr != ' ' && *pStr != '\t' && *pStr != '\n'))
|
||||
pStr++;
|
||||
return pStr;
|
||||
}
|
||||
|
||||
|
||||
int CConsole::ParseStart(CResult *pResult, const char *pString, int Length)
|
||||
|
@ -50,7 +44,7 @@ int CConsole::ParseStart(CResult *pResult, const char *pString, int Length)
|
|||
// get command
|
||||
pStr = str_skip_whitespaces(pStr);
|
||||
pResult->m_pCommand = pStr;
|
||||
pStr = SkipToBlank(pStr);
|
||||
pStr = str_skip_to_whitespace(pStr);
|
||||
|
||||
if(*pStr)
|
||||
{
|
||||
|
@ -133,11 +127,11 @@ int CConsole::ParseArgs(CResult *pResult, const char *pFormat)
|
|||
if(Command == 'r') // rest of the string
|
||||
break;
|
||||
else if(Command == 'i') // validate int
|
||||
pStr = SkipToBlank(pStr);
|
||||
pStr = str_skip_to_whitespace(pStr);
|
||||
else if(Command == 'f') // validate float
|
||||
pStr = SkipToBlank(pStr);
|
||||
pStr = str_skip_to_whitespace(pStr);
|
||||
else if(Command == 's') // validate string
|
||||
pStr = SkipToBlank(pStr);
|
||||
pStr = str_skip_to_whitespace(pStr);
|
||||
|
||||
if(pStr[0] != 0) // check for end of string
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue