1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2007-09-30 08:13:28 +00:00
parent 1a004904d1
commit eb64f5de06
3 changed files with 15 additions and 2 deletions

View file

@ -1,3 +1,11 @@
Sun Sep 30 17:12:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <akr@fsij.org>
* bootstraptest/runner.rb (pretty): don't show beginning empty line.

View file

@ -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)

View file

@ -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;
}