diff options
author | Norbert Preining <norbert@preining.info> | 2020-11-24 03:01:06 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-11-24 03:01:06 +0000 |
commit | 55c6d66f61a96ba63cd8c141229843ad2ab42632 (patch) | |
tree | 64fa3f4bc82828c2475a6a25d23a02cb36502b95 /graphics/asymptote/runstring.in | |
parent | f0be59ccfa7046c57199fe35c49e1e8963fcb1a9 (diff) |
CTAN sync 202011240301
Diffstat (limited to 'graphics/asymptote/runstring.in')
-rw-r--r-- | graphics/asymptote/runstring.in | 15 |
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(); } |