Minor cleanup

This commit is contained in:
Roberto Alsina 2024-08-15 21:35:06 -03:00
parent b589726352
commit cb09dff9f1

View File

@ -3,7 +3,7 @@ module BytesRegex
class Regex class Regex
def initialize(pattern : String, multiline = false, dotall = false, ignorecase = false, anchored = false) def initialize(pattern : String, multiline = false, dotall = false, ignorecase = false, anchored = false)
flags = LibPCRE2::UTF | LibPCRE2::DUPNAMES | LibPCRE2::UCP | LibPCRE2::NO_UTF_CHECK flags = LibPCRE2::UTF | LibPCRE2::UCP | LibPCRE2::NO_UTF_CHECK
flags |= LibPCRE2::MULTILINE if multiline flags |= LibPCRE2::MULTILINE if multiline
flags |= LibPCRE2::DOTALL if dotall flags |= LibPCRE2::DOTALL if dotall
flags |= LibPCRE2::CASELESS if ignorecase flags |= LibPCRE2::CASELESS if ignorecase
@ -40,9 +40,7 @@ module BytesRegex
LibPCRE2::NO_UTF_CHECK, LibPCRE2::NO_UTF_CHECK,
@match_data, @match_data,
nil) nil)
if rc < 0 if rc > 0
# No match, do nothing
else
ovector = LibPCRE2.get_ovector_pointer(@match_data) ovector = LibPCRE2.get_ovector_pointer(@match_data)
(0...rc).each do |i| (0...rc).each do |i|
m_start = ovector[2 * i] m_start = ovector[2 * i]