find first occurrence of args in buf. in case of conflict, the LONGEST argument is kept. (could be the FIRST?). returns the pointer and the whichone found, or NULL. */
| 382 | returns the pointer and the whichone found, or NULL. |
| 383 | */ |
| 384 | static char *next_substitution(const char *buf, |
| 385 | const apr_array_header_t * args, int *whichone) |
| 386 | { |
| 387 | char *chosen = NULL, **tab = (char **) args->elts; |
| 388 | size_t lchosen = 0; |
| 389 | int i; |
| 390 | |
| 391 | for (i = 0; i < args->nelts; i++) { |
| 392 | char *found = ap_strstr((char *) buf, tab[i]); |
| 393 | size_t lfound = strlen(tab[i]); |
| 394 | if (found && (!chosen || found < chosen || |
| 395 | (found == chosen && lchosen < lfound))) { |
| 396 | chosen = found; |
| 397 | lchosen = lfound; |
| 398 | *whichone = i; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | return chosen; |
| 403 | } |
| 404 | |
| 405 | /* |
| 406 | substitute macro arguments by replacements in buf of bufsize. |
no test coverage detected