Skip to content
Merged
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
12 changes: 5 additions & 7 deletions ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,18 @@ private IRubyObject extractBegLen(Ruby runtime, int beg, int len) {
private IRubyObject scan(ThreadContext context, IRubyObject regex, boolean succptr, boolean getstr, boolean headonly) {
final Ruby runtime = context.runtime;
check(context);

ByteList strBL = str.getByteList();
int strBeg = strBL.getBegin();

clearMatched();

if (restLen() < 0) {
return context.nil;
}

ByteList strBL = str.getByteList();
int currPtr = strBL.getBegin() + curr;

if (regex instanceof RubyRegexp) {
pattern = ((RubyRegexp) regex).preparePattern(str);

int currPtr = currPtr();
int range = currPtr + restLen();

Matcher matcher = pattern.matcher(strBL.getUnsafeBytes(), matchTarget(), range);
Expand Down Expand Up @@ -311,12 +309,12 @@ private IRubyObject scan(ThreadContext context, IRubyObject regex, boolean succp
int patternSize = patternBL.realSize();

if (headonly) {
if (ByteList.memcmp(strBL.unsafeBytes(), strBeg + curr, patternBL.unsafeBytes(), patternBL.begin(), patternSize) != 0) {
if (ByteList.memcmp(strBL.unsafeBytes(), currPtr, patternBL.unsafeBytes(), patternBL.begin(), patternSize) != 0) {
return context.nil;
}
setRegisters(patternSize);
} else {
int pos = StringSupport.index(strBL, patternBL, strBeg + curr, patternEnc);
int pos = StringSupport.index(strBL, patternBL, currPtr, patternEnc);
if (pos == -1) {
return context.nil;
}
Expand Down