Fixed bug in string replace.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@543 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c39862ce01
commit
8f0e034cf2
1 changed files with 3 additions and 0 deletions
|
|
@ -332,6 +332,7 @@ String_write(DOH *so, void *buffer, int len) {
|
||||||
int newlen;
|
int newlen;
|
||||||
String *s = (String *) ObjData(so);
|
String *s = (String *) ObjData(so);
|
||||||
s->hashkey = -1;
|
s->hashkey = -1;
|
||||||
|
if (s->sp > s->len) s->sp = s->len;
|
||||||
newlen = s->sp + len+1;
|
newlen = s->sp + len+1;
|
||||||
if (newlen > s->maxsize) {
|
if (newlen > s->maxsize) {
|
||||||
s->str = (char *) DohRealloc(s->str,newlen);
|
s->str = (char *) DohRealloc(s->str,newlen);
|
||||||
|
|
@ -599,6 +600,7 @@ int replace_simple(String *str, char *token, char *rep, int flags, int count, ch
|
||||||
memmove(t,s,(str->str + str->len) - s + 1);
|
memmove(t,s,(str->str + str->len) - s + 1);
|
||||||
}
|
}
|
||||||
str->len += expand;
|
str->len += expand;
|
||||||
|
if (str->sp >= str->len) str->sp += expand; /* Fix the end of file pointer */
|
||||||
return rcount;
|
return rcount;
|
||||||
}
|
}
|
||||||
/* The string is expanding as a result of the replacement */
|
/* The string is expanding as a result of the replacement */
|
||||||
|
|
@ -687,6 +689,7 @@ int replace_simple(String *str, char *token, char *rep, int flags, int count, ch
|
||||||
}
|
}
|
||||||
c = str->str;
|
c = str->str;
|
||||||
str->str = ns;
|
str->str = ns;
|
||||||
|
if (str->sp >= str->len) str->sp += expand;
|
||||||
str->len += expand;
|
str->len += expand;
|
||||||
str->maxsize = newsize;
|
str->maxsize = newsize;
|
||||||
DohFree(c);
|
DohFree(c);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue