summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-09-15 20:19:25 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-09-15 20:19:25 +0000
commitbcb5b3db5f7c1c690f21b8be6e7537a9ab1e1ffb (patch)
treec9087d4a90f87da4358edf574b780458edda2658
parentd6ffc9b18df070c83164ac6a50c03dd2e7b5ce46 (diff)
downloadfpc-bcb5b3db5f7c1c690f21b8be6e7537a9ab1e1ffb.tar.gz
* Patch from Mantis #20046 fixing an issue in rcmatchstring.
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@19072 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--packages/regexpr/src/regex.pp6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/regexpr/src/regex.pp b/packages/regexpr/src/regex.pp
index 9b21e4f158..da4b15d94f 100644
--- a/packages/regexpr/src/regex.pp
+++ b/packages/regexpr/src/regex.pp
@@ -542,10 +542,12 @@ var
Ch : AnsiChar;
State : integer;
StrInx : integer;
+ LenStr : integer;
begin
{assume we fail to match}
Result := false;
Len := StartPosn;
+ LenStr := Length(s);
{clear the deque}
FHead := FCapacity div 2;
FTail := FHead;
@@ -628,14 +630,14 @@ begin
end;
end;
end;
- until (FHead = FTail) or (ch = #0); // deque empty or end of string
+ until (FHead = FTail) or (StrInx > LenStr); // deque empty or end of string
{if we reach this point we've either exhausted the deque or we've
run out of string; if the former, the substring did not match
since there are no more states. If the latter, we need to check
the states left on the deque to see if one is the terminating
state; if so the string matched the regular expression defined by
the transition table}
- while (FHead <> FTail) do begin
+ while (FHead <> FTail) and (StrInx<=LenStr) do begin
State := DequePop;
with FStateTable[State] do begin
case sdMatchType of