@@ -1227,9 +1227,17 @@ module Fun = struct
1227
1227
end
1228
1228
1229
1229
module In_channel = struct
1230
- include In_channel
1230
+ let stdlib_input_line = input_line
1231
+ [@@ if ocaml_version > = (4 , 14 , 0 )]
1232
+
1233
+ module In_channel = In_channel
1231
1234
[@@ if ocaml_version > = (4 , 14 , 0 )]
1232
1235
1236
+ module In_channel = struct end
1237
+ [@@ if ocaml_version < (4 , 14 , 0 )]
1238
+
1239
+ include In_channel
1240
+
1233
1241
(* Read up to [len] bytes into [buf], starting at [ofs]. Return total bytes
1234
1242
read. *)
1235
1243
let read_upto ic buf ofs len =
@@ -1325,6 +1333,18 @@ module In_channel = struct
1325
1333
end
1326
1334
[@@ if ocaml_version < (4 , 14 , 0 )]
1327
1335
1336
+ (* [In_channel.input_lines] only exists in the stdlib since 5.1. We would
1337
+ also like to use tail modulo cons (introduced in 4.14.0) to implement it
1338
+ here for versions between 4.14.0 and 5.1.0, because it gives better
1339
+ performance. Here we reimplement it for all versions of OCaml due to a
1340
+ limitation of [ppx_optcompt_light], namely, that it doesn't support
1341
+ version ranges. *)
1342
+ let [@ tail_mod_cons] rec input_lines ic =
1343
+ match stdlib_input_line ic with
1344
+ | line -> line :: input_lines ic
1345
+ | exception End_of_file -> []
1346
+ [@@ if ocaml_version > = (4 , 14 , 0 )]
1347
+
1328
1348
let input_lines ic =
1329
1349
let rec aux acc =
1330
1350
match input_line ic with
0 commit comments