Skip to content

Commit 5bb27da

Browse files
committed
Update for changes in Base regex support
1 parent 6e02811 commit 5bb27da

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

Project.toml

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

99
[deps]
1010
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

src/PCRE2.jl

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ Licensed under MIT License, see LICENSE.md
99
__precompile__()
1010
module PCRE2
1111

12-
const V6_COMPAT = VERSION < v"0.7.0-DEV"
13-
14-
if VERSION >= v"0.7.0-DEV.3382"
15-
import Libdl
16-
end
12+
import Libdl
1713

1814
# Load in `deps.jl`, complaining if it does not exist
1915
const depsjl_path = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
@@ -22,36 +18,25 @@ if !isfile(depsjl_path)
2218
end
2319
include(depsjl_path)
2420

21+
PCRE_LOCK = nothing
22+
2523
# Module initialization function
2624
function __init__()
2725
# Always check your dependencies from `deps.jl`
2826
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
2932
end
3033

3134
const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
3235

33-
@static if V6_COMPAT
34-
macro preserve(args...)
35-
syms = args[1:end-1]
36-
for x in syms
37-
isa(x, Symbol) || error("Preserved variable must be a symbol")
38-
end
39-
esc(quote ; $(args[end]) ; end)
40-
end
41-
evr(str, rep, sub) = eval(current_module(), parse(replace(str, rep, sub)))
42-
const Nothing = Void
43-
const Cvoid = Void
44-
_ncodeunits(::Type{UInt8}, s) = sizeof(s)
45-
_ncodeunits(::Type{UInt16}, s) = sizeof(s)>>>1
46-
_ncodeunits(::Type{UInt32}, s) = sizeof(s)>>>2
47-
_ncodeunits(s) = _ncodeunits(codeunit(s), s)
48-
create_vector(T, len) = Vector{T}(len)
49-
else # !V6_COMPAT
50-
import Base.GC: @preserve
51-
evr(str, rep, sub) = Core.eval(@__MODULE__, Meta.parse(replace(str, rep => sub)))
52-
const _ncodeunits = ncodeunits
53-
create_vector(T, len) = Vector{T}(undef, len)
54-
end
36+
import Base.GC: @preserve
37+
evr(str, rep, sub) = Core.eval(@__MODULE__, Meta.parse(replace(str, rep => sub)))
38+
const _ncodeunits = ncodeunits
39+
create_vector(T, len) = Vector{T}(undef, len)
5540

5641
import Base: RefValue
5742

@@ -88,9 +73,9 @@ jit_error(errno::Integer) = throw(PCRE2_Error("JIT ", errno))
8873
compile_error(errno, erroff) = throw(PCRE2_Error("compilation ", errno, erroff))
8974

9075
function info_error(errno)
91-
errno == ERROR_NULL && pcre_error("NULL regex object")
92-
errno == ERROR_BADMAGIC && pcre_error("Invalid regex object")
93-
errno == ERROR_BADOPTION && pcre_error("Invalid option flags")
76+
errno == Base.PCRE.ERROR_NULL && pcre_error("NULL regex object")
77+
errno == Base.PCRE.ERROR_BADMAGIC && pcre_error("Invalid regex object")
78+
errno == Base.PCRE.ERROR_BADOPTION && pcre_error("Invalid option flags")
9479
pcre_error(errno)
9580
end
9681

0 commit comments

Comments
 (0)