From cb3371cc88a60041b40b0548f6bd2a1bde60a8a0 Mon Sep 17 00:00:00 2001 From: Stephane Glondu Date: Thu, 2 Dec 2021 08:08:48 +0100 Subject: [PATCH] Use Re.Pcre instead of Pcre Rationale: Pcre depends on an obsolete library: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000004 --- .merlin | 2 +- README.md | 2 +- dune-project | 2 +- duppy.opam | 2 +- examples/http.ml | 8 +++++--- src/dune | 2 +- src/duppy.ml | 2 ++ 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.merlin b/.merlin index 6db9a00..82741a3 100644 --- a/.merlin +++ b/.merlin @@ -1,4 +1,4 @@ B src/** S src/** B +threads -PKG pcre +PKG re diff --git a/README.md b/README.md index c42f4ed..88332c8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Please read the COPYING file before using this software. - ocaml - findlib -- ocaml-pcre +- ocaml-re - dune ## Compilation: diff --git a/dune-project b/dune-project index 5866385..6c16419 100644 --- a/dune-project +++ b/dune-project @@ -14,5 +14,5 @@ (depends (ocaml (>= 4.07.0)) dune - pcre) + re) ) diff --git a/duppy.opam b/duppy.opam index bdff20a..84859ca 100644 --- a/duppy.opam +++ b/duppy.opam @@ -10,7 +10,7 @@ bug-reports: "https://github.com/savonet/ocaml-duppy/issues" depends: [ "ocaml" {>= "4.07.0"} "dune" {>= "2.7"} - "pcre" + "re" "odoc" {with-doc} ] build: [ diff --git a/examples/http.ml b/examples/http.ml index a96903a..8a790ec 100644 --- a/examples/http.ml +++ b/examples/http.ml @@ -1,3 +1,5 @@ +module Pcre = Re.Pcre + let non_blocking_queues = ref 3 let maybe_blocking_queues = ref 1 let files_path = ref "" @@ -275,7 +277,7 @@ let cgi_handler process path h request = (Filename.quote tr_suffix) (Filename.quote suffix) in let sanitize s = - Pcre.replace ~pat:"-" ~templ:"_" (String.uppercase_ascii s) + Pcre.substitute ~rex:(Pcre.regexp "-") ~subst:(fun _ -> "_") (String.uppercase_ascii s) in let headers = List.map (fun (x, y) -> (sanitize x, y)) request.request_headers @@ -341,7 +343,7 @@ let cgi_handler process path h request = in ignore (Unix.close_process (in_c, out_c)); let __pa_duppy_0 = - let headers = Pcre.split ~pat:"\r\n" headers in + let headers = Pcre.split ~rex:(Pcre.regexp "\r\n") headers in parse_headers headers in Duppy.Monad.bind __pa_duppy_0 (fun headers -> @@ -401,7 +403,7 @@ let handle_request h request = let parse_request h r = try - let headers = Pcre.split ~pat:"\r\n" r in + let headers = Pcre.split ~rex:(Pcre.regexp "\r\n") r in let __pa_duppy_0 = match headers with | e :: l -> diff --git a/src/dune b/src/dune index 1f5caa0..3062ce8 100644 --- a/src/dune +++ b/src/dune @@ -1,7 +1,7 @@ (library (name duppy) (public_name duppy) - (libraries unix threads pcre) + (libraries unix threads re) (foreign_stubs (language c) (names duppy_stubs)) diff --git a/src/duppy.ml b/src/duppy.ml index dc82e26..e119368 100644 --- a/src/duppy.ml +++ b/src/duppy.ml @@ -20,6 +20,8 @@ *****************************************************************************) +module Pcre = Re.Pcre + type fd = Unix.file_descr external poll :