]> matita.cs.unibo.it Git - helm.git/commitdiff
- handle prefixes on the same line in conffile
authorStefano Zacchiroli <zack@upsilon.cc>
Wed, 6 Jul 2005 15:23:30 +0000 (15:23 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Wed, 6 Jul 2005 15:23:30 +0000 (15:23 +0000)
- cosmetic changes in settings pretty printing

helm/ocaml/getter/http_getter_env.ml

index a73710632afaf970bed9ab1cf3ef4c8c271229c6..74e32c22f265ceabd16d0b2affb8a08148da573b 100644 (file)
@@ -33,7 +33,7 @@ open Http_getter_misc
 
 let version = Http_getter_const.version
 
-let blanks_RE = Pcre.regexp "\\s"
+let prefix_RE = Pcre.regexp "^\\s*([^\\s]+)\\s+([^\\s]+)\\s*$"
 
 let cache_dir  = lazy (normalize_dir (Helm_registry.get "getter.cache_dir"))
 let dtd_dir = lazy (normalize_dir (Helm_registry.get "getter.dtd_dir"))
@@ -54,11 +54,12 @@ let prefixes = lazy (
   let prefixes = Helm_registry.get_list Helm_registry.string "getter.prefix" in
   List.fold_left
     (fun acc prefix ->
-      match Pcre.split ~rex:blanks_RE prefix with
-      | [uri_prefix; url_prefix] -> (uri_prefix, url_prefix) :: acc
-      | _ ->
-          Http_getter_logger.log ("skipping invalid prefix: " ^ prefix);
-          acc)
+      let subs = Pcre.extract ~rex:prefix_RE prefix in
+      try
+        (subs.(1), subs.(2)) :: acc
+      with Invalid_argument _ ->
+        Http_getter_logger.log ("skipping invalid prefix: " ^ prefix);
+        acc)
     [] prefixes)
 
 let host =
@@ -74,11 +75,13 @@ let my_own_url =
     host (if port = 80 then "" else (sprintf ":%d" port)))
 
 let env_to_string () =
-  let pp_prefix (uri_prefix, url_prefix) = uri_prefix ^ " -> " ^ url_prefix in
+  let pp_prefix (uri_prefix, url_prefix) =
+    "    " ^ uri_prefix ^ " -- " ^ url_prefix
+  in
   let pp_prefixes prefixes =
     match prefixes with
     | [] -> ""
-    | l -> "\n" ^ String.concat "\n" (List.map pp_prefix l) ^ "\n"
+    | l -> "\n" ^ String.concat "\n" (List.map pp_prefix l)
   in
   sprintf
 "HTTP Getter %s