From 2e23ebc601fd5c8d7de232e470e2374df8888d11 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 13 Oct 1999 06:44:42 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 27 +++++++++++++++++++++++++++ ToDo | 11 ++++++----- array.c | 47 +++++++++++++++++++++++++++++++++++------------ dir.c | 8 ++++++++ hash.c | 8 +++----- io.c | 4 ++++ parse.y | 10 ++++++++++ rubytest.rb | 2 ++ signal.c | 2 +- st.c | 4 ++-- version.h | 8 ++++---- 11 files changed, 102 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 900a94ea97..5594434266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto + + * dir.c (dir_s_glob): iterate over generated matching filenames if + the block is given to the method. + + * array.c (rb_ary_at): new methods; at, first, last. + + * hash.c (rb_hash_fetch): raises exception unless the default + value is supplied. + + * hash.c (rb_hash_s_create): need not remove nil from value. + + * hash.c (rb_hash_aset): setting value to nil does not remove key + anymore. + +Tue Oct 12 22:29:04 1999 Yukihiro Matsumoto + + * io.c (io_read): length may be 0 or negative. + +Tue Oct 12 13:26:27 1999 Jun-ichiro itojun Hagino + + * signal.c (posix_signal): RETSIGTYPE may be void. + +Tue Oct 12 03:28:03 1999 EGUCHI Osamu + + * array.c (rb_ary_delete_at): allows negative position. + Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada * parse.y (rb_intern): should generate distinct ID_ATTRSET symbols diff --git a/ToDo b/ToDo index 45b463f34d..6866da7936 100644 --- a/ToDo +++ b/ToDo @@ -1,5 +1,6 @@ Language Spec. +- def foo; .. rescue .. end * compile time string concatenation, "hello" "world" => "helloworld" * ../... outside condition invokes operator method too. * %w(a\ b\ c abc) => ["a b c", "abc"] @@ -15,7 +16,6 @@ Language Spec. Hacking Interpreter -* hash[key] = nil may not remove entry; hashes may have nil as the value. * RUBYOPT environment variable * non-blocking open (e.g. named pipe) for thread * avoid blocking with gethostbyname/gethostbyaddr @@ -27,7 +27,9 @@ Hacking Interpreter Standard Libraries -* Array#{first,last,at} +- hash[key] = nil may not remove entry; hashes may have nil as the value. +- Array#{first,last,at} +- Dir.glob(pat){|f|...} * Struct::new([name,]member,...) ?? * String#scanf(?) * Object#fmt(?) @@ -37,11 +39,10 @@ Standard Libraries * Stream or Port, abstract superclass of IO ? * String#{pred,prev}, String#downto * optional stepsize argument for succ() -* Dir.glob(pat){|f|...} Extension Libraries -* FastCGI ruby +- FastCGI ruby * ptk.rb pTk wrapper that is compatible to tk.rb Ruby Libraries @@ -56,4 +57,4 @@ Tools Misc -* publish Ruby books +- publish Ruby books diff --git a/array.c b/array.c index 9cc0ac1815..a34545dfae 100644 --- a/array.c +++ b/array.c @@ -416,6 +416,29 @@ rb_ary_aref(argc, argv, ary) return rb_ary_entry(ary, NUM2LONG(arg1)); } +static VALUE +rb_ary_at(ary, pos) + VALUE ary, pos; +{ + return rb_ary_entry(ary, NUM2LONG(pos)); +} + +static VALUE +rb_ary_first(ary) + VALUE ary; +{ + if (RARRAY(ary)->len == 0) return Qnil; + return RARRAY(ary)->ptr[0]; +} + +static VALUE +rb_ary_last(ary) + VALUE ary; +{ + if (RARRAY(ary)->len == 0) return Qnil; + return RARRAY(ary)->ptr[RARRAY(ary)->len-1]; +} + static VALUE rb_ary_index(ary, val) VALUE ary; @@ -940,22 +963,19 @@ rb_ary_delete_at(ary, at) VALUE ary; VALUE at; { - long i1, i2, pos; + long i, pos = NUM2LONG(at), len = RARRAY(ary)->len; VALUE del = Qnil; + if (pos >= len) return Qnil; + if (pos < 0) pos += len; + if (pos < 0) return Qnil; + rb_ary_modify(ary); - pos = NUM2LONG(at); - for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) { - if (i1 == pos) { - del = RARRAY(ary)->ptr[i1]; - continue; - } - if (i1 != i2) { - RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1]; - } - i2++; + del = RARRAY(ary)->ptr[pos]; + for (i = pos + 1; i < len; i++, pos++) { + RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i]; } - RARRAY(ary)->len = i2; + RARRAY(ary)->len = pos; return del; } @@ -1445,6 +1465,9 @@ Init_Array() rb_define_method(rb_cArray, "[]", rb_ary_aref, -1); rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1); + rb_define_method(rb_cArray, "at", rb_ary_at, 1); + rb_define_method(rb_cArray, "first", rb_ary_first, 0); + rb_define_method(rb_cArray, "last", rb_ary_last, 0); rb_define_method(rb_cArray, "concat", rb_ary_concat, 1); rb_define_method(rb_cArray, "<<", rb_ary_push, 1); rb_define_method(rb_cArray, "push", rb_ary_push_method, -1); diff --git a/dir.c b/dir.c index 31116a9fff..642a960b54 100644 --- a/dir.c +++ b/dir.c @@ -570,6 +570,14 @@ dir_s_glob(dir, str) } if (buf != buffer) free(buf); + if (rb_iterator_p()) { + long len = RARRAY(ary)->len; + VALUE *ptr = RARRAY(ary)->ptr; + + while (len--) { + rb_yield(*ptr++); + } + } return ary; } diff --git a/hash.c b/hash.c index a0d11c06dd..8e30de7dde 100644 --- a/hash.c +++ b/hash.c @@ -264,7 +264,6 @@ rb_hash_s_create(argc, argv, klass) hash = rb_hash_new2(klass); for (i=0; itbl, argv[i], argv[i+1]); } @@ -363,6 +362,9 @@ rb_hash_fetch(argc, argv, hash) } return rb_yield(argv[0]); } + if (argc == 1) { + rb_raise(rb_eIndexError, "key not found"); + } return if_none; } return val; @@ -521,10 +523,6 @@ rb_hash_aset(hash, key, val) VALUE hash, key, val; { rb_hash_modify(hash); - if (NIL_P(val)) { - rb_hash_delete(hash, key); - return Qnil; - } if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->tbl, key, 0)) { st_insert(RHASH(hash)->tbl, key, val); } diff --git a/io.c b/io.c index c1c7d511db..1dba2ea69a 100644 --- a/io.c +++ b/io.c @@ -482,11 +482,15 @@ io_read(argc, argv, io) } len = NUM2INT(length); + if (len < 0) { + rb_raise(rb_eArgError, "negative length %d given", len); + } GetOpenFile(io, fptr); rb_io_check_readable(fptr); if (feof(fptr->f)) return Qnil; str = rb_str_new(0, len); + if (len == 0) return str; READ_CHECK(fptr->f); n = io_fread(RSTRING(str)->ptr, len, fptr->f); diff --git a/parse.y b/parse.y index 5e516d2751..3365df4676 100644 --- a/parse.y +++ b/parse.y @@ -1182,8 +1182,18 @@ primary : literal } f_arglist compstmt + rescue + opt_else + ensure kEND { + if ($6) $5 = NEW_RESCUE($5, $6, $7); + else if ($7) { + rb_warn("else without rescue is useless"); + $5 = block_append($5, $7); + } + if ($8) $5 = NEW_ENSURE($5, $8); + /* NOEX_PRIVATE for toplevel */ $$ = NEW_DEFN($2, $4, $5, class_nest?0:1); fixpos($$, $4); diff --git a/rubytest.rb b/rubytest.rb index 7b886fd3f4..20032e303e 100644 --- a/rubytest.rb +++ b/rubytest.rb @@ -9,6 +9,8 @@ if File.exist? CONFIG['LIBRUBY_SO'] dldpath = "SHLIB_PATH" when /-aix/ dldpath = "LIBPATH" + when /-beos/ + dldpath = "LIBRARY_PATH" else dldpath = "LD_LIBRARY_PATH" end diff --git a/signal.c b/signal.c index 6489760bc6..fe1107d46d 100644 --- a/signal.c +++ b/signal.c @@ -298,7 +298,7 @@ posix_signal(signum, handler) sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif #ifdef SA_NOCLDWAIT - if (signum == SIGCHLD && handler == (RETSIGTYPE)SIG_IGN) + if (signum == SIGCHLD && handler == SIG_IGN) sigact.sa_flags |= SA_NOCLDWAIT; #endif sigaction(signum, &sigact, 0); diff --git a/st.c b/st.c index 486b72a434..503686b111 100644 --- a/st.c +++ b/st.c @@ -79,8 +79,8 @@ static long primes[] = { 32 + 5, 64 + 3, 128 + 3, - 256 + 29, - 512 + 17, + 256 + 27, + 512 + 9, 1024 + 9, 2048 + 5, 4096 + 83, diff --git a/version.h b/version.h index 0d5ed1f1eb..032524219c 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ -#define RUBY_VERSION "1.4.2" -#define RUBY_RELEASE_DATE "1999-09-18" -#define RUBY_VERSION_CODE 142 -#define RUBY_RELEASE_CODE 19990918 +#define RUBY_VERSION "1.5.0" +#define RUBY_RELEASE_DATE "1999-10-12" +#define RUBY_VERSION_CODE 150 +#define RUBY_RELEASE_CODE 19991012