File tree Expand file tree Collapse file tree 5 files changed +9
-7
lines changed Expand file tree Collapse file tree 5 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -100,5 +100,5 @@ let implementation ppf sourcefile outputprefix =
100100 raise x
101101
102102let c_file name =
103- Location. input_name := name;
103+ Location. set_input_name name;
104104 if Ccomp. compile_file name <> 0 then exit 2
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ let read_ast magic fn =
8484 try
8585 let buffer = really_input_string ic (String. length magic) in
8686 assert (buffer = magic); (* already checked by apply_rewriter *)
87- Location. input_name := input_value ic;
87+ Location. set_input_name @@ input_value ic;
8888 let ast = input_value ic in
8989 close_in ic;
9090 Misc. remove_file fn;
@@ -152,11 +152,11 @@ let file ppf ~tool_name inputfile parse_fun ast_magic =
152152 (* FIXME make this a proper warning *)
153153 fprintf ppf " @[Warning: %s@]@."
154154 " option -unsafe used with a preprocessor returning a syntax tree" ;
155- Location. input_name := input_value ic;
155+ Location. set_input_name @@ input_value ic;
156156 input_value ic
157157 end else begin
158158 seek_in ic 0 ;
159- Location. input_name := inputfile;
159+ Location. set_input_name inputfile;
160160 let lexbuf = Lexing. from_channel ic in
161161 Location. init lexbuf inputfile;
162162 parse_fun lexbuf
@@ -183,7 +183,7 @@ let () =
183183 )
184184
185185let parse_all ~tool_name parse_fun magic ppf sourcefile =
186- Location. input_name := sourcefile;
186+ Location. set_input_name sourcefile;
187187 let inputfile = preprocess sourcefile in
188188 let ast =
189189 try file ppf ~tool_name inputfile parse_fun magic
Original file line number Diff line number Diff line change @@ -799,7 +799,7 @@ let apply_lazy ~source ~target mapper =
799799 if magic <> Config. ast_impl_magic_number
800800 && magic <> Config. ast_intf_magic_number then
801801 failwith " Ast_mapper: OCaml version mismatch or malformed input" ;
802- Location. input_name := input_value ic;
802+ Location. set_input_name @@ input_value ic;
803803 let ast = input_value ic in
804804 close_in ic;
805805
Original file line number Diff line number Diff line change @@ -65,7 +65,8 @@ let rhs_loc n = {
6565
6666let input_name = ref " _none_"
6767let input_lexbuf = ref (None : lexbuf option )
68-
68+ let set_input_name name =
69+ if name <> " " then input_name := name
6970(* Terminal info *)
7071
7172let status = ref Terminfo. Uninitialised
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ val symbol_gloc: unit -> t
4848val rhs_loc : int -> t
4949
5050val input_name : string ref
51+ val set_input_name : string -> unit
5152val input_lexbuf : Lexing .lexbuf option ref
5253
5354val get_pos_info : Lexing .position -> string * int * int (* file, line, char *)
You can’t perform that action at this time.
0 commit comments