From e3eb0464883d2582eb3d91640fbd2bf8147c0ac7 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 5 Mar 2012 14:28:42 +0000 Subject: [PATCH] codetools: clean up git-svn-id: trunk@35734 - --- components/codetools/basiccodetools.pas | 42 +++++++++++++------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 7e891a0ec0..11a90f82e2 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -5018,30 +5018,32 @@ begin if (Txt=nil) or (Txt^=#0) then exit; TxtRun:=Txt; StartChar:=SearchWord^; - repeat - while (TxtRun^<>StartChar) and (TxtRun^<>#0) do inc(TxtRun); - if TxtRun^=#0 then exit; - CurSearchP:=SearchWord+1; - CurTxtP:=TxtRun+1; - while (CurTxtP^=CurSearchP^) and (CurTxtP^<>#0) do begin - inc(CurTxtP); - inc(CurSearchP); - end; - if CurSearchP^=#0 then begin - // word found - if ((TxtRun=Txt) or IsNonWordChar[TxtRun[-1]]) - and IsNonWordChar[CurTxtP^] then begin - // word boundaries - if not WholeWord then begin - WholeWord:=true; - Count:=1; + while TxtRun^<>#0 do begin + if TxtRun^=StartChar then begin + CurSearchP:=SearchWord+1; + CurTxtP:=TxtRun+1; + while (CurTxtP^=CurSearchP^) and (CurTxtP^<>#0) do begin + inc(CurTxtP); + inc(CurSearchP); + end; + if CurSearchP^=#0 then begin + // word found + if ((TxtRun=Txt) or IsNonWordChar[TxtRun[-1]]) + and IsNonWordChar[CurTxtP^] then begin + // word boundaries + if not WholeWord then begin + WholeWord:=true; + Count:=1; + end else + inc(Count); end else inc(Count); - end else - inc(Count); + TxtRun:=CurTxtP; + continue; + end; end; inc(TxtRun); - until false; + end; end; function SubString(p: PChar; Count: SizeInt): string;