diff -r -c xstr/Makefile xstr.modern/Makefile
*** xstr/Makefile	Thu Jul  8 04:51:39 1999
--- xstr.modern/Makefile	Wed Jan 26 13:27:36 2000
***************
*** 35,42 ****
  # general rules:
  
  OPTIONS   =
! OCAMLC    = ocamlc $(UNSAFE) $(OPTIONS) $(ROPTIONS)
! OCAMLOPT  = ocamlopt $(UNSAFE) $(OPTIONS) $(ROPTIONS)
  OCAMLDEP  = ocamldep $(OPTIONS)
  OCAMLFIND = ocamlfind
  
--- 35,42 ----
  # general rules:
  
  OPTIONS   =
! OCAMLC    = ocamlc -modern $(UNSAFE) $(OPTIONS) $(ROPTIONS)
! OCAMLOPT  = ocamlopt -modern $(UNSAFE) $(OPTIONS) $(ROPTIONS)
  OCAMLDEP  = ocamldep $(OPTIONS)
  OCAMLFIND = ocamlfind
  
Only in xstr.modern: Makefile~
Only in xstr.modern: depend
Only in xstr.modern: xstr.cma
Only in xstr.modern: xstr_match.cmi
Only in xstr.modern: xstr_match.cmo
diff -r -c xstr/xstr_match.ml xstr.modern/xstr_match.ml
*** xstr/xstr_match.ml	Thu Jul  8 11:41:10 1999
--- xstr.modern/xstr_match.ml	Wed Jan 26 13:39:35 2000
***************
*** 39,46 ****
  
  (* copied from the JavaCaml regexp implementation *)
  
! let the_full_set = Array.create 16 0xffff;;
! let the_empty_set = Array.create 16 0;;
  
  let dup_set s =
    Array.copy s
--- 39,46 ----
  
  (* copied from the JavaCaml regexp implementation *)
  
! let the_full_set = Array.create len: 16 0xffff;;
! let the_empty_set = Array.create len: 16 0;;
  
  let dup_set s =
    Array.copy s
***************
*** 59,65 ****
  
  let ( +! ) a b =
    (* union *)
!   let r = Array.create 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) lor b.(i)
    done;
--- 59,65 ----
  
  let ( +! ) a b =
    (* union *)
!   let r = Array.create len: 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) lor b.(i)
    done;
***************
*** 69,75 ****
  
  let ( *! ) a b =
    (* intersection *)
!   let r = Array.create 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) land b.(i)
    done;
--- 69,75 ----
  
  let ( *! ) a b =
    (* intersection *)
!   let r = Array.create len: 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) land b.(i)
    done;
***************
*** 79,85 ****
  
  let ( !! ) a =
    (* negation *)
!   let r = Array.create 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) lxor 0xffff
    done;
--- 79,85 ----
  
  let ( !! ) a =
    (* negation *)
!   let r = Array.create len: 16 0 in
    for i=0 to 15 do
      r.(i) <- a.(i) lxor 0xffff
    done;
***************
*** 118,124 ****
  let word_set() =
    let a = dup_set (empty_set()) in
    List.iter
