def next_match(result, term_or_regexp = "")
case term_or_regexp
when String; size = [result.query.size, term_or_regexp.size].max
when Regexp; size = MAX_REGEXP_MATCH_SIZE
end
get_fulltext_IO do |fulltextIO|
get_sarray_IO do |sarrayIO|
idx = result.index
loop do
idx += 1
str = get_string(sarrayIO, fulltextIO, idx, size)
upto = str.index("\0")
str = str[0, upto] if upto
break unless str.index(result.query) == 0
if str[term_or_regexp]
fulltextIO.pos = index_to_offset(sarrayIO, idx)
path, metadata = find_metadata(fulltextIO)
return Result.new(self, result.query, idx, path, metadata) if path
end
end
end
end
end