let read_tags file =
let s = input_file_as_string file in
let l = Str.split (Str.regexp "^----------------------------$") s in
match l with
[] | [_] -> []
| preambule :: _ ->
try
print_DEBUG "Ocvs_commands.read_tags after preambule";
let s = "symbolic names:" in
let pos = Str.search_forward (Str.regexp ("^"^s^"$")) preambule 0 in
print_DEBUG "Ocvs_commands.read_tags after pos";
let pos2 = pos + (String.length s) + 1 in
let pos3 = Str.search_forward (Str.regexp "^keyword substitution:") preambule pos2 in
print_DEBUG "Ocvs_commands.read_tags after pos3";
let s2 = String.sub preambule pos2 (pos3 - pos2) in
let lines = Str.split (Str.regexp "\n") s2 in
let f_line acc line =
try
let pos = String.index line ':' in
let tag = String.sub line 1 (pos - 1) in
let revision = String.sub line (pos + 2) ((String.length line) - pos - 2) in
(tag, revision) :: acc
with
Not_found | Invalid_argument _ ->
acc
in
List.fold_left f_line [] lines
with
Not_found ->
[]