Skip to content

Commit c18d374

Browse files
author
matz
committed
991207
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent dee9620 commit c18d374

File tree

15 files changed

+172
-128
lines changed

15 files changed

+172
-128
lines changed

ChangeLog

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
Tue Dec 7 11:16:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
2+
3+
* eval.c (Init_eval): calculate stack limit from rlimit where
4+
getrlimit(2) is available.
5+
6+
Tue Dec 7 09:57:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
7+
8+
* file.c (rb_file_ftype): should have removed mode_t.
9+
110
Mon Dec 6 15:55:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
211

3-
* numeric.c (fix_rshift): Fix -1 >> 32 returned 0. (-1 is true)
12+
* numeric.c (fix_rshift): Fix -1 >> 32 returned 0 (should be -1).
413

5-
* numeric.c (fix_rshift): Fix 1 >> -1 returned 0. (2 is true)
14+
* numeric.c (fix_rshift): Fix 1 >> -1 returned 0 (should be 2).
615

716
Mon Dec 6 11:47:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
817

918
* sprintf.c (rb_f_sprintf): formatted string must be tainted if
10-
any of parameters is tainted.
19+
any of parameters is a tainted string.
1120

1221
* file.c (rb_file_s_expand_path): expanded file path need not to
1322
be tainted always.

ToDo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Hacking Interpreter
2525
- use eban's fnmatch
2626
- RUBYOPT environment variable
2727
- alias $defout $>
28+
* retrieve STACK_LEVEL_MAX from users' limit.
2829
* remove end_proc registered out of require only
2930
* non-blocking open (e.g. for named pipe) for thread
3031
* avoid blocking with gethostbyname/gethostbyaddr
@@ -42,6 +43,7 @@ Standard Libraries
4243
- Dir.glob(pat){|f|...}
4344
- sprintf/printf's $ to specify argument order
4445
- Dir.glob("**/*.c") ala zsh
46+
- Remove Enumerable#{size,length}
4547
* SyntaxError and NameError should not be subclasses of StandardError, maybe.
4648
* debugger for thread programming
4749
* Struct::new([name,]member,...) ??

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ fi
21992199

22002200
for ac_hdr in stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
22012201
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
2202-
syscall.h pwd.h a.out.h utime.h memory.h direct.h
2202+
syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h
22032203
do
22042204
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
22052205
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -3102,7 +3102,7 @@ for ac_func in fmod killpg drand48 random wait4 waitpid syscall getcwd\
31023102
truncate chsize times utimes fcntl lockf setitimer\
31033103
setruid seteuid setreuid setrgid setegid setregid\
31043104
getpgrp setpgrp getpgid setpgid getgroups getpriority\
3105-
dlopen sigprocmask sigaction _setjmp setsid
3105+
dlopen sigprocmask sigaction _setjmp setsid getrlimit
31063106
do
31073107
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
31083108
echo "configure:3109: checking for $ac_func" >&5

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ AC_HEADER_STDC
156156
AC_HEADER_SYS_WAIT
157157
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
158158
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
159-
syscall.h pwd.h a.out.h utime.h memory.h direct.h)
159+
syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h)
160160

161161
dnl Checks for typedefs, structures, and compiler characteristics.
162162
AC_TYPE_UID_T
@@ -180,7 +180,7 @@ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
180180
truncate chsize times utimes fcntl lockf setitimer\
181181
setruid seteuid setreuid setrgid setegid setregid\
182182
getpgrp setpgrp getpgid setpgid getgroups getpriority\
183-
dlopen sigprocmask sigaction _setjmp setsid)
183+
dlopen sigprocmask sigaction _setjmp setsid getrlimit)
184184
AC_STRUCT_TIMEZONE
185185
if test "$ac_cv_func_strftime" = no; then
186186
AC_TRY_LINK([],

enum.c

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ min_i(i, min)
198198
*min = i;
199199
else {
200200
cmp = rb_funcall(i, id_cmp, 1, *min);
201-
if (FIX2LONG(cmp) < 0)
201+
if (NUM2LONG(cmp) < 0)
202202
*min = i;
203203
}
204204
return Qnil;
@@ -214,7 +214,7 @@ min_ii(i, min)
214214
*min = i;
215215
else {
216216
cmp = rb_yield(rb_assoc_new(i, *min));
217-
if (FIX2LONG(cmp) < 0)
217+
if (NUM2LONG(cmp) < 0)
218218
*min = i;
219219
}
220220
return Qnil;
@@ -240,7 +240,7 @@ max_i(i, max)
240240
*max = i;
241241
else {
242242
cmp = rb_funcall(i, id_cmp, 1, *max);
243-
if (FIX2LONG(cmp) > 0)
243+
if (NUM2LONG(cmp) > 0)
244244
*max = i;
245245
}
246246
return Qnil;
@@ -256,7 +256,7 @@ max_ii(i, max)
256256
*max = i;
257257
else {
258258
cmp = rb_yield(rb_assoc_new(i, *max));
259-
if (FIX2LONG(cmp) > 0)
259+
if (NUM2LONG(cmp) > 0)
260260
*max = i;
261261
}
262262
return Qnil;
@@ -332,32 +332,6 @@ enum_member(obj, val)
332332
return Qfalse;
333333
}
334334

