Skip to content

Commit

Permalink
Don't rely on PCRE internals (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored Jul 26, 2019
1 parent 18fb710 commit 1f498a6
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ valid(r::AbstractRange) = r !== NULL_RANGE
function nullmatch(r::Regex, ctx::Context)
source = ctx.source
index = ctx.pos[]
Base.compile(r)
if Base.PCRE.exec(r.regex, source, index - 1, r.match_options, r.match_data)
range = Int(r.ovec[1] + 1):Int(r.ovec[2])
count = div(length(r.ovec), 2) - 1
if count > 0
length(ctx.captures) < count && resize!(ctx.captures, count)
for i = 1:count
ctx.captures[i] = r.ovec[2i + 1] == Base.PCRE.UNSET ?
NULL_RANGE : (Int(r.ovec[2i + 1] + 1):Int(r.ovec[2i + 2]))
m = match(r, source[index:end])
if m === nothing
return NULL_RANGE
else
if length(m.captures) > 0
length(ctx.captures) < length(m.captures) && resize!(ctx.captures, length(m.captures))
for i = 1:length(m.captures)
ctx.captures[i] = (m.captures[i] === nothing) ? NULL_RANGE :
(index + m.offsets[i] - 1 : index + m.offsets[i] + ncodeunits(m.captures[i]) - 2)
end
end
return range
else
return NULL_RANGE
return index : index + ncodeunits(m.match) - 1
end
end
nullmatch(f::Function, ctx::Context) = f(ctx)
Expand Down

2 comments on commit 1f498a6

@mortenpi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Maintenance & bugfix release.

  • Drop support for Julia < 1.0 (#26)
  • Remove reliance on Base.PCRE internals which changed in Julia 1.3 (#27)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/2310

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 1f498a64013582b99ff2593c1c6959b1ef5a3fd6
git push origin v0.4.0

Please sign in to comment.