Package: headache / 1.03-26

01_detect_end_of_header Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Author: Julien Cristau <julien.cristau@ens-lyon.org>
Description: Patch to detect the end of the header

diff -Nru headache-1.03/main.ml headache-1.03.new/main.ml
--- headache-1.03/main.ml	2004-03-29 11:16:22.000000000 +0200
+++ headache-1.03.new/main.ml	2006-09-16 01:57:34.000000000 +0200
@@ -89,7 +89,7 @@
       let line = input_line ic in
       line :: loop ()
     with
-      End_of_file -> []
+      End_of_file -> close_in ic; []
   in
   loop ()
 
@@ -221,4 +221,4 @@
     main ()
   with
     Sys_error msg ->
-      eprintf "%s: %s" Sys.argv.(0) msg
+      eprintf "%s: %s\n" Sys.argv.(0) msg
diff -Nru headache-1.03/model.ml headache-1.03.new/model.ml
--- headache-1.03/model.ml	2004-03-29 11:16:22.000000000 +0200
+++ headache-1.03.new/model.ml	2006-09-16 01:47:06.000000000 +0200
@@ -138,6 +138,8 @@
   let regexp_end = 
     Str.regexp_string (sprintf "%s%s" (String.make 10 line_char) close_comment)
   in
+  let end_length = 10 + String.length close_comment
+  in
 
   let regexp_blank = Str.regexp "^[ ]*$" in
 
@@ -146,7 +148,11 @@
       let line = input_line ic in
       if Str.string_match regexp_begin line 0
       then begin
-	while not (Str.string_match regexp_end (input_line ic) 0) do () done;
+	while
+          let s = input_line ic in
+            not (Str.string_match regexp_end s
+                   (max 0 (String.length s - end_length)))
+        do () done;
 	""
       end
       else if Str.string_match regexp_blank line 0