From 4b5af0d6e9ec1343a2c3ff9f856a019fa93c3606 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 15 May 2015 17:42:16 +0200 Subject: On MacOS X, ensuring that files found in the file system have the expected lowercase/uppercase spelling (based on a patch by Pierre B.). This should fix #2554 (and see also discussion on coq-club, May 2015). --- lib/system.ml | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/system.ml b/lib/system.ml index d1cdd8efc9..6364035e16 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -53,6 +53,19 @@ let all_subdirs ~unix_path:root = if exists_dir root then traverse root []; List.rev !l +let file_really_exists f = + if Coq_config.arch = "Darwin" then + (* ensure that the file exists with expected case on the + case-insensitive but case-preserving default MacOS file system *) + let rec aux f = + Printf.eprintf ".%!"; + let bf = Filename.basename f in + let df = Filename.dirname f in + String.equal df "." || String.equal df "/" || + aux df && Array.exists (String.equal bf) (Sys.readdir df) + in aux f + else Sys.file_exists f + let rec search paths test = match paths with | [] -> [] -- cgit v1.2.3 From ea3909466eaaf86ff212c0a002e5df11e4a979f5 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Mon, 18 May 2015 17:47:58 +0200 Subject: The Fail command does not catch uncaught exception anomalies anymore. --- lib/errors.ml | 9 +++++++++ lib/errors.mli | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/errors.ml b/lib/errors.ml index 999d99ee08..c60442654a 100644 --- a/lib/errors.ml +++ b/lib/errors.ml @@ -120,3 +120,12 @@ let noncritical = function | Timeout | Drop | Quit -> false | Invalid_argument "equal: functional value" -> false | _ -> true + +(** Check whether an exception is handled *) + +exception Bottom + +let handled e = + let bottom _ = raise Bottom in + try let _ = print_gen bottom !handle_stack e in true + with Bottom -> false diff --git a/lib/errors.mli b/lib/errors.mli index 5bd5724746..8320ce409f 100644 --- a/lib/errors.mli +++ b/lib/errors.mli @@ -88,3 +88,7 @@ val iprint_no_report : Exninfo.iexn -> Pp.std_ppcmds Typical example: [Sys.Break], [Assert_failure], [Anomaly] ... *) val noncritical : exn -> bool + +(** Check whether an exception is handled by some toplevel printer. The + [Anomaly] exception is never handled. *) +val handled : exn -> bool -- cgit v1.2.3 From 69941d4e195650bf59285b897c14d6287defea0f Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Wed, 20 May 2015 14:36:41 +0200 Subject: Continuing incomplete 4b5af0d6e9ec1 (on MacOS X, ensuring that files found in the file system have the expected lowercase/uppercase spelling) --- lib/envars.ml | 19 ++++++++++++++++--- lib/system.ml | 7 +++---- lib/system.mli | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/envars.ml b/lib/envars.ml index b0eed8386b..ac0b6f722e 100644 --- a/lib/envars.ml +++ b/lib/envars.ml @@ -39,12 +39,25 @@ let path_to_list p = let user_path () = path_to_list (Sys.getenv "PATH") (* may raise Not_found *) + (* Duplicated from system.ml to minimize dependencies *) +let file_exists_respecting_case f = + if Coq_config.arch = "Darwin" then + (* ensure that the file exists with expected case on the + case-insensitive but case-preserving default MacOS file system *) + let rec aux f = + let bf = Filename.basename f in + let df = Filename.dirname f in + String.equal df "." || String.equal df "/" || + aux df && Array.exists (String.equal bf) (Sys.readdir df) + in aux f + else Sys.file_exists f + let rec which l f = match l with | [] -> raise Not_found | p :: tl -> - if Sys.file_exists (p / f) then + if file_exists_respecting_case (p / f) then p else which tl f @@ -102,7 +115,7 @@ let _ = If the check fails, then [oth ()] is evaluated. *) let check_file_else ~dir ~file oth = let path = if Coq_config.local then coqroot else coqroot / dir in - if Sys.file_exists (path / file) then path else oth () + if file_exists_respecting_case (path / file) then path else oth () let guess_coqlib fail = let prelude = "theories/Init/Prelude.vo" in @@ -134,7 +147,7 @@ let coqpath = let coqpath = getenv_else "COQPATH" (fun () -> "") in let make_search_path path = let paths = path_to_list path in - let valid_paths = List.filter Sys.file_exists paths in + let valid_paths = List.filter file_exists_respecting_case paths in List.rev valid_paths in make_search_path coqpath diff --git a/lib/system.ml b/lib/system.ml index 6364035e16..1a67120b60 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -53,12 +53,11 @@ let all_subdirs ~unix_path:root = if exists_dir root then traverse root []; List.rev !l -let file_really_exists f = +let file_exists_respecting_case f = if Coq_config.arch = "Darwin" then (* ensure that the file exists with expected case on the case-insensitive but case-preserving default MacOS file system *) let rec aux f = - Printf.eprintf ".%!"; let bf = Filename.basename f in let df = Filename.dirname f in String.equal df "." || String.equal df "/" || @@ -90,7 +89,7 @@ let where_in_path ?(warn=true) path filename = in check_and_warn (search path (fun lpe -> let f = Filename.concat lpe filename in - if Sys.file_exists f then [lpe,f] else [])) + if file_exists_respecting_case f then [lpe,f] else [])) let where_in_path_rex path rex = search path (fun lpe -> @@ -106,7 +105,7 @@ let where_in_path_rex path rex = let find_file_in_path ?(warn=true) paths filename = if not (Filename.is_implicit filename) then - if Sys.file_exists filename then + if file_exists_respecting_case filename then let root = Filename.dirname filename in root, filename else diff --git a/lib/system.mli b/lib/system.mli index a3d66d577a..051e92f166 100644 --- a/lib/system.mli +++ b/lib/system.mli @@ -29,6 +29,8 @@ val exists_dir : string -> bool val find_file_in_path : ?warn:bool -> CUnix.load_path -> string -> CUnix.physical_path * string +val file_exists_respecting_case : string -> bool + (** {6 I/O functions } *) (** Generic input and output functions, parameterized by a magic number and a suffix. The intern functions raise the exception [Bad_magic_number] -- cgit v1.2.3 From 8241460f5a729b577b0d7da544fe8f8fcda18d14 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Wed, 20 May 2015 14:47:24 +0200 Subject: Answering report #4241 (formatting of boxes not behaving regularly when printing width extend). --- lib/pp_control.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pp_control.ml b/lib/pp_control.ml index 0d224c0351..7fe4e0f52d 100644 --- a/lib/pp_control.ml +++ b/lib/pp_control.ml @@ -20,7 +20,7 @@ let dflt_gp = { margin = 78; max_indent = 50; max_depth = 50; - ellipsis = ".." } + ellipsis = "..." } (* A deeper pretty-printer to print proof scripts *) @@ -84,5 +84,8 @@ let set_margin v = let v = match v with None -> default_margin | Some v -> v in Format.pp_set_margin Format.str_formatter v; Format.pp_set_margin !std_ft v; - Format.pp_set_margin !deep_ft v - + Format.pp_set_margin !deep_ft v; + let m = 64 * v / 100 in (* Heuristic, based on usage *) + Format.pp_set_max_indent Format.str_formatter m; + Format.pp_set_max_indent !std_ft m; + Format.pp_set_max_indent !deep_ft m -- cgit v1.2.3 From 2eb7d2e20a2fc58ae91a5110f26e2f9a3699db46 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Thu, 21 May 2015 18:14:56 +0200 Subject: Changing the heuristic fixing bug #4241. Fixed #4241 correlates Printing Width and max_indent, this patch changes the correlation to the following one: max_indent = max ((wdth*80)/100) (wdth-30) i.e. the right column defined by max_indent is 20% of the global width, but capped to 30 characters. --- lib/pp_control.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pp_control.ml b/lib/pp_control.ml index 7fe4e0f52d..969c1550ec 100644 --- a/lib/pp_control.ml +++ b/lib/pp_control.ml @@ -85,7 +85,9 @@ let set_margin v = Format.pp_set_margin Format.str_formatter v; Format.pp_set_margin !std_ft v; Format.pp_set_margin !deep_ft v; - let m = 64 * v / 100 in (* Heuristic, based on usage *) + (* Heuristic, based on usage: the column on the right of max_indent + column is 20% of width, capped to 30 characters *) + let m = max (64 * v / 100) (v-30) in Format.pp_set_max_indent Format.str_formatter m; Format.pp_set_max_indent !std_ft m; Format.pp_set_max_indent !deep_ft m -- cgit v1.2.3 From e7043eec55085f4101bfb126d8829de6f6086c5a Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 22 May 2015 08:50:36 +0200 Subject: Continuing 4b5af0d6e9 and 69941d4e19 about filename case check on MacOS X. Thanks to Vadim Zaliva for testing. --- lib/system.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/system.ml b/lib/system.ml index 1a67120b60..27e21204cc 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -60,8 +60,8 @@ let file_exists_respecting_case f = let rec aux f = let bf = Filename.basename f in let df = Filename.dirname f in - String.equal df "." || String.equal df "/" || - aux df && Array.exists (String.equal bf) (Sys.readdir df) + (String.equal df "." || String.equal df "/" || aux df) + && Array.exists (String.equal bf) (Sys.readdir df) in aux f else Sys.file_exists f -- cgit v1.2.3 From e47c30bf431f3c8160b41384eedb538ba16578d0 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 29 May 2015 15:41:15 +0200 Subject: Flag -test-mode intended to be used for ad-hoc prints in test-suite Of course there is an exception to the previous commit. Fail used to print even if silenced but loading a vernac file. This behavior is useful only in tests, hence this flag. --- lib/flags.ml | 2 ++ lib/flags.mli | 2 ++ 2 files changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/flags.ml b/lib/flags.ml index 313da0c5bd..009caa9dee 100644 --- a/lib/flags.ml +++ b/lib/flags.ml @@ -48,6 +48,8 @@ let batch_mode = ref false type compilation_mode = BuildVo | BuildVio | Vio2Vo let compilation_mode = ref BuildVo +let test_mode = ref false + type async_proofs = APoff | APonLazy | APon let async_proofs_mode = ref APoff type cache = Force diff --git a/lib/flags.mli b/lib/flags.mli index 1f68a88f3a..544e2a72ae 100644 --- a/lib/flags.mli +++ b/lib/flags.mli @@ -15,6 +15,8 @@ val batch_mode : bool ref type compilation_mode = BuildVo | BuildVio | Vio2Vo val compilation_mode : compilation_mode ref +val test_mode : bool ref + type async_proofs = APoff | APonLazy | APon val async_proofs_mode : async_proofs ref type cache = Force -- cgit v1.2.3