File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -55,14 +55,29 @@ let major_minor_from_pgconfig () =
5555 in
5656 Fun. protect ~finally: (fun () -> close_in ic) (fun () -> pg_major_minor ic)
5757
58+ let keep_digits =
59+ let rec aux version_line len i =
60+ if i < len then
61+ match version_line.[i] with
62+ | '0' .. '9' | '.' -> aux version_line len (i + 1 )
63+ | _ -> i
64+ else i
65+ in
66+ fun version_line ->
67+ let len = String. length version_line in
68+ let cut = aux version_line len 0 in
69+ String. sub version_line 0 cut
70+
5871let major_minor_from_pkg_config () =
5972 let bin = Sys. getenv_opt " PKG_CONFIG" |> Option. value ~default: " pkg-config" in
6073 let args = Sys. getenv_opt " PKG_CONFIG_ARGN" |> Option. value ~default: " " in
6174 let cmd = Format. asprintf " %s %s --modversion libpq" bin args in
6275 let ic = Unix. open_process_in cmd in
6376 Fun. protect ~finally: (fun () -> close_in ic) @@ fun () ->
6477 let version_line = input_line ic in
65- match String. split_on_char '.' version_line with
78+ match String. split_on_char '.' (keep_digits version_line) with
79+ | [major] ->
80+ (" -DPG_OCAML_MAJOR_VERSION=" ^ major, " -DPG_OCAML_MINOR_VERSION=0" )
6681 | major :: minor :: _ ->
6782 (" -DPG_OCAML_MAJOR_VERSION=" ^ major, " -DPG_OCAML_MINOR_VERSION=" ^ minor)
6883 | _ ->
You can’t perform that action at this time.
0 commit comments