Skip to content

Commit

Permalink
Use Re.Pcre instead of Pcre
Browse files Browse the repository at this point in the history
Rationale: Pcre depends on an obsolete library:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000004
  • Loading branch information
glondu committed Jul 29, 2023
1 parent 84a198f commit cb3371c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .merlin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
B src/**
S src/**
B +threads
PKG pcre
PKG re
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please read the COPYING file before using this software.

- ocaml
- findlib
- ocaml-pcre
- ocaml-re
- dune

## Compilation:
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
(depends
(ocaml (>= 4.07.0))
dune
pcre)
re)
)
2 changes: 1 addition & 1 deletion duppy.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
8 changes: 5 additions & 3 deletions examples/http.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Pcre = Re.Pcre

let non_blocking_queues = ref 3
let maybe_blocking_queues = ref 1
let files_path = ref ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 2 additions & 0 deletions src/duppy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*****************************************************************************)

module Pcre = Re.Pcre

type fd = Unix.file_descr

external poll :
Expand Down

0 comments on commit cb3371c

Please sign in to comment.