summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 08:06:58 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 08:06:58 +0000
commit931e3b6a67d7e65961ab350f8cef58d7515bcc07 (patch)
treeb440454298aa48dfec88a1c64b30e8139b1aeb40 /string.c
parentcd504997011c0078df5725ad9b751d05cd83f248 (diff)
merges r29453 from trunk into ruby_1_9_2.
-- * string.c (rb_str_concat): use unsigned int for GB18030. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/string.c b/string.c
index fc4f747063..da3242f254 100644
--- a/string.c
+++ b/string.c
@@ -1992,37 +1992,28 @@ rb_str_append(VALUE str, VALUE str2)
VALUE
rb_str_concat(VALUE str1, VALUE str2)
{
- SIGNED_VALUE lc;
+ unsigned int lc;
if (FIXNUM_P(str2)) {
- lc = FIX2LONG(str2);
- if (lc < 0)
- rb_raise(rb_eRangeError, "negative argument");
+ lc = FIX2UINT(str2);
}
else if (TYPE(str2) == T_BIGNUM) {
- if (!RBIGNUM_SIGN(str2))
- rb_raise(rb_eRangeError, "negative argument");
- lc = rb_big2ulong(str2);
+ lc = NUM2UINT(str2);
}
else {
return rb_str_append(str1, str2);
}
-#if SIZEOF_INT < SIZEOF_VALUE
- if ((VALUE)lc > UINT_MAX) {
- rb_raise(rb_eRangeError, "%"PRIuVALUE" out of char range", lc);
- }
-#endif
{
rb_encoding *enc = STR_ENC_GET(str1);
long pos = RSTRING_LEN(str1);
int cr = ENC_CODERANGE(str1);
- int c, len;
+ int len;
- if ((len = rb_enc_codelen(c = (int)lc, enc)) <= 0) {
- rb_raise(rb_eRangeError, "%u invalid char", c);
+ if ((len = rb_enc_codelen(lc, enc)) <= 0) {
+ rb_raise(rb_eRangeError, "%u invalid char", lc);
}
rb_str_resize(str1, pos+len);
- rb_enc_mbcput(c, RSTRING_PTR(str1)+pos, enc);
+ rb_enc_mbcput(lc, RSTRING_PTR(str1)+pos, enc);
ENC_CODERANGE_SET(str1, cr);
return str1;
}