diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-11-24 00:07:31 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-11-24 00:07:31 +0000 |
commit | 89de208360b9022db207e1af37bbae992f45002b (patch) | |
tree | 5248de006e1270590407c7096437f616a83d2733 /perl_checker.src/info.ml | |
parent | 131207a1f99f85d2b8d272e7b47b058076b5c1cf (diff) | |
download | perl_checker-89de208360b9022db207e1af37bbae992f45002b.tar perl_checker-89de208360b9022db207e1af37bbae992f45002b.tar.gz perl_checker-89de208360b9022db207e1af37bbae992f45002b.tar.bz2 perl_checker-89de208360b9022db207e1af37bbae992f45002b.tar.xz perl_checker-89de208360b9022db207e1af37bbae992f45002b.zip |
*** empty log message ***
Diffstat (limited to 'perl_checker.src/info.ml')
-rw-r--r-- | perl_checker.src/info.ml | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/perl_checker.src/info.ml b/perl_checker.src/info.ml index d15d3c0..947dc50 100644 --- a/perl_checker.src/info.ml +++ b/perl_checker.src/info.ml @@ -2,18 +2,21 @@ open List open Printf open Common -let (lines_starts : (string * int list ref) list ref) = ref [] +let (lines_starts : (string, int list) Hashtbl.t) = Hashtbl.create 4 let current_file_lines_starts = ref [] let current_file_current_line = ref 0 let current_file = ref "" let start_a_new_file file = + if !current_file <> "" then Hashtbl.add lines_starts !current_file !current_file_lines_starts ; current_file := file ; - current_file_lines_starts := [0] ; - lines_starts := (file, current_file_lines_starts) :: !lines_starts + current_file_lines_starts := [0] + +let get_lines_starts_for_file file = + if file = !current_file then !current_file_lines_starts else Hashtbl.find lines_starts file let raw_pos2raw_line file a = - let starts = map_index (fun a b -> a,b) (rev !(assoc file !lines_starts)) in + let starts = map_index (fun a b -> a,b) (rev (get_lines_starts_for_file file)) in let ((offset, line), _) = find (fun (_,(e,_)) -> e > a) (combine starts (tl starts @ [999999999, 999999999])) in line, offset |