diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-03-31 04:52:10 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-03-31 04:52:10 +0000 |
commit | a1d8147e4419d81cd93c664b85f7062c89101c87 (patch) | |
tree | 1fea18df7e29da5e86be6337f7fb8181ec044ff7 | |
parent | b41d6e177b44f13b2bfb190a7aae3dd2d5faf4ef (diff) |
eval(..,file,line);String#center
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | class.c | 2 | ||||
-rw-r--r-- | eval.c | 7 | ||||
-rw-r--r-- | ext/dbm/dbm.c | 2 | ||||
-rw-r--r-- | ext/md5/md5init.c | 2 | ||||
-rw-r--r-- | numeric.c | 12 | ||||
-rw-r--r-- | ruby.c | 2 | ||||
-rw-r--r-- | ruby.h | 2 | ||||
-rw-r--r-- | string.c | 6 |
9 files changed, 34 insertions, 10 deletions
@@ -1,3 +1,12 @@ +Tue Mar 31 13:23:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * numeric.c (num2int): raise exception for too big Fixnums on + platforms that sizeof(int) < sizeof(INT). + + * string.c (str_center): SEGV on negative width. + + * eval.c (eval): forgot to set sourcefile. + Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * file.c (f_test): raises exception for unkown command. @@ -6,7 +6,7 @@ $Date$ created at: Tue Aug 10 15:05:44 JST 1993 - Copyright (C) 1993-1995 Yukihiro Matsumoto + Copyright (C) 1993-1998 Yukihiro Matsumoto ************************************************/ @@ -3713,8 +3713,11 @@ eval(self, src, scope, file, line) file = sourcefile; line = sourceline; } - else if (line > 0) { - sourceline = line; + else { + sourcefile = file; + if (line > 0) { + sourceline = line; + } } if (!NIL_P(scope)) { if (TYPE(scope) != T_DATA || RDATA(scope)->dfree != blk_free) { diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index cd630fdb27..cb6a63475a 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -6,7 +6,7 @@ $Date$ created at: Mon Jan 24 15:59:52 JST 1994 - Copyright (C) 1995 Yukihiro Matsumoto + Copyright (C) 1995-1998 Yukihiro Matsumoto ************************************************/ diff --git a/ext/md5/md5init.c b/ext/md5/md5init.c index 47f913792f..348f64bcda 100644 --- a/ext/md5/md5init.c +++ b/ext/md5/md5init.c @@ -5,7 +5,7 @@ $Author$ created at: Fri Aug 2 09:24:12 JST 1996 - Copyright (C) 1995 Yukihiro Matsumoto + Copyright (C) 1995-1998 Yukihiro Matsumoto ************************************************/ /* This module provides an interface to the RSA Data Security, @@ -588,6 +588,18 @@ num2int(val) switch (TYPE(val)) { case T_FIXNUM: + if (sizeof(int) < sizeof(INT)) { +#ifndef INT_MAX +/* assuming 32bit(2's compliment) int */ +# define INT_MAX 2147483647 +# define INT_MIN (- INT_MAX - 1) +#endif + INT i = FIX2INT(val); + if (INT_MIN < i && i < INT_MAX) { + return i; + } + ArgError("Fixnum too big to convert into `int'"); + } return FIX2INT(val); case T_FLOAT: @@ -6,7 +6,7 @@ $Date$ created at: Tue Aug 10 12:47:31 JST 1993 - Copyright (C) 1993-1996 Yukihiro Matsumoto + Copyright (C) 1993-1998 Yukihiro Matsumoto ************************************************/ @@ -165,7 +165,7 @@ void rb_check_safe_str _((VALUE)); #define Check_SafeStr(v) rb_check_safe_str((VALUE)(v)) void rb_secure _((int)); -int num2int _((VALUE)); +int num2int _((VALUE)); #define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):num2int(x)) double num2dbl _((VALUE)); @@ -2530,7 +2530,7 @@ str_ljust(str, w) VALUE res; UCHAR *p, *pend; - if (RSTRING(str)->len >= width) return str; + if (width < 0 || RSTRING(str)->len >= width) return str; res = str_new(0, width); memcpy(RSTRING(res)->ptr, RSTRING(str)->ptr, RSTRING(str)->len); p = RSTRING(res)->ptr + RSTRING(str)->len; pend = RSTRING(res)->ptr + width; @@ -2549,7 +2549,7 @@ str_rjust(str, w) VALUE res; UCHAR *p, *pend; - if (RSTRING(str)->len >= width) return str; + if (width < 0 || RSTRING(str)->len >= width) return str; res = str_new(0, width); p = RSTRING(res)->ptr; pend = p + width - RSTRING(str)->len; while (p < pend) { @@ -2569,7 +2569,7 @@ str_center(str, w) UCHAR *p, *pend; int n; - if (RSTRING(str)->len >= width) return str; + if (width < 0 || RSTRING(str)->len >= width) return str; res = str_new(0, width); n = (width - RSTRING(str)->len)/2; p = RSTRING(res)->ptr; pend = p + n; |