From e0f8351d5528cd01ab71855eae87ef067de55626 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 8 Feb 2012 22:34:12 +0000 Subject: merge revision(s) 34236: [Backport #5890] * numeric.c (rb_enc_uint_char): raise RangeError when added codepoint is invalid. [Feature #5855] [Bug #5863] [Bug #5864] * string.c (rb_str_concat): ditto. * string.c (rb_str_concat): set encoding as ASCII-8BIT when the string is US-ASCII and the argument is an integer greater than 127. * regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code. * enc/euc_jp.c (code_to_mbclen): ditto. * enc/shift_jis.c (code_to_mbclen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enc/euc_jp.c | 7 ++++--- enc/shift_jis.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'enc') diff --git a/enc/euc_jp.c b/enc/euc_jp.c index 2666e60ae0..7667c5800e 100644 --- a/enc/euc_jp.c +++ b/enc/euc_jp.c @@ -154,9 +154,10 @@ static int code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED) { if (ONIGENC_IS_CODE_ASCII(code)) return 1; - else if (code > 0xffffff) return 0; - else if ((code & 0xff0000) >= 0x800000) return 3; - else if ((code & 0xff00) >= 0x8000) return 2; + else if (code > 0xffffff) + return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE; + else if (code & 0x800000) return 3; + else if (code & 0x8000) return 2; else return ONIGERR_INVALID_CODE_POINT_VALUE; } diff --git a/enc/shift_jis.c b/enc/shift_jis.c index d1357b3212..9dcacb584d 100644 --- a/enc/shift_jis.c +++ b/enc/shift_jis.c @@ -135,13 +135,13 @@ code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED) if (EncLen_SJIS[(int )code] == 1) return 1; else - return 0; + return ONIGERR_INVALID_CODE_POINT_VALUE; } else if (code <= 0xffff) { return 2; } else - return ONIGERR_INVALID_CODE_POINT_VALUE; + return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE; } static OnigCodePoint -- cgit v1.2.3