Skip to content

Commit

Permalink
Restore compatibility with OCaml < 4.07
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Nov 16, 2022
1 parent 01a6f2c commit 4813c44
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/mode_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)

let stdlib_stdout = stdout

open Unix
open Unix.LargeFile
open Printf
Expand Down Expand Up @@ -123,7 +125,7 @@ let rec build debug
(PackageSet.cardinal packages);
if debug >= 2 then (
List.iter (printf " - %s\n") pretty_packages;
flush Stdlib.stdout
flush stdlib_stdout
)
);

Expand Down Expand Up @@ -207,7 +209,7 @@ let rec build debug
(List.length files);
if debug >= 2 then (
List.iter (fun { ft_path = path } -> printf " - %s\n" path) files;
flush Stdlib.stdout
flush stdlib_stdout
)
);

Expand Down
18 changes: 10 additions & 8 deletions src/supermin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)

let stdlib_stderr = stderr

open Unix
open Unix.LargeFile
open Printf
Expand Down Expand Up @@ -296,27 +298,27 @@ let () =
main ()
with
| Unix.Unix_error (code, fname, "") -> (* from a syscall *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "error: %s: %s" fname (Unix.error_message code)
| Unix.Unix_error (code, fname, param) -> (* from a syscall *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "error: %s: %s: %s" fname (Unix.error_message code) param
| Failure msg -> (* from failwith/failwithf *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "failure: %s" msg
| Librpm.Multiple_matches (package, count) -> (* from librpm *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "RPM error: %d occurrences for %s" count package
| Invalid_argument msg -> (* probably should never happen *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "internal error: invalid argument: %s" msg
| Assert_failure (file, line, char) -> (* should never happen *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "internal error: assertion failed at %s, line %d, char %d"
file line char
| Not_found -> (* should never happen *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "internal error: Not_found exception was thrown"
| exn -> (* something not matched above *)
Printexc.print_backtrace Stdlib.stderr;
Printexc.print_backtrace stdlib_stderr;
error "exception: %s" (Printexc.to_string exn)
6 changes: 4 additions & 2 deletions src/utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)

let stdlib_compare = compare

open Unix
open Unix.LargeFile
open Printf
Expand All @@ -40,7 +42,7 @@ let dir_exists name =
try (stat name).st_kind = S_DIR
with Unix_error _ -> false

let uniq ?(cmp = Stdlib.compare) xs =
let uniq ?(cmp = stdlib_compare) xs =
let rec loop acc = function
| [] -> acc
| [x] -> x :: acc
Expand All @@ -51,7 +53,7 @@ let uniq ?(cmp = Stdlib.compare) xs =
in
List.rev (loop [] xs)

let sort_uniq ?(cmp = Stdlib.compare) xs =
let sort_uniq ?(cmp = stdlib_compare) xs =
let xs = List.sort cmp xs in
let xs = uniq ~cmp xs in
xs
Expand Down

0 comments on commit 4813c44

Please sign in to comment.