!     (fun c ->
        set_include a (Char.code c))
      [ 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm';
        'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z';
--- 118,124 ----
  let word_set() =
    let a = dup_set (empty_set()) in
    List.iter
!     fun: (fun c ->
        set_include a (Char.code c))
      [ 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm';
        'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z';
***************
*** 137,143 ****
      
  
  let set_as_string set =
!   let s = String.make 32 ' ' in
    for i = 0 to 15 do
      s.[i+i]   <- Char.chr (set.(i) land 0xff);
      s.[i+i+1] <- Char.chr (set.(i) lsr 8);
--- 137,143 ----
      
  
  let set_as_string set =
!   let s = String.make len: 32 ' ' in
    for i = 0 to 15 do
      s.[i+i]   <- Char.chr (set.(i) land 0xff);
      s.[i+i+1] <- Char.chr (set.(i) lsr 8);
***************
*** 174,181 ****
    | Nullstring :: ml' -> first_character ml'
    | Alternative l :: _ ->
        List.fold_left
! 	(fun s x -> s +! (first_character x))
! 	(empty_set())
  	l
    | Optional ml1 :: ml2 -> (first_character ml1) +! (first_character ml2)
    | Record (v,ml1) :: ml2 -> first_character ml1
--- 174,181 ----
    | Nullstring :: ml' -> first_character ml'
    | Alternative l :: _ ->
        List.fold_left
! 	fun: (fun acc: s x -> s +! (first_character x))
! 	acc: (empty_set())
  	l
    | Optional ml1 :: ml2 -> (first_character ml1) +! (first_character ml2)
    | Record (v,ml1) :: ml2 -> first_character ml1
***************
*** 212,218 ****
  	| 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
  	       run (k+xlen) ml' recs
  	          (* this is still not optimal *)
  	end
--- 212,218 ----
  	| 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 pos: k len: xlen s = x then
  	       run (k+xlen) ml' recs
  	          (* this is still not optimal *)
  	end
***************
*** 351,357 ****
  	  r.from <- old_from
  	end
      | Scanner f :: ml' ->
! 	let n = f (String.sub s k (len-k)) in
  	if k+n > len then
  	  failwith "match";
  	run (k+n) ml' recs
--- 351,357 ----
  	  r.from <- old_from
  	end
      | Scanner f :: ml' ->
! 	let n = f (String.sub pos: k len: (len-k) s) in
  	if k+n > len then
  	  failwith "match";
  	run (k+n) ml' recs
***************
*** 366,372 ****
      in
  
      List.iter
!       (fun r ->
  	if r.found then
  	  r.sref <- s)
        recs;
--- 366,372 ----
      in
  
      List.iter
!       fun: (fun r ->
  	if r.found then
  	  r.sref <- s)
        recs;
***************
*** 382,388 ****
      match ml with
        [] -> ()
      | Alternative alts :: ml' ->
! 	List.iter reset alts;
  	reset ml'
      | Optional opt :: ml' ->
  	reset opt;
--- 382,388 ----
      match ml with
        [] -> ()
      | Alternative alts :: ml' ->
! 	List.iter fun: reset alts;
  	reset ml'
      | Optional opt :: ml' ->
  	reset opt;
***************
*** 431,437 ****
  
  
  let replace_matched_substrings ml rl fl s =
!   let anchored = List.mem Anchored fl in
    let all = var "" in
    let ml' = [ Record(all, ml)] @ (if anchored then [] else [ Anystring ]) in
  
--- 431,437 ----
  
  
  let replace_matched_substrings ml rl fl s =
!   let anchored = List.mem key: Anchored fl in
    let all = var "" in
    let ml' = [ Record(all, ml)] @ (if anchored then [] else [ Anystring ]) in
  
***************
*** 439,445 ****
      match ml with
        [] -> []
      | Alternative alts :: ml' ->
! 	List.flatten (List.map resetlist alts) @
  	resetlist ml'
      | Optional opt :: ml' ->
  	resetlist opt @
--- 439,445 ----
      match ml with
        [] -> []
      | Alternative alts :: ml' ->
! 	List.flatten (List.map fun: resetlist alts) @
  	resetlist ml'
      | Optional opt :: ml' ->
  	resetlist opt @
***************
*** 453,465 ****
    let resl = resetlist ml' in
    let limit = 
      List.fold_left 
!       (fun m f ->
  	match f with
  	  Limit n -> 
  	    if n < 0 then failwith "replace_matched_substrings";
  	    if m >= 0 then min m n else n
  	| _       -> m)
!       (-1)
        fl in
  
    let n_repl = ref 0 in
--- 453,465 ----
    let resl = resetlist ml' in
    let limit = 
      List.fold_left 
!       fun: (fun acc: m f ->
  	match f with
  	  Limit n -> 
  	    if n < 0 then failwith "replace_matched_substrings";
  	    if m >= 0 then min m n else n
  	| _       -> m)
!       acc: (-1)
        fl in
  
    let n_repl = ref 0 in
***************
*** 469,475 ****
        [], (-1)
      else begin
        List.iter
! 	(fun v -> 
  	  v.found <- false;
  	  v.begun <- false)
  	resl;
--- 469,475 ----
        [], (-1)
      else begin
        List.iter
! 	fun: (fun v -> 
  	  v.found <- false;
  	  v.begun <- false)
  	resl;
***************
*** 478,484 ****
  	try
  	  let repltext =
  	    List.map
! 	      (fun r ->
  		match r with
  		  ReplaceLiteral s -> RLit s
  		| ReplaceVar v -> 
--- 478,484 ----
  	try
  	  let repltext =
  	    List.map
! 	      fun: (fun r ->
  		match r with
  		  ReplaceLiteral s -> RLit s
  		| ReplaceVar v -> 
***************
*** 570,580 ****
        RLit t :: trans' ->
  	let ls = String.length t in
  	let j' = j - ls in
! 	if ls > 0 then String.blit t 0 target j' ls;
  	form_replacement_ltor target trans' j'
      | RRegion (from,len) :: trans' ->
  	let j' = j - len in
! 	if len > 0 then String.blit s from target j' len;
  	form_replacement_ltor target trans' j'
      | [] -> ()
    in
--- 570,580 ----
        RLit t :: trans' ->
  	let ls = String.length t in
  	let j' = j - ls in
! 	if ls > 0 then String.blit src: t src_pos: 0 dst: target dst_pos: j' len: ls;
  	form_replacement_ltor target trans' j'
      | RRegion (from,len) :: trans' ->
  	let j' = j - len in
! 	if len > 0 then String.blit src: s src_pos: from dst: target dst_pos: j' :len;
  	form_replacement_ltor target trans' j'
      | [] -> ()
    in
***************
*** 590,596 ****
        left_to_right [] 0 0 
    in
    let length = total_length 0 transformer in
!   let target = String.create length in
    form_replacement_ltor target transformer length;
    target, !n_repl
  ;;
--- 590,596 ----
        left_to_right [] 0 0 
    in
    let length = total_length 0 transformer in
!   let target = String.create len: length in
    form_replacement_ltor target transformer length;
    target, !n_repl
  ;;
***************
*** 603,614 ****
  
  
  let string_of_var v =
!   String.sub v.sref v.from v.len
  ;;
  
  
  let found_string_of_var v =
!   if v.found then String.sub v.sref v.from v.len else raise Not_found
  ;;
  
  
--- 603,614 ----
  
  
  let string_of_var v =
!   String.sub pos: v.from len: v.len v.sref
  ;;
  
  
  let found_string_of_var v =
!   if v.found then String.sub pos: v.from len: v.len v.sref else raise Not_found
  ;;
  
  
Only in xstr.modern: xstr_match.ml~
Only in xstr.modern: xstr_search.cmi
Only in xstr.modern: xstr_search.cmo
diff -r -c xstr/xstr_search.ml xstr.modern/xstr_search.ml
*** xstr/xstr_search.ml	Mon Jun 28 08:03:38 1999
--- xstr.modern/xstr_search.ml	Wed Jan 26 13:37:55 2000
***************
*** 14,23 ****
    let c = if substr <> "" then substr.[0] else ' ' in
    let rec search k =
      if k <= k_right then begin
!       if String.sub s k lsub = substr then
  	k
        else
! 	let k_next = String.index_from s (k+1) c in
  	search k_next
      end
      else raise Not_found
--- 14,23 ----
    let c = if substr <> "" then substr.[0] else ' ' in
    let rec search k =
      if k <= k_right then begin
!       if String.sub pos: k len: lsub s = substr then
  	k
        else
! 	let k_next = String.index_from pos: (k+1) char: c s in
  	search k_next
      end
      else raise Not_found
***************
*** 32,41 ****
    let c = if substr <> "" then substr.[0] else ' ' in
    let rec search k =
      if k >= 0 then begin
!       if String.sub s k lsub = substr then
  	k
        else
! 	let k_next = String.rindex_from s (k-1) c in
  	search k_next
      end
      else raise Not_found
--- 32,41 ----
    let c = if substr <> "" then substr.[0] else ' ' in
    let rec search k =
      if k >= 0 then begin
!       if String.sub pos: k len: lsub s = substr then
  	k
        else
! 	let k_next = String.rindex_from pos: (k-1) char: c s in
  	search k_next
      end
      else raise Not_found
***************
*** 101,120 ****
    let len = 
      if sl = [] then 0 else get_len 0 sl - lsep in
  
!   let t = String.create len in
    
    let rec fill_in k sl =
      match sl with
        [] -> ()
      | [ s ] ->
  	let s_len = String.length s in
! 	String.blit s 0 t (k-s_len) s_len
      | s :: sl' ->
  	let s_len = String.length s in
  	let k' = k - s_len in
  	let k'' = k' - lsep in
! 	String.blit s 0 t k' s_len;
! 	String.blit sep 0 t k'' lsep;
  	fill_in k'' sl'
    in
  
--- 101,120 ----
    let len = 
      if sl = [] then 0 else get_len 0 sl - lsep in
  
!   let t = String.create :len in
    
    let rec fill_in k sl =
      match sl with
        [] -> ()
      | [ s ] ->
  	let s_len = String.length s in
! 	String.blit src: s src_pos: 0 dst: t dst_pos: (k-s_len) len: s_len
      | s :: sl' ->
  	let s_len = String.length s in
  	let k' = k - s_len in
  	let k'' = k' - lsep in
! 	String.blit src: s src_pos: 0 dst: t dst_pos: k' len: s_len;
! 	String.blit src: sep src_pos: 0 dst: t dst_pos: k'' len: lsep;
  	fill_in k'' sl'
    in
  
***************
*** 142,151 ****
        |	Not_found ->
  	  replace coll k_last (k+1)
        |	Replace_phrase (length, s') ->
! 	  replace (s' :: String.sub s k_last (k-k_last) :: coll) (k+length) (k+length)
      end
      else
!       String.sub s k_last (k-k_last) :: coll
    in
    rev_concat "" (replace [] 0 0)
  ;;
--- 142,151 ----
        |	Not_found ->
  	  replace coll k_last (k+1)
        |	Replace_phrase (length, s') ->
! 	  replace (s' :: String.sub pos: k_last len: (k-k_last) s :: coll) (k+length) (k+length)
      end
      else
!       String.sub pos: k_last len: (k-k_last) s :: coll
    in
    rev_concat "" (replace [] 0 0)
  ;;
***************
*** 154,160 ****
  let replace_substring s substrlist rule =
    let characters =
        (List.map
! 	 (fun substr ->
  	   if substr = "" then
  	     failwith "replace_substring"
  	   else
--- 154,160 ----
  let replace_substring s substrlist rule =
    let characters =
        (List.map
! 	 fun: (fun substr ->
  	   if substr = "" then
  	     failwith "replace_substring"
  	   else
***************
*** 168,174 ****
        [] -> raise Not_found
      | sub :: sl' ->
  	let lsub = String.length sub in
! 	if k <= l - lsub & String.sub s k lsub = sub then
  	  let replacement = rule sub k in
  	  raise (Replace_phrase(lsub, replacement))
  	else
--- 168,174 ----
        [] -> raise Not_found
      | sub :: sl' ->
  	let lsub = String.length sub in
! 	if k <= l - lsub & String.sub pos: k len: lsub s = sub then
  	  let replacement = rule sub k in
  	  raise (Replace_phrase(lsub, replacement))
  	else
***************
*** 176,182 ****
    in
  
    let rule' c k =
!     if List.mem c characters then 
        find k substrlist
      else
        raise Not_found
--- 176,182 ----
    in
  
    let rule' c k =
!     if List.mem key: c characters then 
        find k substrlist
      else
        raise Not_found
Only in xstr.modern: xstr_search.ml~
Only in xstr.modern: xstr_split.cmi
Only in xstr.modern: xstr_split.cmo
diff -r -c xstr/xstr_split.ml xstr.modern/xstr_split.ml
*** xstr/xstr_split.ml	Thu Jul  8 04:33:56 1999
--- xstr.modern/xstr_split.ml	Wed Jan 26 13:35:36 2000
***************
*** 32,41 ****
     *   = [ "a"; "b"; "c"; "d " ]
     *)
    let character_classification =
!     let a = Array.create 256 CData in
      let sepchars =
        List.flatten 
! 	(List.map (fun sep -> if sep <> "" then [sep.[0]] else []) separators)
      in
      let ignorechars =
        let l = ref [] in
--- 32,41 ----
     *   = [ "a"; "b"; "c"; "d " ]
     *)
    let character_classification =
!     let a = Array.create len: 256 CData in
      let sepchars =
        List.flatten 
! 	(List.map fun: (fun sep -> if sep <> "" then [sep.[0]] else []) separators)
      in
      let ignorechars =
        let l = ref [] in
***************
*** 45,55 ****
        !l
      in
      List.iter
!       (fun c ->
  	a.( Char.code c ) <- CSeparator)
        sepchars;
      List.iter
!       (fun c ->
  	let code = Char.code c in
  	if a.( code ) = CSeparator then
  	  a.( code ) <- CIgnoreOrSeparator
--- 45,55 ----
        !l
      in
      List.iter
!       fun: (fun c ->
  	a.( Char.code c ) <- CSeparator)
        sepchars;
      List.iter
!       fun: (fun c ->
  	let code = Char.code c in
  	if a.( code ) = CSeparator then
  	  a.( code ) <- CIgnoreOrSeparator
***************
*** 86,94 ****
  	      | sep :: sepl' ->
  		  let lsep = String.length sep in
  		  if i_current + lsep <= l & 
! 		    String.sub s i_current lsep = sep then
  		      (* found separator *)
! 		    String.sub s i_wordbeg (i_wordend - i_wordbeg) ::
  		    split_after_word (i_current + lsep) (i_current + lsep)
  		  else
  		    find_sep sepl'
--- 86,94 ----
  	      | sep :: sepl' ->
  		  let lsep = String.length sep in
  		  if i_current + lsep <= l & 
! 		    String.sub pos: i_current len: lsep s = sep then
  		      (* found separator *)
! 		    String.sub pos: i_wordbeg len: (i_wordend - i_wordbeg) s ::
  		    split_after_word (i_current + lsep) (i_current + lsep)
  		  else
  		    find_sep sepl'
***************
*** 98,106 ****
        else
  	(* i_current >= l *)
  	if ignoreright then
! 	  [ String.sub s i_wordbeg (i_wordend - i_wordbeg) ]
  	else
!     	  [ String.sub s i_wordbeg (i_current - i_wordbeg) ]
  
      and split_after_word i_wordbeg i_current =
        (* i_wordbeg > i_wordend:  i_current is just after the separator and
--- 98,106 ----
        else
  	(* i_current >= l *)
  	if ignoreright then
! 	  [ String.sub pos: i_wordbeg len: (i_wordend - i_wordbeg) s ]
  	else
!     	  [ String.sub pos: i_wordbeg len: (i_current - i_wordbeg) s ]
  
      and split_after_word i_wordbeg i_current =
        (* i_wordbeg > i_wordend:  i_current is just after the separator and
***************
*** 124,130 ****
  	      | sep :: sepl' ->
  		  let lsep = String.length sep in
  		  if i_current + lsep < l & 
! 		    String.sub s i_current lsep = sep then
  		      (* found separator *)
  		    "" ::
  		    split_after_word (i_current + lsep) (i_current + lsep)
--- 124,130 ----
  	      | sep :: sepl' ->
  		  let lsep = String.length sep in
  		  if i_current + lsep < l & 
! 		    String.sub pos: i_current len: lsep s = sep then
  		      (* found separator *)
  		    "" ::
  		    split_after_word (i_current + lsep) (i_current + lsep)
Only in xstr.modern: xstr_split.ml~
