Skip to content

Commit 12acd56

Browse files
committed
Use PCRE2_jll instead of build
1 parent 0b6e8d4 commit 12acd56

File tree

6 files changed

+47
-120
lines changed

6 files changed

+47
-120
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.5'
1413
- '1.6'
14+
- '1.7'
1515
- 'nightly'
1616
os:
1717
- ubuntu-latest

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ keywords = ["Strings", "PCRE", "Regex"]
44
license = "MIT"
55
name = "PCRE2"
66
uuid = "c9310f65-a42c-5928-aca3-d34f64192029"
7-
version = "1.0.2"
7+
version = "1.1.0"
88

99
[deps]
10+
PCRE2_jll = "efcefdf7-47ab-520b-bdef-62a2eaa19f15"
1011
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
11-
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
1212

1313
[extras]
1414
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -17,4 +17,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1717
test = ["Test"]
1818

1919
[compat]
20-
julia = "^1.0.0"
20+
julia = "^1.7"

deps/build.jl

Lines changed: 0 additions & 43 deletions
This file was deleted.

deps/build.jl~

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/PCRE2.jl

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
11
#=
22
Low-level wrapper for PCRE2 library
33
4-
Copyright 2018 Gandalf Software, Inc., Scott P. Jones, and contributors to pcre.jl and pcre2.h
4+
Copyright 2018,2022 Gandalf Software, Inc., Scott P. Jones, and contributors to pcre.jl and pcre2.h
55
(Based in part on julia/base/pcre.jl, and on pcre2.h (copyright University of Cambridge))
66
Licensed under MIT License, see LICENSE.md
77
=#
88

9-
__precompile__()
109
module PCRE2
1110

1211
import Libdl
12+
using PCRE2_jll
1313

14-
# Load in `deps.jl`, complaining if it does not exist
15-
const depsjl_path = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
16-
if !isfile(depsjl_path)
17-
error("PCRE2 not installed properly, run Pkg.build(\"PCRE2\"), restart Julia and try again")
18-
end
19-
include(depsjl_path)
14+
const PCRE_LOCK = Base.PCRE.PCRE_COMPILE_LOCK
15+
16+
# Base.Experimental.@compiler_options compile=min optimize=0 infer=false
2017

21-
PCRE_LOCK = nothing
18+
export libpcre2_8, libpcre2_16, libpcre2_32
19+
20+
# These get calculated in __init__()
21+
libpcre2_16_handle = C_NULL
22+
libpcre2_16_path = ""
23+
libpcre2_32_handle = C_NULL
24+
libpcre2_32_path = ""
25+
26+
if Sys.iswindows()
27+
const libpcre2_16 = "libpcre2-16-0.dll"
28+
const libpcre2_32 = "libpcre2-32-0.dll"
29+
elseif Sys.isapple()
30+
const libpcre2_16 = "libpcre2-16.0.dylib"
31+
const libpcre2_32 = "libpcre2-32.0.dylib"
32+
else
33+
const libpcre2_16 = "libpcre2-16.so.0"
34+
const libpcre2_32 = "libpcre2-32.so.0"
35+
end
2236

23-
# Module initialization function
2437
function __init__()
25-
# Always check your dependencies from `deps.jl`
26-
check_deps()
27-
@static if isdefined(Base.PCRE, :PCRE_COMPILE_LOCK)
28-
global PCRE_LOCK = Base.PCRE.PCRE_COMPILE_LOCK
29-
else
30-
global PCRE_LOCK = Threads.SpinLock()
31-
end
38+
global libpcre2_16_handle = Libdl.dlopen(libpcre2_16)
39+
global libpcre2_16_path = Libdl.dlpath(libpcre2_16_handle)
40+
global libpcre2_32_handle = Libdl.dlopen(libpcre2_32)
41+
global libpcre2_32_path = Libdl.dlpath(libpcre2_32_handle)
3242
end
3343

44+
# ??? get_libpcre2_8_path() = libpcre2_8_path
45+
3446
const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
3547

3648
import Base.GC: @preserve

src/pcre2_h.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#=
22
Constants for PCRE2 library API
33
4-
Copyright 2018 Gandalf Software, Inc., Scott P. Jones, and contributors to pcre2.h
4+
Copyright 2018,2022 Gandalf Software, Inc., Scott P. Jones, and contributors to pcre2.h
55
(based on pcre2.h (copyright University of Cambridge), see PCRE2_LICENSE)
66
Licensed under MIT License, see LICENSE.md
77
=#
@@ -49,19 +49,24 @@ const ALT_VERBNAMES = 0x00400000 # C
4949
const USE_OFFSET_LIMIT = 0x00800000 # J M D
5050
const EXTENDED_MORE = 0x01000000 # C
5151
const LITERAL = 0x02000000 # C
52+
const MATCH_INVALID_UTF = 0x04000000 # J M D
5253

5354
## An additional compile options word is available in the compile context.
5455

5556
const EXTRA_ALLOW_SURROGATE_ESCAPES = 0x00000001 # C
5657
const EXTRA_BAD_ESCAPE_IS_LITERAL = 0x00000002 # C
5758
const EXTRA_MATCH_WORD = 0x00000004 # C
5859
const EXTRA_MATCH_LINE = 0x00000008 # C
60+
const EXTRA_ESCAPED_CR_IS_LF = 0x00000010 # C
61+
const EXTRA_ALT_BSUX = 0x00000020 # C
62+
const EXTRA_ALLOW_LOOKAROUND_BSK = 0x00000040 # C
5963

6064
## These are for pcre2_jit_compile().
6165

62-
const JIT_COMPLETE = 0x00000001 # For full matching */
66+
const JIT_COMPLETE = 0x00000001 # For full matching
6367
const JIT_PARTIAL_SOFT = 0x00000002
6468
const JIT_PARTIAL_HARD = 0x00000004
69+
const JIT_INVALID_UTF = 0x00000100
6570

6671
## These are for pcre2_match(), pcre2_dfa_match(), and pcre2_jit_match().
6772
## Note that PCRE2_ANCHORED and PCRE2_NO_UTF_CHECK can also be passed to these functions
@@ -91,6 +96,11 @@ const SUBSTITUTE_OVERFLOW_LENGTH = 0x00001000
9196

9297
const NO_JIT = 0x00002000
9398

99+
const COPY_MATCHED_SUBJECT = 0x00004000
100+
const SUBSTITUTE_LITERAL = 0x00008000 # pcre2_substitute() only
101+
const SUBSTITUTE_MATCHED = 0x00010000 # pcre2_substitute() only
102+
const SUBSTITUTE_REPLACEMENT_ONLY = 0x00020000 # pcre2_substitute() only
103+
94104
## Options for pattern_convert()
95105

96106
const CONVERT_UTF = 0x00000001
@@ -162,8 +172,8 @@ const BSR_ANYCRLF = 2
162172
CONFIG_VERSION,
163173
CONFIG_HEAPLIMIT,
164174
CONFIG_NEVER_BACKSLASH_C,
165-
CONFIG_COMPILED_WIDTHS)
166-
175+
CONFIG_COMPILED_WIDTHS,
176+
CONFIG_TABLES_LENGTH)
167177

168178
# supported options for different use cases
169179

0 commit comments

Comments
 (0)