diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-10 08:44:05 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-10 08:44:05 +0000 |
commit | 3ab072c0dc748031816ebfbdccdc10fa4212a9db (patch) | |
tree | 1af982c2e02748e9f72146220e9f62d6c5728ff0 /string.c | |
parent | b2fa1cbeda1b7893910205f38733430f521c3744 (diff) |
1.1b7 pre3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@69 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -1034,7 +1034,12 @@ str_aset(str, indx, val) if (idx < 0 || RSTRING(str)->len <= idx) { IndexError("index %d out of range [0..%d]", idx, RSTRING(str)->len-1); } - RSTRING(str)->ptr[idx] = FIX2INT(val) & 0xff; + if (TYPE(val) == T_STRING) { + str_replace(str, idx, 1, val); + } + else { + RSTRING(str)->ptr[idx] = NUM2INT(val) & 0xff; + } return val; case T_REGEXP: @@ -2243,7 +2248,13 @@ static VALUE str_oct(str) VALUE str; { - return str2inum(RSTRING(str)->ptr, 8); + int base = 8; + + if (RSTRING(str)->len > 2 && RSTRING(str)->ptr[0] == '0' && + (RSTRING(str)->ptr[1] == 'x' || RSTRING(str)->ptr[1] == 'X')) { + base = 16; + } + return str2inum(RSTRING(str)->ptr, base); } static VALUE |