projects
/
SXSI
/
xpathcomp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added filename parameter for Save() and Load()
[SXSI/xpathcomp.git]
/
tree.ml
diff --git
a/tree.ml
b/tree.ml
index
a034636
..
20bd067
100644
(file)
--- a/
tree.ml
+++ b/
tree.ml
@@
-34,8
+34,8
@@
let equal_node : 'a node -> 'a node -> bool = (==)
external parse_xml_uri : string -> int -> bool -> bool -> tree = "caml_call_shredder_uri"
external parse_xml_string : string -> int -> bool -> bool -> tree = "caml_call_shredder_string"
external tree_print_xml_fast3 : tree -> [`Tree ] node -> Unix.file_descr ->unit = "caml_xml_tree_print"
external parse_xml_uri : string -> int -> bool -> bool -> tree = "caml_call_shredder_uri"
external parse_xml_string : string -> int -> bool -> bool -> tree = "caml_call_shredder_string"
external tree_print_xml_fast3 : tree -> [`Tree ] node -> Unix.file_descr ->unit = "caml_xml_tree_print"
-external tree_save : tree -> Unix.file_descr -> unit = "caml_xml_tree_save"
-external tree_load : Unix.file_descr -> bool -> int -> tree = "caml_xml_tree_load"
+external tree_save : tree -> Unix.file_descr ->
string ->
unit = "caml_xml_tree_save"
+external tree_load : Unix.file_descr ->
string ->
bool -> int -> tree = "caml_xml_tree_load"
external nullt : unit -> 'a node = "caml_xml_tree_nullt"
external nullt : unit -> 'a node = "caml_xml_tree_nullt"
@@
-176,7
+176,7
@@
let text_size t = text_size t.doc
module MemUnion = Hashtbl.Make (struct
type t = Ptset.Int.t*Ptset.Int.t
module MemUnion = Hashtbl.Make (struct
type t = Ptset.Int.t*Ptset.Int.t
- let equal (x,y) (z,t) = x == z
||
y == t
+ let equal (x,y) (z,t) = x == z
&&
y == t
let equal a b = equal a b || equal b a
let hash (x,y) = (* commutative hash *)
let x = Uid.to_int (Ptset.Int.uid x)
let equal a b = equal a b || equal b a
let hash (x,y) = (* commutative hash *)
let x = Uid.to_int (Ptset.Int.uid x)
@@
-421,7
+421,7
@@
let save t str =
(* we need to move the fd to the correct position *)
flush out_c;
ignore (Unix.lseek fd (pos_out out_c) Unix.SEEK_SET);
(* we need to move the fd to the correct position *)
flush out_c;
ignore (Unix.lseek fd (pos_out out_c) Unix.SEEK_SET);
- tree_save t.doc fd;
+ tree_save t.doc fd
str
;
close_out out_c
;;
close_out out_c
;;
@@
-452,7
+452,7
@@
let load ?(sample=64) ?(load_text=true) str =
let _ = Printf.eprintf "\nLoading tag table : " in
let ntable = time (load_table) () in
ignore(Unix.lseek fd (pos_in in_c) Unix.SEEK_SET);
let _ = Printf.eprintf "\nLoading tag table : " in
let ntable = time (load_table) () in
ignore(Unix.lseek fd (pos_in in_c) Unix.SEEK_SET);
- let tree = { doc = tree_load fd load_text sample;
+ let tree = { doc = tree_load fd
str
load_text sample;
ttable = ntable;}
in close_in in_c;
tree
ttable = ntable;}
in close_in in_c;
tree
@@
-513,7
+513,8
@@
let select_following_sibling t = fun ts ->
fun n -> tree_select_following_sibling t.doc n v
let next_sibling_below t = (); fun n _ -> tree_next_sibling t.doc n
fun n -> tree_select_following_sibling t.doc n v
let next_sibling_below t = (); fun n _ -> tree_next_sibling t.doc n
-let next_element_below t = (); fun n _ -> tree_next_element t.doc n
+let next_element_below t = (); fun n _ -> tree_next_element t.doc n
+
let tagged_following_sibling_below t tag = (); fun n _ -> tree_tagged_following_sibling t.doc n tag
let select_following_sibling_below t = fun ts ->
let tagged_following_sibling_below t tag = (); fun n _ -> tree_tagged_following_sibling t.doc n tag
let select_following_sibling_below t = fun ts ->
@@
-788,3
+789,7
@@
let stats t =
+let test_prefix t s = Array.length (text_prefix t.doc s)
+let test_suffix t s = Array.length (text_suffix t.doc s)
+let test_contains t s = Array.length (text_contains t.doc s)
+let test_equals t s = Array.length (text_equals t.doc s)