Skip to content

Commit bb98730

Browse files
authored
Fix OCaml 5 compatibility (#110)
* Fix OCaml 5 compatibility By removing the compatibility with 4.02.3. The opam dependencies have a constraint on OCaml >= 4.08.0 anyways. * Replace Lwt_log with Logs_lwt * Remove asciiart example which doesn't build on OCaml 5
1 parent aed0eb6 commit bb98730

File tree

13 files changed

+25
-256
lines changed

13 files changed

+25
-256
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434

3535
- run: opam install . --deps-only --with-test
3636

37-
- run: opam install camlimages
38-
3937
- run: opam exec -- dune build
4038

4139
- run: opam exec -- dune runtest

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ To build the examples:
5656

5757
Binaries for the examples will be in `_build/default/examples`.
5858

59-
The `asciiart` example is not built by default as it as an additional
60-
dependency on the `camlimages` library. To build it run:
61-
62-
$ dune build examples/asciiart/asciiart.exe
63-
6459
Terminal emulators compatibility
6560
--------------------------------
6661

dune-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ facilities in console applications.")
2828
(depends
2929
(ocaml
3030
(>= 4.08.0))
31+
logs
3132
(lwt
3233
(>= 4.2.0))
33-
lwt_log
3434
lwt_react
3535
(mew_vi
3636
(and

dune-workspace.dev

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
(lang dune 1.1)
22

33
;; This file is used by `make all-supported-ocaml-versions`
4-
(context (opam (switch 4.02.3)))
5-
(context (opam (switch 4.03.0)))
6-
(context (opam (switch 4.04.2)))
7-
(context (opam (switch 4.05.0)))
8-
(context (opam (switch 4.06.1)))
9-
(context (opam (switch 4.07.0)))
10-
4+
(context (opam (switch 4.08.1)))
5+
(context (opam (switch 4.09.1)))
6+
(context (opam (switch 4.10.2)))
7+
(context (opam (switch 4.11.2)))
8+
(context (opam (switch 4.12.1)))
9+
(context (opam (switch 4.13.1)))
10+
(context (opam (switch 4.14.0)))

examples/asciiart/asciiart.ml

Lines changed: 0 additions & 215 deletions
This file was deleted.

examples/asciiart/dune

Lines changed: 0 additions & 5 deletions
This file was deleted.

lambda-term.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ bug-reports: "https://github.com/ocaml-community/lambda-term/issues"
1818
depends: [
1919
"dune" {>= "3.0"}
2020
"ocaml" {>= "4.08.0"}
21+
"logs"
2122
"lwt" {>= "4.2.0"}
22-
"lwt_log"
2323
"lwt_react"
2424
"mew_vi" {>= "0.5.0" & < "0.6.0"}
2525
"react"

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(name lambda_term)
33
(public_name lambda-term)
44
(wrapped false)
5-
(libraries lwt lwt.unix lwt_react zed lwt_log mew_vi uucp)
5+
(libraries logs logs.lwt lwt lwt.unix lwt_react zed mew_vi uucp)
66
(flags (:standard -safe-string))
77
(synopsis "Cross-platform library for terminal manipulation")
88
(c_library_flags (:standard (:include c_library_flags)))

src/lTerm_buttons_impl.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module Make (LiteralIntf: LiteralIntf.Type) = struct
1313
open LTerm_mouse
1414
open LTerm_widget_callbacks
1515

16-
let section = Lwt_log.Section.make "lambda-term(buttons_impl)"
17-
1816
class t = LTerm_widget_base_impl.t
1917

2018
let space = Char(Uchar.of_char ' ')

src/lTerm_history.ml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ let unescape line =
321321
in
322322
loop 0 0
323323

324-
let section = Lwt_log.Section.make "lambda-term(history)"
324+
325+
let src = Logs.Src.create "lambda-term.history" ~doc:"logs LTerm_history module's events"
326+
module Log = (val Logs_lwt.src_log src : Logs_lwt.LOG)
325327

326328
let rec safe_lockf fn fd cmd ofs =
327329
Lwt.catch (fun () ->
@@ -331,7 +333,7 @@ let rec safe_lockf fn fd cmd ofs =
331333
| Unix.Unix_error (Unix.EINTR, _, _) ->
332334
safe_lockf fn fd cmd ofs
333335
| Unix.Unix_error (error, _, _) ->
334-
Lwt_log.ign_warning_f ~section "failed to lock file '%s': %s" fn (Unix.error_message error);
336+
Log.warn (fun m -> m "failed to lock file '%s': %s" fn (Unix.error_message error)) >>= fun () ->
335337
return false
336338
| exn -> Lwt.fail exn)
337339

@@ -344,7 +346,7 @@ let open_history fn =
344346
| Unix.Unix_error (Unix.ENOENT, _, _) ->
345347
return None
346348
| Unix.Unix_error (Unix.EACCES, _, _) ->
347-
Lwt_log.ign_info_f "cannot open file '%s' in read and write mode: %s" fn (Unix.error_message Unix.EACCES);
349+
Log.info (fun m -> m "cannot open file '%s' in read and write mode: %s" fn (Unix.error_message Unix.EACCES)) >>= fun () ->
348350
(* If the file cannot be openned in read & write mode,
349351
open it in read only mode but do not lock it. *)
350352
Lwt.catch (fun () ->
@@ -369,7 +371,7 @@ let load history ?log ?(skip_empty=true) ?(skip_dup=true) fn =
369371
func
370372
| None ->
371373
fun line msg ->
372-
Lwt_log.ign_error_f ~section "File %S, at line %d: %s" fn line msg
374+
Log.info (fun m -> m "File %S, at line %d: %s" fn line msg)
373375
in
374376
(* File opening. *)
375377
open_history fn >>= fun history_file ->
@@ -392,11 +394,12 @@ let load history ?log ?(skip_empty=true) ?(skip_dup=true) fn =
392394
if not (skip_empty && is_empty entry) && not (skip_dup && is_dup history entry) then begin
393395
add_aux history entry size;
394396
history.old_count <- history.length
395-
end
397+
end;
398+
Lwt.return ()
396399
with
397400
| Zed_string.Invalid (msg, _)-> log num msg
398401
| Zed_utf8.Invalid (msg, _)-> log num msg
399-
);
402+
) >>= fun () ->
400403
aux (num + 1)
401404
in
402405
aux 1)

0 commit comments

Comments
 (0)