| 367 | } |
| 368 | |
| 369 | void V_SplitString2( const char *pString, const char * const *pSeparators, int nSeparators, CUtlVector<char*> &outStrings, bool bIncludeEmptyStrings ) |
| 370 | { |
| 371 | outStrings.Purge(); |
| 372 | const char *pCurPos = pString; |
| 373 | for (;;) |
| 374 | { |
| 375 | int iFirstSeparator = -1; |
| 376 | const char *pFirstSeparator = 0; |
| 377 | for ( int i=0; i < nSeparators; i++ ) |
| 378 | { |
| 379 | const char *pTest = V_stristr( pCurPos, pSeparators[i] ); |
| 380 | if ( pTest && (!pFirstSeparator || pTest < pFirstSeparator) ) |
| 381 | { |
| 382 | iFirstSeparator = i; |
| 383 | pFirstSeparator = pTest; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | if ( pFirstSeparator ) |
| 388 | { |
| 389 | // Split on this separator and continue on. |
| 390 | int separatorLen = (int)strlen( pSeparators[iFirstSeparator] ); |
| 391 | if ( pFirstSeparator > pCurPos || ( pFirstSeparator == pCurPos && bIncludeEmptyStrings ) ) |
| 392 | { |
| 393 | outStrings.AddToTail( AllocString( pCurPos, pFirstSeparator-pCurPos ) ); |
| 394 | } |
| 395 | |
| 396 | pCurPos = pFirstSeparator + separatorLen; |
| 397 | } |
| 398 | else |
| 399 | { |
| 400 | // Copy the rest of the string, if there's anything there |
| 401 | if ( pCurPos[0] != 0 ) |
| 402 | { |
| 403 | outStrings.AddToTail( AllocString( pCurPos, -1 ) ); |
| 404 | } |
| 405 | else if (bIncludeEmptyStrings && pCurPos > pString) |
| 406 | { |
| 407 | outStrings.AddToTail( AllocString( "" , 1 )); |
| 408 | } |
| 409 | return; |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | void V_AllocAndSplitString( const char *pString, const char *pSeparator, CUtlVector<char*> &outStrings, bool bIncludeEmptyStrings ) |
| 415 | { |
no test coverage detected