aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/system.ml7
-rw-r--r--lib/system.mli2
-rw-r--r--library/library.ml10
-rw-r--r--library/states.ml3
4 files changed, 12 insertions, 10 deletions
diff --git a/lib/system.ml b/lib/system.ml
index 854c5dbdb..e0ec7b3ea 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -255,6 +255,13 @@ let extern_intern ?(warn=true) magic suffix =
in
(extern_state,intern_state)
+let with_magic_number_check f a =
+ try f a
+ with Bad_magic_number fname ->
+ errorlabstrm "with_magic_number_check"
+ (str"File " ++ str fname ++ strbrk" has bad magic number." ++ spc () ++
+ strbrk "It is corrupted or was compiled with another version of Coq.")
+
(* Communication through files with another executable *)
let connect writefun readfun com =
diff --git a/lib/system.mli b/lib/system.mli
index 86bff1d88..13fd09f5f 100644
--- a/lib/system.mli
+++ b/lib/system.mli
@@ -57,6 +57,8 @@ val raw_extern_intern : int -> string ->
val extern_intern : ?warn:bool -> int -> string ->
(string -> 'a -> unit) * (load_path -> string -> 'a)
+val with_magic_number_check : ('a -> 'b) -> 'a -> 'b
+
(** {6 Sending/receiving once with external executable } *)
val connect : (out_channel -> unit) -> (in_channel -> 'a) -> string -> 'a
diff --git a/library/library.ml b/library/library.ml
index 8677de837..478abe590 100644
--- a/library/library.ml
+++ b/library/library.ml
@@ -321,14 +321,6 @@ let (in_import, out_import) =
let (raw_extern_library, raw_intern_library) =
System.raw_extern_intern Coq_config.vo_magic_number ".vo"
-let with_magic_number_check f a =
- try f a
- with System.Bad_magic_number fname ->
- errorlabstrm "with_magic_number_check"
- (str"File " ++ str fname ++ spc () ++ str"has bad magic number." ++
- spc () ++ str"It is corrupted" ++ spc () ++
- str"or was compiled with another version of Coq.")
-
(************************************************************************)
(*s Locate absolute or partially qualified library names in the path *)
@@ -407,7 +399,7 @@ let mk_library md digest = {
library_digest = digest }
let intern_from_file f =
- let ch = with_magic_number_check raw_intern_library f in
+ let ch = System.with_magic_number_check raw_intern_library f in
let md = System.marshal_in ch in
let digest = System.marshal_in ch in
close_in ch;
diff --git a/library/states.ml b/library/states.ml
index ed13c3b7a..2cd8da982 100644
--- a/library/states.ml
+++ b/library/states.ml
@@ -22,7 +22,8 @@ let (extern_state,intern_state) =
extern_intern Coq_config.state_magic_number ".coq" in
(fun s -> raw_extern s (freeze())),
(fun s ->
- unfreeze (raw_intern (Library.get_load_paths ()) s);
+ unfreeze
+ (with_magic_number_check (raw_intern (Library.get_load_paths ())) s);
Library.overwrite_library_filenames s)
(* Rollback. *)