substitute a word or phrase in a string (in place); caller is responsible for ensuring that bp points to big enough buffer */
| 533 | /* substitute a word or phrase in a string (in place); |
| 534 | caller is responsible for ensuring that bp points to big enough buffer */ |
| 535 | char * |
| 536 | strsubst( |
| 537 | char *bp, |
| 538 | const char *orig, |
| 539 | const char *replacement) |
| 540 | { |
| 541 | char *found, buf[BUFSZ]; |
| 542 | /* [this could be replaced by strNsubst(bp, orig, replacement, 1)] */ |
| 543 | |
| 544 | found = strstr(bp, orig); |
| 545 | if (found) { |
| 546 | Strcpy(buf, found + strlen(orig)); |
| 547 | Strcpy(found, replacement); |
| 548 | Strcat(bp, buf); |
| 549 | } |
| 550 | return bp; |
| 551 | } |
| 552 | |
| 553 | /* substitute the Nth occurrence of a substring within a string (in place); |
| 554 | if N is 0, substitute all occurrences; returns the number of substitutions; |
no outgoing calls
no test coverage detected