MCPcopy Create free account
hub / github.com/apache/httpd / next_substitution

Function next_substitution

modules/core/mod_macro.c:384–403  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

382 returns the pointer and the whichone found, or NULL.
383*/
384static 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.

Callers 1

substitute_macro_argsFunction · 0.85

Calls 1

ap_strstrFunction · 0.85

Tested by

no test coverage detected