335-
static VALUE
336-
length_i(i, length)
337-
VALUE i;
338-
int *length;
339-
{
340-
(*length)++;
341-
return Qnil;
342-
}
343-
344-
static VALUE
345-
enum_length(obj)
346-
VALUE obj;
347-
{
348-
int length = 0;
349-
350-
rb_iterate(rb_each, obj, length_i, (VALUE)&length);
351-
return INT2FIX(length);
352-
}
353-
354-
VALUE
355-
rb_enum_length(obj)
356-
VALUE obj;
357-
{
358-
return enum_length(obj);
359-
}
360-
361335
static VALUE
362336
each_with_index_i(val, indexp)
363337
VALUE val;
@@ -403,8 +377,6 @@ Init_Enumerable()
403377
rb_define_method(rb_mEnumerable,"index", enum_index, 1);
404378
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
405379
rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
406-
rb_define_method(rb_mEnumerable,"length", enum_length, 0);
407-
rb_define_method(rb_mEnumerable,"size", enum_length, 0);
408380
rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
409381

410382
id_eqq = rb_intern("===");

eval.c

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ char *strrchr _((const char*,const char));
4949
#endif
5050
#endif
5151

52+
#include <sys/types.h>
53+
#ifdef HAVE_SYS_TIME_H
54+
# include <sys/time.h>
55+
#else
56+
#ifndef NT
57+
struct timeval {
58+
long tv_sec; /* seconds */
59+
long tv_usec; /* and microseconds */
60+
};
61+
#endif /* NT */
62+
#endif
63+
#include <signal.h>
64+
#include <errno.h>
65+
66+
#ifdef HAVE_SYS_SELECT_H
67+
#include <sys/select.h>
68+
#endif
69+
70+
#ifdef HAVE_SYS_RESOURCE_H
71+
#include <sys/resource.h>
72+
#endif
73+
5274
VALUE rb_cProc;
5375
static VALUE rb_cBinding;
5476
static VALUE proc_call _((VALUE,VALUE));
@@ -3714,9 +3736,14 @@ rb_undefined(obj, id, argc, argv, call_status)
37143736
extern int _stacksize;
37153737
# define STACK_LEVEL_MAX (_stacksize - 4096)
37163738
#else
3739+
#ifdef HAVE_GETRLIMIT
3740+
static int STACK_LEVEL_MAX = 655300;
3741+
#else
37173742
# define STACK_LEVEL_MAX 655300
37183743
#endif
37193744
#endif
3745+
#endif
3746+
37203747
extern VALUE *rb_gc_stack_start;
37213748
static int
37223749
stack_length()
@@ -3844,7 +3871,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
38443871
break;
38453872
}
38463873

3847-
if ((++tick & 0x3ff) == 0) {
3874+
if ((++tick & 0xff) == 0) {
38483875
CHECK_INTS; /* better than nothing */
38493876
if (stack_length() > STACK_LEVEL_MAX) {
38503877
rb_raise(rb_eSysStackError, "stack level too deep");
@@ -5389,6 +5416,19 @@ Init_eval()
53895416
rb_global_variable(&trace_func);
53905417

53915418
rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);
5419+
5420+
#ifdef HAVE_GETRLIMIT
5421+
{
5422+
struct rlimit rlim;
5423+
5424+
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
5425+
double space = (double)rlim.rlim_cur*0.2;
5426+
5427+
if (space > 256*1024) space = 256*1024;
5428+
STACK_LEVEL_MAX = (rlim.rlim_cur - space) / 4;
5429+
}
5430+
}
5431+
#endif
53925432
}
53935433

53945434
VALUE rb_f_autoload();
@@ -6042,24 +6082,6 @@ int rb_thread_pending = 0;
60426082

60436083
VALUE rb_cThread;
60446084

6045-
#include <sys/types.h>
6046-
#ifdef HAVE_SYS_TIME_H
6047-
# include <sys/time.h>
6048-
#else
6049-
#ifndef NT
6050-
struct timeval {
6051-
long tv_sec; /* seconds */
6052-
long tv_usec; /* and microseconds */
6053-
};
6054-
#endif /* NT */
6055-
#endif
6056-
#include <signal.h>
6057-
#include <errno.h>
6058-
6059-
#ifdef HAVE_SYS_SELECT_H
6060-
#include <sys/select.h>
6061-
#endif
6062-
60636085
extern VALUE rb_last_status;
60646086

