Skip to content

Commit ddc3d81

Browse files
committed
Handle PR 27098 change to eval
1 parent e419583 commit ddc3d81

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/PCRE2.jl

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

12+
const V6_COMPAT = VERSION < v"0.7.0-DEV"
13+
1214
if VERSION >= v"0.7.0-DEV.3382"
1315
import Libdl
1416
end
@@ -28,15 +30,15 @@ end
2830

2931
const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
3032

31-
@static if VERSION < v"v0.7.0-DEV"
33+
@static if V6_COMPAT
3234
macro preserve(args...)
3335
syms = args[1:end-1]
3436
for x in syms
3537
isa(x, Symbol) || error("Preserved variable must be a symbol")
3638
end
3739
esc(quote ; $(args[end]) ; end)
3840
end
39-
ev(s) = eval(parse(s))
41+
evr(str, rep, sub) = eval(current_module(), parse(replace(str, rep, sub)))
4042
const Nothing = Void
4143
const Cvoid = Void
4244
_ncodeunits(::Type{UInt8}, s) = sizeof(s)
@@ -46,7 +48,7 @@ const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
4648
create_vector(T, len) = Vector{T}(len)
4749
else # !V6_COMPAT
4850
import Base.GC: @preserve
49-
ev(s) = eval(Meta.parse(s))
51+
evr(str, rep, sub) = Core.eval(@__MODULE__, Meta.parse(replace(str, rep => sub)))
5052
const _ncodeunits = ncodeunits
5153
create_vector(T, len) = Vector{T}(undef, len)
5254
end
@@ -62,9 +64,8 @@ for siz in (8,16,32), (nam, ret, sig) in funclist
6264
l = SubString("a,b,c,d,e,f,g,h,i,j,k,l,m", 1, length(sig)*2-1)
6365
#parms = string(["$('a'+i-1)::$(sig[i]), " for i=1:length(sig)]...)[1:end-1]
6466
sub = "UInt$siz"
65-
rep = "PCRE2._UCHAR"
6667
str = "$nam(::Type{$sub},$l)=ccall((:pcre2_$(nam)_$siz, libpcre2_$siz),$ret,$sig,$l)"
67-
ev(@static VERSION < v"v0.7.0-DEV" ? replace(str, rep, sub) : replace(str, rep => sub))
68+
evr(str, "PCRE2._UCHAR", sub)
6869
end
6970

7071
const UNSET = ~Csize_t(0) # Indicates that an output vector element is unset

0 commit comments

Comments
 (0)