Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions spec/std/regex_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,12 @@ describe "Regex" do
/foo/.matches?("foo", options: Regex::Options::ANCHORED).should be_true
end

it "doesn't crash with a large single line string" do
{% if Regex::Engine.resolve.name == "Regex::PCRE" %}
LibPCRE.config LibPCRE::CONFIG_JIT, out jit_enabled
pending! "PCRE JIT mode not available." unless 1 == jit_enabled
{% end %}
it "matches a large single line string" do
LibPCRE.config LibPCRE::CONFIG_JIT, out jit_enabled
pending! "PCRE JIT mode not available." unless 1 == jit_enabled

str = File.read(datapath("large_single_line_string.txt"))
str.matches?(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
# We don't care whether this actually matches or not, it's just to make
# sure the engine does not stack overflow with a large string.
str.matches?(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/).should be_false
end
end

Expand Down Expand Up @@ -426,12 +422,6 @@ describe "Regex" do

it ".error?" do
Regex.error?("(foo|bar)").should be_nil
Regex.error?("(foo|bar").should eq(
if Regex::Engine.to_s == "Regex::PCRE2"
"missing closing parenthesis at 8"
else
"missing ) at 8"
end
)
Regex.error?("(foo|bar").should eq "missing ) at 8"
end
end
13 changes: 3 additions & 10 deletions src/regex/engine.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
{% if flag?(:use_pcre2) || (!flag?(:use_pcre) && !flag?(:win32) && `hash pkg-config 2> /dev/null && pkg-config --silence-errors --modversion libpcre2-8 || printf %s false` != "false") %}
require "./pcre2"
require "./pcre"

# :nodoc:
alias Regex::Engine = PCRE2
{% else %}
require "./pcre"

# :nodoc:
alias Regex::Engine = PCRE
{% end %}
# :nodoc:
alias Regex::Engine = PCRE
89 changes: 0 additions & 89 deletions src/regex/lib_pcre2.cr

This file was deleted.

176 changes: 0 additions & 176 deletions src/regex/pcre2.cr

This file was deleted.