* encoding.c (rb_enc_compatible): encoding should never fall back

to ASCII-8BIT unless both encodings are ASCII-8BIT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-13 13:44:02 +00:00
Родитель 968918da16
Коммит a648fc802b
4 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Dec 13 22:16:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* encoding.c (rb_enc_compatible): encoding should never fall back
to ASCII-8BIT unless both encodings are ASCII-8BIT.
Thu Dec 13 20:31:28 2007 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_shared_replace): make str noembed after free.

Просмотреть файл

@ -397,7 +397,10 @@ rb_enc_compatible(VALUE str1, VALUE str2)
if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx2);
if (cr2 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx1);
}
if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(0);
if (cr2 == ENC_CODERANGE_7BIT) {
if (idx1 == 0) return rb_enc_from_index(idx2);
if (idx2 == 0) return rb_enc_from_index(idx1);
}
}
if (cr1 == ENC_CODERANGE_7BIT &&
rb_enc_asciicompat(enc = rb_enc_from_index(idx2)))

3
re.c
Просмотреть файл

@ -144,6 +144,7 @@ rb_memsearch(const void *x0, long m, const void *y0, long n)
#define ARG_KCODE_EUC 1
#define ARG_KCODE_SJIS 2
#define ARG_KCODE_UTF8 3
#define ARG_KCODE_MASK 3
static int
char_to_option(int c)
@ -1968,7 +1969,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
if (unescaped == Qnil)
return -1;
if (fixed_enc && (options & ARG_ENCODING_FIXED) && fixed_enc != enc) {
if (fixed_enc && fixed_enc != enc) {
strcpy(err, "character encodings differ");
return -1;
}

Просмотреть файл

@ -447,13 +447,13 @@ class TestM17N < Test::Unit::TestCase
end
def test_regexp_unicode
assert_nothing_raised { eval '/\u{0}/' }
assert_nothing_raised { eval '/\u{D7FF}/' }
assert_raise(SyntaxError) { eval '/\u{D800}/' }
assert_raise(SyntaxError) { eval '/\u{DFFF}/' }
assert_nothing_raised { eval '/\u{E000}/' }
assert_nothing_raised { eval '/\u{10FFFF}/' }
assert_raise(SyntaxError) { eval '/\u{110000}/' }
assert_nothing_raised { eval '/\u{0}/u' }
assert_nothing_raised { eval '/\u{D7FF}/u' }
assert_raise(SyntaxError) { eval '/\u{D800}/u' }
assert_raise(SyntaxError) { eval '/\u{DFFF}/u' }
assert_nothing_raised { eval '/\u{E000}/u' }
assert_nothing_raised { eval '/\u{10FFFF}/u' }
assert_raise(SyntaxError) { eval '/\u{110000}/u' }
end
def test_regexp_mixed_unicode