All pastes #189210 Raw Edit

Something

public c v1 · immutable
·published 2006-10-02 22:12 UTC
rendered paste body
strreplace(trg[],newstr[],src[]) { new f=0; new s1[MAX_STRING]; new tmp[MAX_STRING]; set(s1,src); f = strfind(s1,trg); tmp[0]=0; while (f>=0)    {		strcat(tmp,ret_memcpy(s1, 0, f));		strcat(tmp,newstr);		s1=ret_memcpy(s1, f+strlen(trg), strlen(s1)-f);        f = strfind(s1,trg);    } strcat(tmp,s1); return tmp;}strrest(const string[], index){	new length = strlen(string);	new offset = index;	new result[256];	while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))	{		result[index - offset] = string[index];		index++;	}	result[index - offset] = EOS;	return result;}