60656087
enum thread_status {

file.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -731,35 +731,35 @@ rb_file_s_size(obj, fname)
731731
}
732732

733733
static VALUE
734-
rb_file_ftype(mode)
735-
mode_t mode;
734+
rb_file_ftype(st)
735+
struct stat *st;
736736
{
737737
char *t;
738738

739-
if (S_ISREG(mode)) {
739+
if (S_ISREG(st->st_mode)) {
740740
t = "file";
741-
} else if (S_ISDIR(mode)) {
741+
} else if (S_ISDIR(st->st_mode)) {
742742
t = "directory";
743-
} else if (S_ISCHR(mode)) {
743+
} else if (S_ISCHR(st->st_mode)) {
744744
t = "characterSpecial";
745745
}
746746
#ifdef S_ISBLK
747-
else if (S_ISBLK(mode)) {
747+
else if (S_ISBLK(st->st_mode)) {
748748
t = "blockSpecial";
749749
}
750750
#endif
751751
#ifdef S_ISFIFO
752-
else if (S_ISFIFO(mode)) {
752+
else if (S_ISFIFO(st->st_mode)) {
753753
t = "fifo";
754754
}
755755
#endif
756756
#ifdef S_ISLNK
757-
else if (S_ISLNK(mode)) {
757+
else if (S_ISLNK(st->st_mode)) {
758758
t = "link";
759759
}
760760
#endif
761761
#ifdef S_ISSOCK
762-
else if (S_ISSOCK(mode)) {
762+
else if (S_ISSOCK(st->st_mode)) {
763763
t = "socket";
764764
}
765765
#endif
@@ -786,7 +786,7 @@ rb_file_s_ftype(obj, fname)
786786
}
787787
#endif
788788

789-
return rb_file_ftype(st.st_mode);
789+
return rb_file_ftype(&st);
790790
}
791791

792792
static VALUE
@@ -1183,7 +1183,6 @@ rb_file_s_expand_path(argc, argv)
11831183
s = STR2CSTR(fname);
11841184
p = buf;
11851185
if (s[0] == '~') {
1186-
tainted = 1;
11871186
if (isdirsep(s[1]) || s[1] == '\0') {
11881187
char *dir = getenv("HOME");
11891188

@@ -1193,6 +1192,7 @@ rb_file_s_expand_path(argc, argv)
11931192
strcpy(buf, dir);
11941193
p = &buf[strlen(buf)];
11951194
s++;
1195+
tainted = 1;
11961196
}
11971197
else {
11981198
#ifdef HAVE_PWD_H
@@ -1670,7 +1670,7 @@ static VALUE
16701670
rb_stat_ftype(obj)
16711671
VALUE obj;
16721672
{
1673-
return rb_file_ftype(get_stat(obj)->st_mode);
1673+
return rb_file_ftype(get_stat(obj));
16741674
}
16751675

16761676
static VALUE

hash.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ rb_hash_replace(hash, hash2)
550550
}
551551

552552
static VALUE
553-
rb_hash_length(hash)
553+
rb_hash_size(hash)
554554
VALUE hash;
555555
{
556556
return INT2FIX(RHASH(hash)->tbl->num_entries);
@@ -1454,8 +1454,8 @@ Init_Hash()
14541454
rb_define_method(rb_cHash,"index", rb_hash_index, 1);
14551455
rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
14561456
rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
1457-
rb_define_method(rb_cHash,"length", rb_hash_length, 0);
1458-
rb_define_alias(rb_cHash, "size", "length");
1457+
rb_define_method(rb_cHash,"size", rb_hash_size, 0);
1458+
rb_define_method(rb_cHash,"length", rb_hash_size, 0);
14591459
rb_define_method(rb_cHash,"empty?", rb_hash_empty_p, 0);
14601460

14611461
rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0);
@@ -1503,6 +1503,7 @@ Init_Hash()
15031503
rb_define_singleton_method(envtbl,"index", env_index, 1);
15041504
rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
15051505
rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
1506+
rb_define_singleton_method(envtbl,"size", env_size, 0);
15061507
rb_define_singleton_method(envtbl,"length", env_size, 0);
15071508
rb_define_singleton_method(envtbl,"empty?", env_empty_p, 0);
15081509
rb_define_singleton_method(envtbl,"keys", env_keys, 0);

intern.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ void rb_syswait _((int));
233233
/* range.c */
234234
VALUE rb_range_new _((VALUE, VALUE, int));
235235
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
236+
VALUE rb_length_by_each _((VALUE));
236237
/* re.c */
237238
VALUE rb_reg_nth_defined _((int, VALUE));
238239
VALUE rb_reg_nth_match _((int, VALUE));

0 commit comments

Comments
 (0)