let analyse_status_file f =
  try
    let s = input_file_as_string f in
    let l = Str.split
        (Str.regexp_string "===================================================================\nFile: ")
        s
    in
    let date = Unix.time () in
    let f acc str =
      try
        (* the file name, between 0 and n1 *)
        let n1 = Str.search_forward (Str.regexp "[ \t]*Status:[ ]") str 0 in
        let file = String.sub str 0 n1 in
        (* the status string, between n2 and n3 *)
        let n2 = n1 + (String.length (Str.matched_string str)) in
        let n3 = Str.search_forward (Str.regexp "\n") str n1 in
        let status_string = String.sub str n2 (n3-n2) in
        let cvs_info =
          if status_string = "Unknown" or status_string = "Locally Added" then
            {
              cvs_file = file ;
              cvs_status = Ocvs_types.status_of_string status_string ;
              cvs_work_rev = "" ;
              cvs_rep_rev = "" ;
              cvs_date_string = "" ;
              cvs_date = date
            }
          else if status_string = "Locally Removed" then
            (
             let len = String.length file in
             let no_file = "no file " in
             let len_no_file = String.length no_file in
             let real_file =
               if len <= len_no_file then
                 file
               else
                 if String.sub file 0 len_no_file = no_file then
                   String.sub file len_no_file (len - len_no_file)
                 else
                   file
             in
             {
              cvs_file = real_file ;
              cvs_status = Ocvs_types.status_of_string status_string ;
              cvs_work_rev = "" ;
              cvs_rep_rev = "" ;
              cvs_date_string = "" ;
              cvs_date = date
            }
            )
          else
            (
             print_DEBUG "after n3";
              (* the working revision *)
             let n4 = Str.search_forward (Str.regexp "Working revision:\t\\([^\t\n]+\\)\t?") str n3 in
             print_DEBUG "after n4";
             let n5 = n4 + (String.length (Str.matched_string str)) in
             let work_rev = Str.matched_group 1 str in
             print_DEBUG ("after work_rev="^work_rev);
             (* the date as string between n5 and n6 *)
             let n6 = Str.search_forward (Str.regexp "\n") str n5 in
             print_DEBUG "after n6";
             (* the repository revision *)
             let _n7 = Str.search_forward (Str.regexp "Repository revision:\t\\([^\t]+\\)\t") str n6 in
             print_DEBUG "after n7";
             let rep_rev = Str.matched_group 1 str in
             let cvs_info =
               {
                 cvs_file = file ;
                 cvs_status = Ocvs_types.status_of_string (String.sub str n2 (n3-n2)) ;
                 cvs_work_rev = work_rev ;
                 cvs_rep_rev = rep_rev ;
                 cvs_date_string = String.sub str n5 (n6-n5) ;
                 cvs_date = date
               }
             in
             cvs_info
            )
        in
        acc @ [cvs_info]
    with
     Not_found ->
       acc
    in
    List.fold_left f [] l

  with
    Sys_error s ->
      raise (Ocvs_types.CvsFailure s)