From 85d15ff3a0eee53e80d7634039530899d594e08d Mon Sep 17 00:00:00 2001 From: malc Date: Sun, 20 May 2018 06:42:52 +0300 Subject: [PATCH] Cosmetics --- help.ml | 50 +++++++++++++++++++++++++------------------------- link.c | 6 ++++++ version.c | 11 +---------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/help.ml b/help.ml index 3c56d6b..d8f53f5 100644 --- a/help.ml +++ b/help.ml @@ -1,28 +1,3 @@ -open Utils;; - -external fz_version : unit -> string = "ml_fz_version";; -external llpp_version : unit -> string = "ml_llpp_version";; - -let gotourl launcher url = - let command = Str.global_replace percentsre url launcher in - try ignore @@ spawn command [] - with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn -;; - -let gotouri launcher uri = - if emptystr launcher - then dolog "%s" uri - else - if nonemptystr @@ geturl uri - then gotourl launcher uri - else dolog "obtained empty url from uri %S" uri -;; - -let version () = - Printf.sprintf "llpp version %s, fitz %s, ocaml %s/%d bit" - (llpp_version ()) (fz_version ()) Sys.ocaml_version Sys.word_size -;; - let keys = {|-----Quitting----- escape/q - quit @@ -200,6 +175,31 @@ selection command otherwise o Text selection is limited to a single page o Text searching is very naive|};; +open Utils;; + +external fz_version : unit -> string = "ml_fz_version";; +external llpp_version : unit -> string = "ml_llpp_version";; + +let gotourl launcher url = + let command = Str.global_replace percentsre url launcher in + try ignore @@ spawn command [] + with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn +;; + +let gotouri launcher uri = + if emptystr launcher + then dolog "%s" uri + else + if nonemptystr @@ geturl uri + then gotourl launcher uri + else dolog "obtained empty url from uri %S" uri +;; + +let version () = + Printf.sprintf "llpp version %s, fitz %s, ocaml %s/%d bit" + (llpp_version ()) (fz_version ()) Sys.ocaml_version Sys.word_size +;; + let makehelp launcher = let strings = fz_version () diff --git a/link.c b/link.c index e08bee9..4a94a83 100644 --- a/link.c +++ b/link.c @@ -4113,6 +4113,12 @@ CAMLprim value ml_fz_version (void) return caml_copy_string (FZ_VERSION); } +CAMLprim value ml_llpp_version (void) +{ + extern char llpp_version[]; + return caml_copy_string (llpp_version); +} + CAMLprim void ml_init (value csock_v, value params_v) { CAMLparam2 (csock_v, params_v); diff --git a/version.c b/version.c index 674f92b..bf93fb9 100644 --- a/version.c +++ b/version.c @@ -1,11 +1,2 @@ -#define CAML_NAME_SPACE -#include -#include - #define stringify(x) #x -#define ver stringify (LLPP_VERSION) - -CAMLprim value ml_llpp_version (void) -{ - return caml_copy_string (ver); -} +const char llpp_version[] = stringify (LLPP_VERSION);