Commit 1cbe5608 authored by gerd's avatar gerd

Bugfix in 'Record' matching: the variable was not reset to

its old values in the case the matching fails.


git-svn-id: https://godirepo.camlcity.org/svn/lib-xstr/[email protected] e4cd5726-45db-0310-8eb3-84e3bb775810
parent 1726851c
(* $Id: xstr_match.ml,v 1.6 1999/07/06 21:29:33 gerd Exp $
(* $Id: xstr_match.ml,v 1.7 1999/07/08 02:41:10 gerd Exp $
* ----------------------------------------------------------------------
* String matching
*)
......@@ -335,15 +335,20 @@ let match_string_at ml s k =
if r.found then
failwith "string_match: the same variable matches twice";
if r.begun then begin (* ==> recorded = [] *)
let old_len = r.len in
r.found <- true;
r.len <- k - r.from;
run k ml' (r::recs)
run k ml' (r::recs);
r.found <- false;
r.len <- old_len
end
else begin
let old_from = r.from in
r.begun <- true;
r.from <- k;
run k (recorded @ (Record(r,[]) :: ml')) recs;
r.begun <- false;
r.from <- old_from
end
| Scanner f :: ml' ->
let n = f (String.sub s k (len-k)) in
......@@ -673,6 +678,10 @@ let mknegset s =
* History:
*
* $Log: xstr_match.ml,v $
* Revision 1.7 1999/07/08 02:41:10 gerd
* Bugfix in 'Record' matching: the variable was not reset to
* its old values in the case the matching fails.
*
* Revision 1.6 1999/07/06 21:29:33 gerd
* Optimizations in the 'replace_matched_substrings' function.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment