From 47732dbd2ba2430c22d10663399a42447e98b240 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 4 Oct 2007 07:28:35 +0000 Subject: * parse.y (reg_compile_gen): copy encoding from source string if non-empty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++-- parse.y | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e41a0b108d..e4184c411f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -Thu Oct 4 16:15:55 2007 Nobuyoshi Nakada +Thu Oct 4 16:28:33 2007 Nobuyoshi Nakada * encoding.c (rb_obj_encoding): returns encoding of the given object. - * parse.y (reg_compile_gen): copy encoding from source string. + * parse.y (reg_compile_gen): copy encoding from source string if + non-empty. * re.c (Init_Regexp): new method Regexp#encoding. diff --git a/parse.y b/parse.y index b81e37ee0f..3b4065ac06 100644 --- a/parse.y +++ b/parse.y @@ -8170,7 +8170,7 @@ reg_compile_gen(struct parser_params* parser, VALUE str, int options) compile_error(PARSER_ARG "%s", RSTRING_PTR(re)); return Qnil; } - rb_enc_copy(re, str); + if (str) rb_enc_copy(re, str); return re; } -- cgit v1.2.3