From c5f9b66e51c89fa76a0b39d122ceaed8131ca75d Mon Sep 17 00:00:00 2001 From: pierre Date: Fri, 6 Apr 2012 15:15:48 +0000 Subject: [PATCH] * Fix bug in DelOptions leading to infinite loop:( git-svn-id: trunk@20721 - --- tests/utils/dotest.pp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/utils/dotest.pp b/tests/utils/dotest.pp index 1ab0b2f306..dc92146185 100644 --- a/tests/utils/dotest.pp +++ b/tests/utils/dotest.pp @@ -765,7 +765,7 @@ end; function DelOptions(Pattern, opts : string) : string; var currentopt : string; - optpos, endopt, endpos : longint; + optpos, endopt, startpos, endpos : longint; iswild : boolean; begin opts:=trimspace(opts); @@ -785,30 +785,41 @@ begin end else iswild:=false; + startpos:=1; repeat - optpos:=pos(currentopt,opts); + optpos:=pos(currentopt,copy(opts,startpos,length(opts))); if optpos>0 then begin + { move to index in full opts string } + optpos:=optpos+startpos-1; + { compute position of end of opt } endopt:=optpos+length(currentopt); + { use that end as start position for next round } + startpos:=endopt; if iswild then begin while (opts[endopt]<>' ') and (endoptlength(opts)) or (opts[endopt]=' ') then begin Verbose(V_Debug,'Exact match found "'+currentopt+'" in "'+opts+'"'); system.delete(opts,optpos,endopt-optpos+1); Verbose(V_Debug,'After opts="'+opts+'"'); end else - Verbose(V_Debug,'No exact match "'+currentopt+'" in "'+opts+'"'); + begin + Verbose(V_Debug,'No exact match "'+currentopt+'" in "'+opts+'"'); + end; end; end;