substitute macro arguments by replacements in buf of bufsize. returns an error message or NULL. if used is defined, returns the used macro arguments. */
| 408 | if used is defined, returns the used macro arguments. |
| 409 | */ |
| 410 | static const char *substitute_macro_args( |
| 411 | char *buf, |
| 412 | int bufsize, |
| 413 | const ap_macro_t * macro, |
| 414 | const apr_array_header_t * replacements, |
| 415 | apr_array_header_t * used) |
| 416 | { |
| 417 | char *ptr = buf, |
| 418 | **atab = (char **) macro->arguments->elts, |
| 419 | **rtab = (char **) replacements->elts; |
| 420 | int whichone = -1; |
| 421 | |
| 422 | if (used) { |
| 423 | ap_assert(used->nalloc >= replacements->nelts); |
| 424 | } |
| 425 | debug(fprintf(stderr, "1# %s", buf)); |
| 426 | |
| 427 | while ((ptr = next_substitution(ptr, macro->arguments, &whichone))) { |
| 428 | const char *errmsg = substitute(ptr, buf - ptr + bufsize, |
| 429 | atab[whichone], rtab[whichone], |
| 430 | atab[whichone][0] == ESCAPE_ARG); |
| 431 | if (errmsg) { |
| 432 | return errmsg; |
| 433 | } |
| 434 | ptr += strlen(rtab[whichone]); |
| 435 | if (used) { |
| 436 | used->elts[whichone] = 1; |
| 437 | } |
| 438 | } |
| 439 | debug(fprintf(stderr, "2# %s", buf)); |
| 440 | |
| 441 | return NULL; |
| 442 | } |
| 443 | |
| 444 | /* |
| 445 | perform substitutions in a macro contents and |
no test coverage detected