Commit 4d9d9d44 authored by bguillaum's avatar bguillaum

Fix bug with empty lexical parameter file

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@9220 7838e531-6607-4d57-9587-6c381814729c
parent 15f0b98d
......@@ -103,20 +103,23 @@ module File = struct
let read file =
let in_ch = open_in file in
(* if the input file contains an UTF-8 byte order mark (EF BB BF), skip 3 bytes, else get back to 0 *)
(match input_byte in_ch with 0xEF -> seek_in in_ch 3 | _ -> seek_in in_ch 0);
try
(* if the input file contains an UTF-8 byte order mark (EF BB BF), skip 3 bytes, else get back to 0 *)
(match input_byte in_ch with 0xEF -> seek_in in_ch 3 | _ -> seek_in in_ch 0);
let rev_lines = ref [] in
try
while true do
let line = input_line in_ch in
if (Str.string_match (Str.regexp "^[ \t]*$") line 0) || (line.[0] = '%')
then ()
else rev_lines := line :: !rev_lines
done; assert false
with End_of_file ->
close_in in_ch;
List.rev !rev_lines
with End_of_file -> [] (* if the file is empty, input_byte raises End_of_file *)
let rev_lines = ref [] in
try
while true do
let line = input_line in_ch in
if (Str.string_match (Str.regexp "^[ \t]*$") line 0) || (line.[0] = '%')
then ()
else rev_lines := line :: !rev_lines
done; assert false
with End_of_file ->
close_in in_ch;
List.rev !rev_lines
(* [read_ln file] returns a list of couples (line_num, line). Blank lines and lines starting with '%' are ignored. *)
let read_ln file =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment