forked from starnakin/IronGOLEM
16 lines
366 B
Plaintext
16 lines
366 B
Plaintext
replace(str, fill, start, stop)
|
|
{
|
|
local out;
|
|
local sum;
|
|
|
|
out = galloc(strlen(str) + strlen(fill) - (stop - start) + 1);
|
|
if (out == NULL)
|
|
return (NULL);
|
|
strncpy(out, str, start);
|
|
strncpy(out + start, fill, strlen(fill));
|
|
sum = start + strlen(fill);
|
|
strncpy(out + sum, str + stop, strlen(str) - stop);
|
|
[out + sum + strlen(str) - stop] = 0;
|
|
return (out);
|
|
}
|