summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-08 07:21:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-08 07:21:05 +0000
commitb12bb501496a3ad2822db14d13629629fad8fefb (patch)
tree5439660b5873af54e4dddb3d3c573143304c6137 /parse.y
parent9667f7953e1ca78e5acfa40e9573d1fcdbd3d1ea (diff)
* re.c (rb_reg_check_preprocess): new function for validating regexp
fragment. * parse.y (regexp): invoke reg_fragment_check. (reg_fragment_check): defined. (reg_fragment_check_gen): defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y20
1 files changed, 18 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 0becb9280d..0a44cbe1db 100644
--- a/parse.y
+++ b/parse.y
@@ -444,6 +444,8 @@ static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
#define reg_compile(str,options) reg_compile_gen(parser, str, options)
static void reg_fragment_setenc_gen(struct parser_params*, VALUE, int);
#define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, str, options)
+static void reg_fragment_check_gen(struct parser_params*, VALUE, int);
+#define reg_fragment_check(str,options) reg_fragment_check_gen(parser, str, options)
#else
#define remove_begin(node) (node)
#endif /* !RIPPER */
@@ -3661,10 +3663,10 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
nd_set_type(node, NODE_DREGX);
}
node->nd_cflag = options & RE_OPTION_MASK;
- reg_fragment_setenc(node->nd_lit, options);
+ reg_fragment_check(node->nd_lit, options);
for (list = node->nd_next; list; list = list->nd_next) {
if (nd_type(list->nd_head) == NODE_STR) {
- reg_fragment_setenc(list->nd_head->nd_lit, options);
+ reg_fragment_check(list->nd_head->nd_lit, options);
}
}
break;
@@ -8456,6 +8458,7 @@ dvar_curr_gen(struct parser_params *parser, ID id)
}
VALUE rb_reg_compile(VALUE str, int options);
+VALUE rb_reg_check_preprocess(VALUE);
static void
reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
@@ -8475,6 +8478,19 @@ reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
}
}
+static void
+reg_fragment_check_gen(struct parser_params* parser, VALUE str, int options)
+{
+ VALUE err;
+ reg_fragment_setenc_gen(parser, str, options);
+ err = rb_reg_check_preprocess(str);
+ if (err != Qnil) {
+ err = rb_obj_as_string(err);
+ compile_error(PARSER_ARG "%s", RSTRING_PTR(err));
+ RB_GC_GUARD(err);
+ }
+}
+
static VALUE
reg_compile_gen(struct parser_params* parser, VALUE str, int options)
{