MCPcopy Index your code
hub / github.com/NetHack/NetHack / strsubst

Function strsubst

src/hacklib.c:535–551  ·  view source on GitHub ↗

substitute a word or phrase in a string (in place); caller is responsible for ensuring that bp points to big enough buffer */

Source from the content-addressed store, hash-verified

533/* substitute a word or phrase in a string (in place);
534 caller is responsible for ensuring that bp points to big enough buffer */
535char *
536strsubst(
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;

Callers 15

aboutMsgFunction · 0.85
optfn_perminv_modeFunction · 0.85
submit_web_reportFunction · 0.85
NH_panictrace_libcFunction · 0.85
disco_typenameFunction · 0.85
worn_item_removalFunction · 0.85
wielding_corpseFunction · 0.85
poly_steedFunction · 0.85
wishymatchFunction · 0.85
readobjnam_preparseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected