From: Luca Padovani Date: Fri, 20 Dec 2002 15:10:20 +0000 (+0000) Subject: * if no configuration file is found, issue a warning but doesn't crash X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=8ae285e63ffafccb4336950aa512a6b79ca0a4a2;p=helm.git * if no configuration file is found, issue a warning but doesn't crash --- diff --git a/helm/ocaml/getter/configuration.ml b/helm/ocaml/getter/configuration.ml index 2c7ead3dc..16dc9d0f5 100644 --- a/helm/ocaml/getter/configuration.ml +++ b/helm/ocaml/getter/configuration.ml @@ -37,11 +37,11 @@ let xml_document () = let module Y = Pxp_yacc in try let config = {Y.default_config with Y.warner = new warner} in - Y.parse_document_entity config (Y.from_file filename) Y.default_spec + Some (Y.parse_document_entity config (Y.from_file filename) Y.default_spec) with e -> - print_endline (Pxp_types.string_of_exn e) ; - raise e + prerr_endline ("Warning: configuration file not found, or incorrect: " ^ Pxp_types.string_of_exn e) ; + None ;; exception Impossible;; @@ -65,15 +65,18 @@ let rec resolve = (* we trust the xml file to be valid because of the validating xml parser *) let _ = - List.iter - (function - n -> - match n#node_type with - Pxp_document.T_element var -> - Hashtbl.add vars var (resolve (n#sub_nodes)) - | _ -> raise Impossible - ) - ((xml_document ())#root#sub_nodes) + match xml_document () with + None -> () + | Some d -> + List.iter + (function + n -> + match n#node_type with + Pxp_document.T_element var -> + Hashtbl.add vars var (resolve (n#sub_nodes)) + | _ -> raise Impossible + ) + (d#root#sub_nodes) ;; (* try to read a configuration variable, given its name into the @@ -101,15 +104,7 @@ let read_configuration_var xml_name = flush stdout ; raise Not_found -let helm_dir = read_configuration_var "helm_dir";; -let dtd_dir = read_configuration_var "dtd_dir";; -let style_dir = read_configuration_var_env "style_dir" "HELM_STYLE_DIR";; -let servers_file = read_configuration_var "servers_file";; -let uris_dbm = read_configuration_var "uris_dbm";; -let dest = read_configuration_var "dest";; -let indexname = read_configuration_var "indexname";; -let tmp_dir = read_configuration_var "tmp_dir" -let helm_dir = read_configuration_var "helm_dir";; +let tmp_dir = read_configuration_var_env "tmp_dir" "HELM_TMP_DIR";; let getter_url = read_configuration_var_env "getter_url" "HELM_GETTER_URL";; let processor_url = read_configuration_var_env "processor_url" "HELM_PROCESSOR_URL";; let annotations_dir = read_configuration_var_env "annotations_dir" "HELM_ANNOTATIONS_DIR" diff --git a/helm/ocaml/getter/configuration.mli b/helm/ocaml/getter/configuration.mli index 4d0bfbc01..3dae0e000 100644 --- a/helm/ocaml/getter/configuration.mli +++ b/helm/ocaml/getter/configuration.mli @@ -33,15 +33,7 @@ (* *) (******************************************************************************) -val helm_dir : string -val dtd_dir : string -val style_dir : string -val servers_file : string -val uris_dbm : string -val dest : string -val indexname : string val tmp_dir : string -val helm_dir : string val getter_url : string val processor_url : string val annotations_dir : string