|
Lines 578-588
Link Here
|
| 578 |
if (keys[num_keys].repl == NULL) |
578 |
if (keys[num_keys].repl == NULL) |
| 579 |
fatal("percent_expand: NULL replacement"); |
579 |
fatal("percent_expand: NULL replacement"); |
| 580 |
} |
580 |
} |
| 581 |
va_end(ap); |
|
|
| 582 |
|
581 |
|
| 583 |
if (num_keys >= EXPAND_MAX_KEYS) |
582 |
/* |
|
|
583 |
* If num_keys is equal to EXPAND_MAX_KEYS we must surely have at least |
| 584 |
* the terminating NULL on the stack. |
| 585 |
*/ |
| 586 |
if (num_keys == EXPAND_MAX_KEYS && va_arg(ap, char *) != NULL) |
| 584 |
fatal("percent_expand: too many keys"); |
587 |
fatal("percent_expand: too many keys"); |
| 585 |
|
588 |
|
|
|
589 |
va_end(ap); |
| 590 |
|
| 586 |
/* Expand string */ |
591 |
/* Expand string */ |
| 587 |
*buf = '\0'; |
592 |
*buf = '\0'; |
| 588 |
for (i = 0; *string != '\0'; string++) { |
593 |
for (i = 0; *string != '\0'; string++) { |
|
Lines 595-600
Link Here
|
| 595 |
continue; |
600 |
continue; |
| 596 |
} |
601 |
} |
| 597 |
string++; |
602 |
string++; |
|
|
603 |
/* %% case */ |
| 598 |
if (*string == '%') |
604 |
if (*string == '%') |
| 599 |
goto append; |
605 |
goto append; |
| 600 |
for (j = 0; j < num_keys; j++) { |
606 |
for (j = 0; j < num_keys; j++) { |
|
Lines 605-611
Link Here
|
| 605 |
break; |
611 |
break; |
| 606 |
} |
612 |
} |
| 607 |
} |
613 |
} |
| 608 |
if (j >= num_keys) |
614 |
if (j == num_keys) |
| 609 |
fatal("percent_expand: unknown key %%%c", *string); |
615 |
fatal("percent_expand: unknown key %%%c", *string); |
| 610 |
} |
616 |
} |
| 611 |
return (xstrdup(buf)); |
617 |
return (xstrdup(buf)); |