Skip to content

Commit 7dfd5a1

Browse files
authored
Merge pull request jruby#8548 from enebo/regex
tcification of regex
2 parents 3c88b28 + ce0c411 commit 7dfd5a1

File tree

13 files changed

+393
-341
lines changed

13 files changed

+393
-341
lines changed

core/src/main/java/org/jruby/RubyComplex.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {
12891289

12901290
if (m != nil) {
12911291
RubyMatchData match = (RubyMatchData)m;
1292-
sr = match.at(1);
1293-
si = match.at(2);
1292+
sr = match.at(context, 1);
1293+
si = match.at(context, 2);
12941294
re = match.post_match(context);
12951295
po = true;
12961296
}
@@ -1301,9 +1301,9 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {
13011301
if (m != nil) {
13021302
RubyMatchData match = (RubyMatchData)m;
13031303
sr = nil;
1304-
si = match.at(1);
1304+
si = match.at(context, 1);
13051305
if (si == nil) si = runtime.newString();
1306-
IRubyObject t = match.at(2);
1306+
IRubyObject t = match.at(context, 2);
13071307
if (t == nil) t = runtime.newString(RubyInteger.singleCharByteList((byte) '1'));
13081308
((RubyString) (si = si.convertToString())).cat(t.convertToString());
13091309
re = match.post_match(context);
@@ -1315,12 +1315,12 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {
13151315
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat2).match_m(context, str, false);
13161316
if (m == nil) return new IRubyObject[] { context.nil, str };
13171317
RubyMatchData match = (RubyMatchData) m;
1318-
sr = match.at(1);
1319-
if (match.at(2) == nil) {
1318+
sr = match.at(context, 1);
1319+
if (match.at(context, 2) == nil) {
13201320
si = context.nil;
13211321
} else {
1322-
si = match.at(3);
1323-
IRubyObject t = match.at(4);
1322+
si = match.at(context, 3);
1323+
IRubyObject t = match.at(context, 4);
13241324
if (t == nil) t = runtime.newString(RubyInteger.singleCharByteList((byte) '1'));
13251325
((RubyString) (si = si.convertToString())).cat(t.convertToString());
13261326
}

core/src/main/java/org/jruby/RubyGlobal.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ public PreMatchGlobalVariable(Ruby runtime, String name) {
918918

919919
@Override
920920
public IRubyObject get() {
921-
return RubyRegexp.match_pre(runtime.getCurrentContext().getBackRef());
921+
var context = runtime.getCurrentContext();
922+
return RubyRegexp.match_pre(context, context.getBackRef());
922923
}
923924
}
924925

@@ -940,7 +941,8 @@ public LastMatchGlobalVariable(Ruby runtime, String name) {
940941

941942
@Override
942943
public IRubyObject get() {
943-
return RubyRegexp.match_last(runtime.getCurrentContext().getBackRef());
944+
var context = runtime.getCurrentContext();
945+
return RubyRegexp.match_last(context, context.getBackRef());
944946
}
945947
}
946948

0 commit comments

Comments
 (0)