mirror of
https://github.com/anope/anope.git
synced 2026-07-07 14:23:13 +02:00
Merge (with small conflict) from upstream.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1177 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+4
-4
@@ -139,16 +139,16 @@ char *stristr(char *s1, char *s2)
|
||||
* @param s String
|
||||
* @param size size of s
|
||||
* @param old character to replace
|
||||
* @param new character to replace with
|
||||
* @param newstr character to replace with
|
||||
* @return updated s
|
||||
*/
|
||||
char *strnrepl(char *s, int32 size, const char *old, const char *new)
|
||||
char *strnrepl(char *s, int32 size, const char *old, const char *newstr)
|
||||
{
|
||||
char *ptr = s;
|
||||
int32 left = strlen(s);
|
||||
int32 avail = size - (left + 1);
|
||||
int32 oldlen = strlen(old);
|
||||
int32 newlen = strlen(new);
|
||||
int32 newlen = strlen(newstr);
|
||||
int32 diff = newlen - oldlen;
|
||||
|
||||
while (left >= oldlen) {
|
||||
@@ -161,7 +161,7 @@ char *strnrepl(char *s, int32 size, const char *old, const char *new)
|
||||
break;
|
||||
if (diff != 0)
|
||||
memmove(ptr + oldlen + diff, ptr + oldlen, left + 1 - oldlen);
|
||||
strncpy(ptr, new, newlen);
|
||||
strncpy(ptr, newstr, newlen);
|
||||
ptr += newlen;
|
||||
left -= oldlen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user