From eb64f5de06ff378c3efe17504a1b57df9f4985f9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 30 Sep 2007 08:13:28 +0000 Subject: [PATCH] * string.c (rb_str_append): always set encoding, and coderange cache bits. * include/ruby/encoding.h (ENC_CODERANGE_SET): fixed a bug not to set chache bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ include/ruby/encoding.h | 3 ++- string.c | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d7e0004ef..3909cfc10b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Sep 30 17:12:53 2007 Nobuyoshi Nakada + + * string.c (rb_str_append): always set encoding, and coderange + cache bits. + + * include/ruby/encoding.h (ENC_CODERANGE_SET): fixed a bug not to + set chache bits. + Sun Sep 30 11:52:11 2007 Tanaka Akira * bootstraptest/runner.rb (pretty): don't show beginning empty line. diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 20b676369f..36cf110cdb 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -31,7 +31,8 @@ #define ENC_CODERANGE_BROKEN (FL_USER12|FL_USER13) #define ENC_CODERANGE(obj) (RBASIC(obj)->flags & ENC_CODERANGE_MASK) #define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_SINGLE) -#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags &= ~ENC_CODERANGE_MASK | (cr)) +#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \ + (RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr)) #define ENC_CODERANGE_CLEAR(obj) ENC_CODERANGE_SET(obj,0) diff --git a/string.c b/string.c index c70dc16441..5fbc4e7133 100644 --- a/string.c +++ b/string.c @@ -995,9 +995,12 @@ VALUE rb_str_append(VALUE str, VALUE str2) { rb_encoding *enc; + int cr, cr2; StringValue(str2); enc = rb_enc_check(str, str2); + cr = ENC_CODERANGE(str); + if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2; rb_str_modify(str); if (RSTRING_LEN(str2) > 0) { if (STR_ASSOC_P(str)) { @@ -1008,11 +1011,12 @@ rb_str_append(VALUE str, VALUE str2) RSTRING(str)->as.heap.len = len; } else { - return rb_str_buf_append(str, str2); + rb_str_buf_append(str, str2); } } OBJ_INFECT(str, str2); rb_enc_associate(str, enc); + ENC_CODERANGE_SET(str, cr); return str; }