Skip to content

Commit

Permalink
Enable merlin and fix detected errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
gildor478 committed Nov 1, 2016
1 parent 558a4be commit d054fb4
Show file tree
Hide file tree
Showing 21 changed files with 382 additions and 456 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/test/oUnit.log
/website/website-tools/
/website/dist/
/BenchFind.native
7 changes: 7 additions & 0 deletions .merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
S src/**
S test/**
B _build/src/**
B _build/test/**
PKG unix
PKG oUnit
FLG -w +a-4-44
3 changes: 0 additions & 3 deletions src/ExtensionPath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
(** Manipulate path extension
*)

open FilePath_type


let get fn =
let start_pos =
(String.rindex fn '.') + 1
Expand Down
20 changes: 7 additions & 13 deletions src/FilePath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,8 @@ struct
(string_of_filename [hd2])
)
end
| (subdir, []) ->
SubDir
| ([], updir) ->
UpDir
| (_, []) -> SubDir
| ([], _) -> UpDir
in
relation_of_filename_aux path1 path2

Expand Down Expand Up @@ -244,19 +242,15 @@ struct

let basename path =
match List.rev path with
hd :: tl ->
[hd]
| [] ->
raise EmptyFilename
| hd :: _ -> [hd]
| [] -> raise EmptyFilename

(* Dirname *)

let dirname path =
match List.rev path with
hd :: tl ->
List.rev tl
| [] ->
raise EmptyFilename
| _ :: tl -> List.rev tl
| [] -> raise EmptyFilename

(* Extension manipulation *)

Expand Down Expand Up @@ -323,7 +317,7 @@ struct
make_relative_aux tl_base tl_path
| _, _ ->
let back_to_base = List.rev_map
(fun x -> ParentDir)
(fun _ -> ParentDir)
lst_base
in
back_to_base @ lst_path
Expand Down
9 changes: 3 additions & 6 deletions src/FilePath_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ type extension = string
(* Utility function to parse filename *)


let begin_string str lst =
(str, lst)
let begin_string str lst = (str, lst)


let add_string str1 (str2, lst) =
(str1 ^ str2, lst)
let add_string str1 (str2, lst) = (str1 ^ str2, lst)


let end_string (str, lst) =
(Component str) :: lst
let end_string (str, lst) = (Component str) :: lst


(* Definition of the caracteristic length of a path *)
Expand Down
2 changes: 1 addition & 1 deletion src/FileUtil.mli
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type interactive =
(**
{2 Permission }
*)

(** Base permission. This is the permission corresponding to one user or group.
Expand Down
4 changes: 2 additions & 2 deletions src/FileUtilMV.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let rec mv
?(error=fun str _ -> raise (MvError str))
?(force=Force)
fln_src fln_dst =
let handle_error, handle_exception =
let handle_error, _ =
handle_error_gen "mv" error
(function
| `NoSourceFile ->
Expand All @@ -50,7 +50,7 @@ let rec mv
Printf.sprintf
"Recursive error in 'mv %s %s' for 'cp %s %s': %s"
fn_src fn_dst fn_src fn_dst str
| `MvRm (fn, str, e) ->
| `MvRm (fn, str, _) ->
Printf.sprintf "Recursive error in 'mv %s ..' for 'rm %s': %s"
fn fn str
| #exc -> "")
Expand Down
20 changes: 10 additions & 10 deletions src/FileUtilMode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ let of_int i =
`Other (`Set (`List other))]


let rec to_string: t -> string =
let to_string =
let perm =
function
| `Read -> "r"
Expand Down Expand Up @@ -145,7 +145,7 @@ let rec to_string: t -> string =
fun t -> String.concat "," (List.map clause t)


let rec apply ~is_dir ~umask i (t: t) =
let apply ~is_dir ~umask i (t: t) =
let set who prm b i =
let m = mask who prm in
if b then i lor m else i land (lnot m)
Expand All @@ -154,13 +154,13 @@ let rec apply ~is_dir ~umask i (t: t) =
let m = mask who prm in
(i land m) <> 0
in
let permlist who i lst =
let permlist _who i lst =
List.fold_left
(fun acc ->
function
| `Exec | `Read | `Write | `Sticky | `StickyO as a -> a :: acc
| `ExecX ->
if is_dir ||
if is_dir ||
List.exists (fun who -> get who `Exec i)
[`User; `Group; `Other] then
`Exec :: acc
Expand All @@ -171,9 +171,9 @@ let rec apply ~is_dir ~umask i (t: t) =
| `List lst -> lst
| #perm as prm -> [prm])
in
let permcopy who i =
let permcopy _who i =
List.fold_left
(fun acc (who, prm, _) ->
(fun acc (who, prm, _) ->
if get who prm i then
prm :: acc
else
Expand All @@ -183,12 +183,12 @@ let rec apply ~is_dir ~umask i (t: t) =
let args who i =
function
| #permlist as lst -> permlist who i lst
| #permcopy as who -> permcopy who i
| #permcopy as who -> permcopy who i
in
let rec action who i act =
match act with
match act with
| `Set arg ->
action who
action who
(action who i (`Remove (`List (permcopy who i))))
(`Add arg)
| `Add arg ->
Expand All @@ -203,7 +203,7 @@ let rec apply ~is_dir ~umask i (t: t) =
in
let actionlist_none i lst =
let numask = lnot umask in
let arg_set_if_mask who i arg b =
let arg_set_if_mask who i arg b =
List.fold_left
(fun i prm ->
if get who prm numask then
Expand Down
6 changes: 1 addition & 5 deletions src/FileUtilPWD.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@
(* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *)
(******************************************************************************)

open FileUtilMisc


let pwd () =
FilePath.reduce (Sys.getcwd ())
let pwd () = FilePath.reduce (Sys.getcwd ())
15 changes: 9 additions & 6 deletions src/FileUtilREADLINK.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ let readlink fln =
let rec all_upper_dir_aux lst fln =
let dir = dirname fln in
match lst with
| prev_dir :: tl when prev_dir = dir -> lst
| prev_dir :: _ when prev_dir = dir -> lst
| _ -> all_upper_dir_aux (dir :: lst) dir
in
all_upper_dir_aux [fln] fln
all_upper_dir_aux [fln] fln
in
let ctst =
let st_opt, stL_opt = None, None in
compile_filter ?st_opt ?stL_opt Is_link
in
let ctst = compile_filter Is_link in
let rec readlink_aux already_read fln =
let newly_read = prevent_recursion already_read fln in
let dirs = all_upper_dir fln in
try
try
let src_link = List.find ctst (List.rev dirs) in
let dst_link = Unix.readlink src_link in
let real_link =
Expand All @@ -49,10 +52,10 @@ let readlink fln =
else
reduce dst_link
in
readlink_aux newly_read (reparent src_link real_link fln)
readlink_aux newly_read (reparent src_link real_link fln)
with Not_found ->
fln
in
readlink_aux SetFilename.empty (make_absolute (pwd ()) fln)
readlink_aux SetFilename.empty (make_absolute (pwd ()) fln)


4 changes: 2 additions & 2 deletions src/FileUtilRM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let rm
let exists =
try
let _st: Unix.stats = Unix.lstat fn in
true
true
with Unix.Unix_error(Unix.ENOENT, _, _) ->
false
in
Expand All @@ -81,4 +81,4 @@ let rm
end)
lst
in
rm_aux fln_lst
rm_aux fln_lst
26 changes: 13 additions & 13 deletions src/FileUtilSTAT.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ let stat ?(dereference=false) fln =
else
ustat
in
{
kind = kind_of_stat ustat;
is_link = is_link;
permission = permission_of_int ustat.Unix.LargeFile.st_perm;
size = B ustat.Unix.LargeFile.st_size;
owner = ustat.Unix.LargeFile.st_uid;
group_owner = ustat.Unix.LargeFile.st_gid;
access_time = ustat.Unix.LargeFile.st_atime;
modification_time = ustat.Unix.LargeFile.st_mtime;
creation_time = ustat.Unix.LargeFile.st_ctime;
device = ustat.Unix.LargeFile.st_dev;
inode = ustat.Unix.LargeFile.st_ino;
}
{
kind = kind_of_stat ustat;
is_link = is_link;
permission = permission_of_int ustat.Unix.LargeFile.st_perm;
size = B ustat.Unix.LargeFile.st_size;
owner = ustat.Unix.LargeFile.st_uid;
group_owner = ustat.Unix.LargeFile.st_gid;
access_time = ustat.Unix.LargeFile.st_atime;
modification_time = ustat.Unix.LargeFile.st_mtime;
creation_time = ustat.Unix.LargeFile.st_ctime;
device = ustat.Unix.LargeFile.st_dev;
inode = ustat.Unix.LargeFile.st_ino;
}
with Unix.Unix_error(Unix.ENOENT, _, _) ->
raise (FileDoesntExist fln)

12 changes: 4 additions & 8 deletions src/FileUtilStr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@
(** Compile [FileUtil.Match] expression using [Str.regexp]
*)
let match_compile str =
let regex =
Str.regexp str
in
fun fn -> Str.string_match regex fn 0
let regex = Str.regexp str in
fun fn -> Str.string_match regex fn 0


(** See {!FileUtil.test}
*)
let test =
FileUtil.test ~match_compile:match_compile
let test = FileUtil.test ~match_compile:match_compile


(** See {!FileUtil.find}
*)
let find =
FileUtil.find ~match_compile:match_compile
let find = FileUtil.find ~match_compile:match_compile
Loading

0 comments on commit d054fb4

Please sign in to comment.