|
|
@ -13,12 +13,21 @@ type t = {dir: string; file: string; line: int; col: int}
|
|
|
|
let none = {dir= ""; file= ""; line= 0; col= 0}
|
|
|
|
let none = {dir= ""; file= ""; line= 0; col= 0}
|
|
|
|
|
|
|
|
|
|
|
|
let mk ?(dir = none.dir) ?(file = none.file) ?(col = none.col) ~line =
|
|
|
|
let mk ?(dir = none.dir) ?(file = none.file) ?(col = none.col) ~line =
|
|
|
|
|
|
|
|
let dir = if String.is_empty dir then dir else Filename.realpath dir in
|
|
|
|
{dir; file; line; col}
|
|
|
|
{dir; file; line; col}
|
|
|
|
|
|
|
|
|
|
|
|
let pp fs {dir; file; line; col} =
|
|
|
|
let root = ref (Filename.realpath (Sys.getcwd ()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pp fs ({dir; file; line; col} as loc) =
|
|
|
|
|
|
|
|
if not (equal loc none) then Format.pp_print_string fs "; " ;
|
|
|
|
|
|
|
|
if not (String.is_empty dir) then (
|
|
|
|
|
|
|
|
let dir =
|
|
|
|
|
|
|
|
Option.value_map ~f:Fpath.to_string
|
|
|
|
|
|
|
|
(Fpath.relativize ~root:(Fpath.v !root) (Fpath.v dir))
|
|
|
|
|
|
|
|
~default:dir
|
|
|
|
|
|
|
|
in
|
|
|
|
Format.pp_print_string fs dir ;
|
|
|
|
Format.pp_print_string fs dir ;
|
|
|
|
if not (String.is_empty dir) then
|
|
|
|
Format.pp_print_string fs Filename.dir_sep ) ;
|
|
|
|
Format.pp_print_string fs Filename.dir_sep ;
|
|
|
|
|
|
|
|
Format.pp_print_string fs file ;
|
|
|
|
Format.pp_print_string fs file ;
|
|
|
|
if not (String.is_empty file) then Format.pp_print_char fs ':' ;
|
|
|
|
if not (String.is_empty file) then Format.pp_print_char fs ':' ;
|
|
|
|
if line > 0 then (
|
|
|
|
if line > 0 then (
|
|
|
|