X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic%2FcicParser.ml;h=e4a840ccf5243ad59a90669318429a8b26de6fa2;hb=12cc5b2b8e7f7bb0b5e315094b008a293a4df6b1;hp=619e947f21d4af37334eff3052fec896cc5592fd;hpb=1b1ae2b73035d4a09792ee53c51e7c6dd5bbd41c;p=helm.git diff --git a/helm/ocaml/cic/cicParser.ml b/helm/ocaml/cic/cicParser.ml index 619e947f2..e4a840ccf 100644 --- a/helm/ocaml/cic/cicParser.ml +++ b/helm/ocaml/cic/cicParser.ml @@ -658,6 +658,13 @@ let end_element ctxt tag = (** {2 Parser internals} *) +let has_gz_suffix fname = + try + let idx = String.rindex fname '.' in + let suffix = String.sub fname idx (String.length fname - idx) in + suffix = ".gz" + with Not_found -> false + let parse uri filename = let ctxt = new_parser_context uri in ctxt.filename <- filename; @@ -671,7 +678,11 @@ let parse uri filename = ctxt.xml_parser <- Some xml_parser; try (try - P.parse xml_parser (`Gzip_file filename); + let xml_source = + if has_gz_suffix filename then `Gzip_file filename + else `File filename + in + P.parse xml_parser xml_source with exn -> ctxt.xml_parser <- None; (* ZACK: the above "<- None" is vital for garbage collection. Without it