diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-17 13:01:52 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-17 13:01:52 +0000 |
| commit | 5688661bd26141458fd00c05db19651996f4edec (patch) | |
| tree | 3961b89549c90662c8eb531950eacf2dbdc0698b | |
| parent | 54275712f26ef77deff10691dc43bd4d87c2d57c (diff) | |
| download | ruby-5688661bd26141458fd00c05db19651996f4edec.tar.gz ruby-5688661bd26141458fd00c05db19651996f4edec.tar.xz ruby-5688661bd26141458fd00c05db19651996f4edec.zip | |
* encoding.c (ENC_CODERANGE_AND): fix broken case. [ruby-dev:33826]
* string.c (rb_str_times): fix broken case. [ruby-dev:33826]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | include/ruby/encoding.h | 13 | ||||
| -rw-r--r-- | string.c | 5 |
3 files changed, 16 insertions, 8 deletions
@@ -1,3 +1,9 @@ +Sun Feb 17 21:38:21 2008 NARUSE, Yui <naruse@ruby-lang.org> + + * encoding.c (ENC_CODERANGE_AND): fix broken case. [ruby-dev:33826] + + * string.c (rb_str_times): fix broken case. [ruby-dev:33826] + Sun Feb 17 20:45:10 2008 Tanaka Akira <akr@fsij.org> * re.c (rb_reg_prepare_re): add enable_warning parameter. diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 9cd1f9e1e..dcae15a03 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -56,13 +56,12 @@ #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) -#define ENC_CODERANGE_AND(a, b) (\ - (a == b) ? a : \ - (a == ENC_CODERANGE_BROKEN) ? ENC_CODERANGE_BROKEN : \ - (b == ENC_CODERANGE_BROKEN) ? ENC_CODERANGE_BROKEN : \ - (a == ENC_CODERANGE_UNKNOWN) ? ENC_CODERANGE_UNKNOWN : \ - (b == ENC_CODERANGE_UNKNOWN) ? ENC_CODERANGE_UNKNOWN : \ - ENC_CODERANGE_VALID) + +/* assumed ASCII compatiblity */ +#define ENC_CODERANGE_AND(a, b) \ + (a == ENC_CODERANGE_7BIT ? b : \ + a == ENC_CODERANGE_VALID ? (b == ENC_CODERANGE_7BIT ? ENC_CODERANGE_VALID : b) : \ + ENC_CODERANGE_UNKNOWN) #define ENCODING_CODERANGE_SET(obj, encindex, cr) \ do { \ @@ -758,6 +758,7 @@ rb_str_times(VALUE str, VALUE times) { VALUE str2; long n, len; + int cr; len = NUM2LONG(times); if (len < 0) { @@ -779,7 +780,9 @@ rb_str_times(VALUE str, VALUE times) } RSTRING_PTR(str2)[RSTRING_LEN(str2)] = '\0'; OBJ_INFECT(str2, str); - ENCODING_CODERANGE_SET(str2, rb_enc_get_index(str), ENC_CODERANGE(str)); + cr = ENC_CODERANGE(str); + if (cr == ENC_CODERANGE_BROKEN) cr = ENC_CODERANGE_UNKNOWN; + ENCODING_CODERANGE_SET(str2, rb_enc_get_index(str), cr); return str2; } |
