File: skip.ml

package info (click to toggle)
headache 1.03-27
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 556 kB
  • ctags: 190
  • sloc: ml: 621; xml: 218; makefile: 70
file content (36 lines) | stat: -rw-r--r-- 633 bytes parent folder | download | duplicates (5)
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


type regexp_filename = Str.regexp
;;

type regexp_skip = Str.regexp
;;

let skip skip_lst ic oc =
  let skip_aux () =
    let initial_pos =
      LargeFile.pos_in ic
    in
    try
      let line = 
        input_line ic
      in
      try
        let _ =
          List.find 
            (fun (_, rg_skip) -> Str.string_match rg_skip line 0)
            skip_lst
        in
          prerr_endline 
            ("Line : "^line^" skipped");
          output_string oc line;
          output_string oc "\n"
      with Not_found ->
        LargeFile.seek_in ic initial_pos
    with End_of_file ->
      ()
  in
    skip_aux ()
;;