Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Re.Pcre instead of Pcre #9

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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