| 364 | } |
| 365 | |
| 366 | int asCString::FindLast(const char *str, int *count) const |
| 367 | { |
| 368 | // There is no strstr that starts from the end, so |
| 369 | // we'll iterate until we find the last occurrance. |
| 370 | // This shouldn't cause a performance problem because |
| 371 | // it is not expected that this will be done very often, |
| 372 | // and then only on quite short strings anyway. |
| 373 | |
| 374 | if( count ) *count = 0; |
| 375 | |
| 376 | const char *last = 0; |
| 377 | const char *curr = AddressOf()-1; |
| 378 | while( (curr = strstr(curr+1, str)) != 0 ) |
| 379 | { |
| 380 | if( count ) (*count)++; |
| 381 | last = curr; |
| 382 | } |
| 383 | |
| 384 | if( last ) |
| 385 | return int(last - AddressOf()); |
| 386 | |
| 387 | return -1; |
| 388 | } |
| 389 | |
| 390 | //----------------------------------------------------------------------------- |
| 391 | // Helper functions |
no outgoing calls
no test coverage detected