summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-03-31 04:52:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-03-31 04:52:10 +0000
commita1d8147e4419d81cd93c664b85f7062c89101c87 (patch)
tree1fea18df7e29da5e86be6337f7fb8181ec044ff7
parentb41d6e177b44f13b2bfb190a7aae3dd2d5faf4ef (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--ChangeLog9
-rw-r--r--class.c2
-rw-r--r--eval.c7
-rw-r--r--ext/dbm/dbm.c2
-rw-r--r--ext/md5/md5init.c2
-rw-r--r--numeric.c12
-rw-r--r--ruby.c2
-rw-r--r--ruby.h2
-rw-r--r--string.c6
9 files changed, 34 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 80dbc480d5..40f87b464a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/class.c b/class.c
index bed83ef792..41a0b504da 100644
--- a/class.c
+++ b/class.c
@@ -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
************************************************/
diff --git a/eval.c b/eval.c
index e6872a215e..95f5d4ad5f 100644
--- a/eval.c
+++ b/eval.c
@@ -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,
diff --git a/numeric.c b/numeric.c
index d07af84425..527d65d2a3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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:
diff --git a/ruby.c b/ruby.c
index 280c088d71..2c220500dc 100644
--- a/ruby.c
+++ b/ruby.c
@@ -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
************************************************/
diff --git a/ruby.h b/ruby.h
index ea133413eb..e6c437369c 100644
--- a/ruby.h
+++ b/ruby.h
@@ -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));
diff --git a/string.c b/string.c
index 59e4024bbf..43c8aaac37 100644
--- a/string.c
+++ b/string.c
@@ -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;