@@ -9,11 +9,7 @@ Licensed under MIT License, see LICENSE.md
9
9
__precompile__ ()
10
10
module PCRE2
11
11
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
17
13
18
14
# Load in `deps.jl`, complaining if it does not exist
19
15
const depsjl_path = joinpath (dirname (@__FILE__ ), " .." , " deps" , " deps.jl" )
@@ -22,36 +18,25 @@ if !isfile(depsjl_path)
22
18
end
23
19
include (depsjl_path)
24
20
21
+ PCRE_LOCK = nothing
22
+
25
23
# Module initialization function
26
24
function __init__ ()
27
25
# Always check your dependencies from `deps.jl`
28
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
29
32
end
30
33
31
34
const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
32
35
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)
55
40
56
41
import Base: RefValue
57
42
@@ -88,9 +73,9 @@ jit_error(errno::Integer) = throw(PCRE2_Error("JIT ", errno))
88
73
compile_error (errno, erroff) = throw (PCRE2_Error (" compilation " , errno, erroff))
89
74
90
75
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" )
94
79
pcre_error (errno)
95
80
end
96
81
0 commit comments