Parcourir la source

Fix some problem with number of launch

Leo il y a 10 ans
Parent
commit
848527e129
4 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 2 0
      src/const.ml
  2. 2 0
      src/const.mli
  3. 1 1
      src/exec_cmd.ml
  4. 1 1
      src/tmp_file.ml

+ 2 - 0
src/const.ml

@@ -82,3 +82,5 @@ let rc_file_default = Lazy.(home >>| (fun home -> home ^ "/" ^
 let rc_file = ref rc_file_default;;
 (* Set tmp file, in witch stock launches, in biniou format *)
 let tmp_file = get_var ~default:"/tmp/.oclaunch_trace.dat" "OC_TMP";; (* File where launch are logged *)
+(* Default number for launchment *)
+let default_launch = 1;; (* TODO set it in rc file *)

+ 2 - 0
src/const.mli

@@ -46,4 +46,6 @@ val no_color : bool ref
 val rc_file_default : string Core.Std.Lazy.t
 val rc_file : string Core.Std.Lazy.t ref
 val tmp_file : string
+(* Conf *)
+val default_launch : int
 

+ 1 - 1
src/exec_cmd.ml

@@ -54,7 +54,7 @@ let less_launched (log : (string * int) list) =
   let entries_by_number = List.Assoc.inverse log  in
     List.min_elt ~cmp:(fun (n,_) (n',_) -> Int.compare n n') entries_by_number
     |> (function Some (min,cmd) ->
-        if min < max
+        if min <= max
         then Some cmd
         else None
       | None -> assert false) (* XXX Use exception here? *)

+ 1 - 1
src/tmp_file.ml

@@ -124,7 +124,7 @@ let log ~cmd ?(func= (+) 1 ) () =
     (* Only number of launchment associated with commands *)
     let l = get_log li in
     find l cmd
-      |> (function None -> add l cmd 0 | Some n -> add l cmd (func n)) (* XXX Using 0 as default value *)
+      |> (function None -> add l cmd Const.default_launch | Some n -> add l cmd (func n))
       |> List.map ~f:(fun e -> { Tmp_biniou_t.commands = e})
     in
   (* Write the file with the new value *)