Fix the build script.
authorKim Nguyễn <kn@lri.fr>
Thu, 4 Apr 2013 14:17:32 +0000 (16:17 +0200)
committerKim Nguyễn <kn@lri.fr>
Thu, 4 Apr 2013 14:17:32 +0000 (16:17 +0200)
build

diff --git a/build b/build
index f381c94..75781b0 100755 (executable)
--- a/build
+++ b/build
@@ -1,20 +1,17 @@
 #!/usr/bin/env ocaml
 
-let file_content =
-  let buffer = Buffer.create 128 in
-  begin fun f ->
-    Buffer.clear buffer;
-    try
-      let in_f = open_in f in
-      while true do
-        let line = input_line in_f in
-        Buffer.add_string buffer line;
-        Buffer.add_char buffer ' ';
-      done;
-      failwith "finished"
-    with
-      e -> let s = Buffer.contents buffer in s
-  end
+let read_lines f =
+  let lines = ref [] in
+  let in_f = open_in f in
+  try
+    while true do
+      let line = input_line in_f in
+      if String.length line != 0 then lines := line :: !lines
+    done;
+    []
+  with
+    End_of_file -> close_in in_f; List.rev !lines
+;;
 
 let target = ref [ ]
 let debug = ref false
@@ -47,7 +44,7 @@ let otarget = List.fold_left (fun acc t ->
   else
     let t =
       if Filename.check_suffix t ".otarget" then
-        file_content ((Filename.chop_suffix t ".otarget") ^ ".itarget")
+        String.concat " " (read_lines ((Filename.chop_suffix t ".otarget") ^ ".itarget"))
       else t
     in
     t ^ " " ^ acc) "" (if (!target == []) then [ "main.otarget" ] else !target)