Commit c46dddee authored by gerd's avatar gerd

Fixed Xstr_match.mkset


git-svn-id: https://godirepo.camlcity.org/svn/lib-xstr/[email protected] e4cd5726-45db-0310-8eb3-84e3bb775810
parent d56bdf01
version = "0.2"
version = "0.2.1"
requires = ""
archive(byte) = "xstr.cma"
archive(native) = "xstr.cmxa"
......
(* $Id: xstr_match.ml,v 1.8 2000/09/23 13:43:22 gerd Exp $
(* $Id: xstr_match.ml,v 1.9 2002/07/07 11:27:16 gerd Exp $
* ----------------------------------------------------------------------
* String matching
*)
......@@ -203,16 +203,16 @@ let match_string_at ml s k =
let xlen = String.length x in
begin match xlen with
0 -> run k ml' recs
| 1 -> if k+1 <= len & s.[k] = x.[0] then run (k+1) ml' recs
| 2 -> if k+2 <= len & s.[k] = x.[0] & s.[k+1] = x.[1] then
| 1 -> if k+1 <= len && s.[k] = x.[0] then run (k+1) ml' recs
| 2 -> if k+2 <= len && s.[k] = x.[0] && s.[k+1] = x.[1] then
run (k+2) ml' recs
| 3 -> if k+3 <= len & s.[k] = x.[0] & s.[k+1] = x.[1] &
| 3 -> if k+3 <= len && s.[k] = x.[0] && s.[k+1] = x.[1] &&
s.[k+2] = x.[2] then
run (k+3) ml' recs
| 4 -> if k+4 <= len & s.[k] = x.[0] & s.[k+1] = x.[1] &
s.[k+2] = x.[2] & s.[k+3] = x.[3] then
| 4 -> if k+4 <= len && s.[k] = x.[0] && s.[k+1] = x.[1] &&
s.[k+2] = x.[2] && s.[k+3] = x.[3] then
run (k+4) ml' recs
| _ -> if k + xlen <= len & String.sub s k xlen = x then
| _ -> if k + xlen <= len && String.sub s k xlen = x then
run (k+xlen) ml' recs
(* this is still not optimal *)
end
......@@ -465,7 +465,7 @@ let replace_matched_substrings ml rl fl s =
let n_repl = ref 0 in
let replace_at k =
if limit >= 0 & !n_repl >= limit then
if limit >= 0 && !n_repl >= limit then
[], (-1)
else begin
List.iter
......@@ -640,16 +640,11 @@ let mkset s =
in
let continue = ref true in
let first = ref true in (* the character after [ or [^ ? *)
next_noesc();
while !continue & !k < l do
while !continue && !k < l do
match () with
() when !c = '[' & !k + 1 < l & s.[!k + 1] = ':' ->
failwith "mkset: Character classes such as [[:digit:]] not implemented";
(* TODO: check for predefined sets *)
| () when (!k + 2 < l) & (s.[!k + 1] = '-') & (s.[!k + 2] <> ']') ->
| () when (!k + 2 < l) && (s.[!k + 1] = '-') ->
(* range *)
......@@ -657,12 +652,10 @@ let mkset s =
next_noesc();
next_noesc();
next_noesc();
first := false;
| () ->
add_char !c;
next_noesc();
first := false;
done;
set
......@@ -678,6 +671,9 @@ let mknegset s =
* History:
*
* $Log: xstr_match.ml,v $
* Revision 1.9 2002/07/07 11:27:16 gerd
* Fixed Xstr_match.mkset
*
* Revision 1.8 2000/09/23 13:43:22 gerd
* Bugfix in replace_matched_substrings.
*
......
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