X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fhttp_getter%2Fhttp_getter_misc.ml;h=ad543b447e783f5a9dadd1fbc4bab70c853c3c67;hb=45bd3127b1ac786dc1ae14284b952fb503ba3094;hp=9ab7082974b5603e342f46b507a9e0b5dc12e1ab;hpb=96204969d2611dc618f7ed72ae40612b9526c763;p=helm.git diff --git a/helm/http_getter/http_getter_misc.ml b/helm/http_getter/http_getter_misc.ml index 9ab708297..ad543b447 100644 --- a/helm/http_getter/http_getter_misc.ml +++ b/helm/http_getter/http_getter_misc.ml @@ -30,7 +30,7 @@ open Http_getter_debugger;; open Printf;; let trailing_dot_gz_RE = Pcre.regexp "\\.gz$" (* for g{,un}zip *) -let url_RE = Pcre.regexp "^([\\w.]+)(:(\\d+))?(/.*)?$" +let url_RE = Pcre.regexp "^([\\w.-]+)(:(\\d+))?(/.*)?$" let http_scheme_RE = Pcre.regexp ~flags:[`CASELESS] "^http://" let file_scheme_RE = Pcre.regexp ~flags:[`CASELESS] "^file://" let dir_sep_RE = Pcre.regexp "/" @@ -225,10 +225,14 @@ let http_get url = close_in ic; Some buf with Unix.Unix_error (Unix.ENOENT, "stat", _) -> None - end else (* other URL, pass it to netclient *) + end else (* other URL, pass it to Http_client *) try - Some (Http_client.Convenience.http_get url) - with Http_client.Http_error (code, _) -> None + Some (Http_client.http_get url) + with e -> + prerr_endline (sprintf + "Warning: Http_client failed on url %s with exception: %s" + url (Printexc.to_string e)); + None (** apply a transformation "string list -> string list" to file lines *) let mangle_file ~fname f = @@ -273,3 +277,9 @@ let remove_line ~fname position = remove position ([], lines)) ;; +let is_blank_line = + let blank_line_RE = Pcre.regexp "(^#)|(^\\s*$)" in + fun line -> + Pcre.pmatch ~rex:blank_line_RE line +;; +