summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-02 00:16:24 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-02 00:16:24 +0000
commit21729a1c7796cb152f9dc13b56ca2d761e511a96 (patch)
treee0ae786506f1338549db59f637afe7a0c2264278 /parse.y
parent5a930580c9ec152ac3940b3b5ecfe2a86813835c (diff)
* parse.y (regexp): fix /#{}\xa1\xa2/e to be EUC-JP.
(reg_fragment_setenc_gen): extracted from reg_compile_gen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y22
1 files changed, 19 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 264a3d2d63..2bfd9e09b0 100644
--- a/parse.y
+++ b/parse.y
@@ -442,6 +442,8 @@ extern int rb_parse_in_eval(void);
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)
#else
#define remove_begin(node) (node)
#endif /* !RIPPER */
@@ -3642,6 +3644,7 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
/*%%%*/
int options = $3;
NODE *node = $2;
+ NODE *list;
if (!node) {
node = NEW_LIT(reg_compile(STR_NEW0(), options));
}
@@ -3663,6 +3666,12 @@ 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);
+ 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);
+ }
+ }
break;
}
$$ = node;
@@ -8436,10 +8445,9 @@ dvar_curr_gen(struct parser_params *parser, ID id)
VALUE rb_reg_compile(VALUE str, int options);
-static VALUE
-reg_compile_gen(struct parser_params* parser, VALUE str, int options)
+static void
+reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
{
- VALUE re;
int c = RE_OPTION_ENCODING_IDX(options);
if (c) {
@@ -8453,6 +8461,14 @@ reg_compile_gen(struct parser_params* parser, VALUE str, int options)
}
ENCODING_SET(str, idx);
}
+}
+
+static VALUE
+reg_compile_gen(struct parser_params* parser, VALUE str, int options)
+{
+ VALUE re;
+
+ reg_fragment_setenc(str, options);
re = rb_reg_compile(str, options & RE_OPTION_MASK);
if (NIL_P(re)) {
RB_GC_GUARD(re) = rb_obj_as_string(rb_errinfo());