1
- open Base
2
- open Stdio
1
+ open Printf
3
2
4
3
let find_number ~pos str =
5
4
let len = String. length str in
@@ -20,7 +19,7 @@ let find_number ~pos str =
20
19
| _ -> [] , pos
21
20
in
22
21
let number_lst, next = loop ~pos in
23
- String. concat number_lst, next
22
+ String. concat " " number_lst, next
24
23
25
24
let () =
26
25
let module C = Configurator. V1 in
@@ -30,26 +29,26 @@ let () =
30
29
try Unix. open_process_in cmd
31
30
with exc -> eprintf " could not open pg_config, cmd: '%s'" cmd; raise exc
32
31
in
33
- Exn. protectx ic ~finally: In_channel. close ~f: (fun ic ->
34
- let pgsql_includedir = " -I" ^ In_channel. input_line_exn ic in
35
- let pgsql_libdir = " -L" ^ In_channel. input_line_exn ic in
32
+ Fun. protect ~finally: (fun () -> close_in ic) ( fun () ->
33
+ let pgsql_includedir = " -I" ^ input_line ic in
34
+ let pgsql_libdir = " -L" ^ input_line ic in
36
35
let major, minor =
37
- let line = In_channel. input_line_exn ic in
36
+ let line = input_line ic in
38
37
let print_fail () =
39
38
eprintf " Unable to find versions from line '%s', cmd: '%s'" line cmd
40
39
in
41
- let exit_fail () = print_fail () ; Caml. exit 1 in
40
+ let exit_fail () = print_fail () ; exit 1 in
42
41
try
43
- let first_space = String. index_exn line ' ' in
42
+ let first_space = String. index line ' ' in
44
43
let major, next = find_number ~pos: first_space line in
45
44
let minor =
46
45
(* Can also handle release candidates *)
47
46
let c = line.[next] in
48
- if Char. ( c = '.' ) then fst (find_number ~pos: next line)
49
- else if Char. ( c <> 'r' || line.[next + 1 ] <> 'c' ) then exit_fail ()
47
+ if c = '.' then fst (find_number ~pos: next line)
48
+ else if c <> 'r' || line.[next + 1 ] <> 'c' then exit_fail ()
50
49
else " 0"
51
50
in
52
- if String. ( major = " " || minor = " " ) then exit_fail ()
51
+ if major = " " || minor = " " then exit_fail ()
53
52
else
54
53
" -DPG_OCAML_MAJOR_VERSION=" ^ major,
55
54
" -DPG_OCAML_MINOR_VERSION=" ^ minor
0 commit comments