summaryrefslogtreecommitdiff
path: root/graphics/asymptote/runstring.in
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/runstring.in')
-rw-r--r--graphics/asymptote/runstring.in15
1 files changed, 9 insertions, 6 deletions
diff --git a/graphics/asymptote/runstring.in b/graphics/asymptote/runstring.in
index 915811c7ff..415db53652 100644
--- a/graphics/asymptote/runstring.in
+++ b/graphics/asymptote/runstring.in
@@ -181,9 +181,11 @@ string replace(string *S, stringarray2 *translate)
array *a=read<array*>(translate,i);
checkArray(a);
}
- const char *p=S->c_str();
+ size_t pos=0;
ostringstream buf;
- while(*p) {
+ size_t Len=S->length();
+
+ while(pos < Len) {
for(size_t i=0; i < size;) {
array *a=read<array*>(translate,i);
size_t size2=checkArray(a);
@@ -191,13 +193,14 @@ string replace(string *S, stringarray2 *translate)
error("translation table entry must be an array of length 2");
string* from=read<string*>(a,0);
size_t len=from->length();
- if(strncmp(p,from->c_str(),len) != 0) {i++; continue;}
+ if(len == 0 || S->compare(pos,len,*from,0,len) != 0) {i++; continue;}
buf << read<string>(a,1);
- p += len;
- if(*p == 0) return buf.str();
+ pos += len;
+ if(pos == Len) return buf.str();
i=0;
}
- buf << *(p++);
+ buf << S->substr(pos,1);
+ ++pos;
}
return buf.str();
}