@@ -105,41 +105,18 @@ public static Encoding checkEncoding(DynamicObject regexp, Rope str, boolean war
105
105
return checkEncoding (regexp , str .getEncoding (), str .getCodeRange (), warn );
106
106
}
107
107
108
- // TODO (nirvdrum 03-June-15) Unify with JRuby in RegexpSupport.
109
108
public static Encoding checkEncoding (DynamicObject regexp , Encoding strEnc , CodeRange codeRange , boolean warn ) {
110
109
assert RubyGuards .isRubyRegexp (regexp );
111
110
112
111
final Encoding regexEnc = Layouts .REGEXP .getRegex (regexp ).getEncoding ();
113
112
114
- /*
115
- if (str.scanForCodeRange() == StringSupport.CR_BROKEN) {
116
- throw getRuntime().newArgumentError("invalid byte sequence in " + str.getEncoding());
117
- }
118
- */
119
- //check();
120
113
if (strEnc == regexEnc ) {
121
114
return regexEnc ;
122
115
} else if (regexEnc == USASCIIEncoding .INSTANCE && codeRange == CodeRange .CR_7BIT ) {
123
116
return regexEnc ;
124
- } else if (!strEnc .isAsciiCompatible ()) {
125
- if (strEnc != regexEnc ) {
126
- //encodingMatchError(getRuntime(), pattern, enc);
127
- }
128
- } else if (Layouts .REGEXP .getOptions (regexp ).isFixed ()) {
129
- /*
130
- if (enc != pattern.getEncoding() &&
131
- (!pattern.getEncoding().isAsciiCompatible() ||
132
- str.scanForCodeRange() != StringSupport.CR_7BIT)) {
133
- encodingMatchError(getRuntime(), pattern, enc);
134
- }
135
- */
117
+ } else if (strEnc .isAsciiCompatible () && Layouts .REGEXP .getOptions (regexp ).isFixed ()) {
136
118
return regexEnc ;
137
119
}
138
- /*
139
- if (warn && this.options.isEncodingNone() && enc != ASCIIEncoding.INSTANCE && str.scanForCodeRange() != StringSupport.CR_7BIT) {
140
- getRuntime().getWarnings().warn(ID.REGEXP_MATCH_AGAINST_STRING, "regexp match /.../n against to " + enc + " string");
141
- }
142
- */
143
120
return strEnc ;
144
121
}
145
122
@@ -198,7 +175,7 @@ public abstract static class MatchStartNode extends CoreMethodArrayArgumentsNode
198
175
@ Child private RopeNodes .BytesNode bytesNode = RopeNodes .BytesNode .create ();
199
176
200
177
@ Specialization (guards = "isRubyString(string)" )
201
- public Object matchStart (VirtualFrame frame , DynamicObject regexp , DynamicObject string , int startPos ) {
178
+ public Object matchStart (DynamicObject regexp , DynamicObject string , int startPos ) {
202
179
final Rope rope = StringOperations .rope (string );
203
180
final Matcher matcher = createMatcher (getContext (), regexp , rope , bytesNode .execute (rope ), true );
204
181
int range = rope .byteLength ();
@@ -255,7 +232,7 @@ public abstract static class SearchFromNode extends CoreMethodArrayArgumentsNode
255
232
@ Child private RopeNodes .BytesNode bytesNode = RopeNodes .BytesNode .create ();
256
233
257
234
@ Specialization (guards = "isRubyString(string)" )
258
- public Object searchFrom (VirtualFrame frame , DynamicObject regexp , DynamicObject string , int startPos ) {
235
+ public Object searchFrom (DynamicObject regexp , DynamicObject string , int startPos ) {
259
236
final Rope rope = StringOperations .rope (string );
260
237
final Matcher matcher = createMatcher (getContext (), regexp , rope , bytesNode .execute (rope ), true );
261
238
int range = StringOperations .rope (string ).byteLength ();
@@ -271,7 +248,7 @@ public abstract static class SearchFromBinaryNode extends CoreMethodArrayArgumen
271
248
@ Child private RopeNodes .BytesNode bytesNode = RopeNodes .BytesNode .create ();
272
249
273
250
@ Specialization (guards = "isRubyString(string)" )
274
- public Object searchFrom (VirtualFrame frame , DynamicObject regexp , DynamicObject string , int startPos ) {
251
+ public Object searchFrom (DynamicObject regexp , DynamicObject string , int startPos ) {
275
252
final Rope rope = StringOperations .rope (string );
276
253
final Matcher matcher = createMatcher (getContext (), regexp , rope , bytesNode .execute (rope ), false );
277
254
final int endPos = rope .byteLength ();
0 commit comments