mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eval(..,file,line);String#center
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b41d6e177b
commit
a1d8147e44
9 changed files with 34 additions and 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>
|
Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* file.c (f_test): raises exception for unkown command.
|
* file.c (f_test): raises exception for unkown command.
|
||||||
|
|
2
class.c
2
class.c
|
@ -6,7 +6,7 @@
|
||||||
$Date$
|
$Date$
|
||||||
created at: Tue Aug 10 15:05:44 JST 1993
|
created at: Tue Aug 10 15:05:44 JST 1993
|
||||||
|
|
||||||
Copyright (C) 1993-1995 Yukihiro Matsumoto
|
Copyright (C) 1993-1998 Yukihiro Matsumoto
|
||||||
|
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
|
|
5
eval.c
5
eval.c
|
@ -3713,9 +3713,12 @@ eval(self, src, scope, file, line)
|
||||||
file = sourcefile;
|
file = sourcefile;
|
||||||
line = sourceline;
|
line = sourceline;
|
||||||
}
|
}
|
||||||
else if (line > 0) {
|
else {
|
||||||
|
sourcefile = file;
|
||||||
|
if (line > 0) {
|
||||||
sourceline = line;
|
sourceline = line;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!NIL_P(scope)) {
|
if (!NIL_P(scope)) {
|
||||||
if (TYPE(scope) != T_DATA || RDATA(scope)->dfree != blk_free) {
|
if (TYPE(scope) != T_DATA || RDATA(scope)->dfree != blk_free) {
|
||||||
TypeError("wrong argument type %s (expected Proc/Binding)",
|
TypeError("wrong argument type %s (expected Proc/Binding)",
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
$Date$
|
$Date$
|
||||||
created at: Mon Jan 24 15:59:52 JST 1994
|
created at: Mon Jan 24 15:59:52 JST 1994
|
||||||
|
|
||||||
Copyright (C) 1995 Yukihiro Matsumoto
|
Copyright (C) 1995-1998 Yukihiro Matsumoto
|
||||||
|
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
$Author$
|
$Author$
|
||||||
created at: Fri Aug 2 09:24:12 JST 1996
|
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,
|
/* This module provides an interface to the RSA Data Security,
|
||||||
|
|
12
numeric.c
12
numeric.c
|
@ -588,6 +588,18 @@ num2int(val)
|
||||||
|
|
||||||
switch (TYPE(val)) {
|
switch (TYPE(val)) {
|
||||||
case T_FIXNUM:
|
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);
|
return FIX2INT(val);
|
||||||
|
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
|
|
2
ruby.c
2
ruby.c
|
@ -6,7 +6,7 @@
|
||||||
$Date$
|
$Date$
|
||||||
created at: Tue Aug 10 12:47:31 JST 1993
|
created at: Tue Aug 10 12:47:31 JST 1993
|
||||||
|
|
||||||
Copyright (C) 1993-1996 Yukihiro Matsumoto
|
Copyright (C) 1993-1998 Yukihiro Matsumoto
|
||||||
|
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
|
|
6
string.c
6
string.c
|
@ -2530,7 +2530,7 @@ str_ljust(str, w)
|
||||||
VALUE res;
|
VALUE res;
|
||||||
UCHAR *p, *pend;
|
UCHAR *p, *pend;
|
||||||
|
|
||||||
if (RSTRING(str)->len >= width) return str;
|
if (width < 0 || RSTRING(str)->len >= width) return str;
|
||||||
res = str_new(0, width);
|
res = str_new(0, width);
|
||||||
memcpy(RSTRING(res)->ptr, RSTRING(str)->ptr, RSTRING(str)->len);
|
memcpy(RSTRING(res)->ptr, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||||
p = RSTRING(res)->ptr + RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
|
p = RSTRING(res)->ptr + RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
|
||||||
|
@ -2549,7 +2549,7 @@ str_rjust(str, w)
|
||||||
VALUE res;
|
VALUE res;
|
||||||
UCHAR *p, *pend;
|
UCHAR *p, *pend;
|
||||||
|
|
||||||
if (RSTRING(str)->len >= width) return str;
|
if (width < 0 || RSTRING(str)->len >= width) return str;
|
||||||
res = str_new(0, width);
|
res = str_new(0, width);
|
||||||
p = RSTRING(res)->ptr; pend = p + width - RSTRING(str)->len;
|
p = RSTRING(res)->ptr; pend = p + width - RSTRING(str)->len;
|
||||||
while (p < pend) {
|
while (p < pend) {
|
||||||
|
@ -2569,7 +2569,7 @@ str_center(str, w)
|
||||||
UCHAR *p, *pend;
|
UCHAR *p, *pend;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (RSTRING(str)->len >= width) return str;
|
if (width < 0 || RSTRING(str)->len >= width) return str;
|
||||||
res = str_new(0, width);
|
res = str_new(0, width);
|
||||||
n = (width - RSTRING(str)->len)/2;
|
n = (width - RSTRING(str)->len)/2;
|
||||||
p = RSTRING(res)->ptr; pend = p + n;
|
p = RSTRING(res)->ptr; pend = p + n;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue