aboutsummaryrefslogtreecommitdiffhomepage
path: root/toplevel
diff options
context:
space:
mode:
authorGravatar Maxime Dénès <mail@maximedenes.fr>2016-08-30 16:40:30 +0200
committerGravatar Maxime Dénès <mail@maximedenes.fr>2016-08-30 16:43:15 +0200
commitcc6957b0dbb19a4c0ca505650d252d9486088a5f (patch)
tree4a3d2bce53ea2bd8450fd0c2813e074e21d02c63 /toplevel
parent0d5abcf9e17b4fe0462ffa60d04a321d2707ccf6 (diff)
Fix #4941 - ~/.coqrc file confusing locations
Diffstat (limited to 'toplevel')
-rw-r--r--toplevel/vernac.ml9
1 files changed, 8 insertions, 1 deletions
diff --git a/toplevel/vernac.ml b/toplevel/vernac.ml
index 6dba2c51e..de3d14483 100644
--- a/toplevel/vernac.ml
+++ b/toplevel/vernac.ml
@@ -81,7 +81,6 @@ let open_file_twice_if verbosely longfname =
let in_chan = open_utf8_file_in longfname in
let verb_ch =
if verbosely then Some (open_utf8_file_in longfname) else None in
- CLexer.set_current_file longfname;
let po = Pcoq.Gram.parsable (Stream.of_channel in_chan) in
(in_chan, longfname, (po, verb_ch))
@@ -190,6 +189,8 @@ let rec vernac_com checknav (loc,com) =
let fname = CUnix.make_suffix fname ".v" in
let f = Loadpath.locate_file fname in
let st = save_translator_coqdoc () in
+ let old_lexer_file = CLexer.get_current_file () in
+ CLexer.set_current_file f;
if !Flags.beautify_file then
begin
chan_beautify := open_out (f^beautify_suffix);
@@ -199,9 +200,11 @@ let rec vernac_com checknav (loc,com) =
try
Flags.silently (read_vernac_file verbosely) f;
restore_translator_coqdoc st;
+ CLexer.set_current_file old_lexer_file;
with reraise ->
let reraise = CErrors.push reraise in
restore_translator_coqdoc st;
+ CLexer.set_current_file old_lexer_file;
iraise reraise
end
@@ -271,12 +274,16 @@ let (f_xml_end_library, xml_end_library) = Hook.make ~default:ignore ()
let load_vernac verb file =
chan_beautify :=
if !Flags.beautify_file then open_out (file^beautify_suffix) else stdout;
+ let old_lexer_file = CLexer.get_current_file () in
try
+ CLexer.set_current_file file;
Flags.silently (read_vernac_file verb) file;
if !Flags.beautify_file then close_out !chan_beautify;
+ CLexer.set_current_file old_lexer_file;
with any ->
let (e, info) = CErrors.push any in
if !Flags.beautify_file then close_out !chan_beautify;
+ CLexer.set_current_file old_lexer_file;
iraise (disable_drop e, info)
let warn_file_no_extension =