git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-10-13 06:44:42 +00:00
Родитель be1fea072c
Коммит 2e23ebc601
11 изменённых файлов: 102 добавлений и 29 удалений

Просмотреть файл

@ -1,3 +1,30 @@
Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* 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 <matz@netlab.co.jp>
* io.c (io_read): length may be 0 or negative.
Tue Oct 12 13:26:27 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
* signal.c (posix_signal): RETSIGTYPE may be void.
Tue Oct 12 03:28:03 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* array.c (rb_ary_delete_at): allows negative position.
Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* parse.y (rb_intern): should generate distinct ID_ATTRSET symbols * parse.y (rb_intern): should generate distinct ID_ATTRSET symbols

11
ToDo
Просмотреть файл

@ -1,5 +1,6 @@
Language Spec. Language Spec.
- def foo; .. rescue .. end
* compile time string concatenation, "hello" "world" => "helloworld" * compile time string concatenation, "hello" "world" => "helloworld"
* ../... outside condition invokes operator method too. * ../... outside condition invokes operator method too.
* %w(a\ b\ c abc) => ["a b c", "abc"] * %w(a\ b\ c abc) => ["a b c", "abc"]
@ -15,7 +16,6 @@ Language Spec.
Hacking Interpreter Hacking Interpreter
* hash[key] = nil may not remove entry; hashes may have nil as the value.
* RUBYOPT environment variable * RUBYOPT environment variable
* non-blocking open (e.g. named pipe) for thread * non-blocking open (e.g. named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr * avoid blocking with gethostbyname/gethostbyaddr
@ -27,7 +27,9 @@ Hacking Interpreter
Standard Libraries 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,...) ?? * Struct::new([name,]member,...) ??
* String#scanf(?) * String#scanf(?)
* Object#fmt(?) * Object#fmt(?)
@ -37,11 +39,10 @@ Standard Libraries
* Stream or Port, abstract superclass of IO ? * Stream or Port, abstract superclass of IO ?
* String#{pred,prev}, String#downto * String#{pred,prev}, String#downto
* optional stepsize argument for succ() * optional stepsize argument for succ()
* Dir.glob(pat){|f|...}
Extension Libraries Extension Libraries
* FastCGI ruby - FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb * ptk.rb pTk wrapper that is compatible to tk.rb
Ruby Libraries Ruby Libraries
@ -56,4 +57,4 @@ Tools
Misc Misc
* publish Ruby books - publish Ruby books

47
array.c
Просмотреть файл

@ -416,6 +416,29 @@ rb_ary_aref(argc, argv, ary)
return rb_ary_entry(ary, NUM2LONG(arg1)); 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 static VALUE
rb_ary_index(ary, val) rb_ary_index(ary, val)
VALUE ary; VALUE ary;
@ -940,22 +963,19 @@ rb_ary_delete_at(ary, at)
VALUE ary; VALUE ary;
VALUE at; VALUE at;
{ {
long i1, i2, pos; long i, pos = NUM2LONG(at), len = RARRAY(ary)->len;
VALUE del = Qnil; VALUE del = Qnil;
if (pos >= len) return Qnil;
if (pos < 0) pos += len;
if (pos < 0) return Qnil;
rb_ary_modify(ary); rb_ary_modify(ary);
pos = NUM2LONG(at); del = RARRAY(ary)->ptr[pos];
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) { for (i = pos + 1; i < len; i++, pos++) {
if (i1 == pos) { RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
del = RARRAY(ary)->ptr[i1];
continue;
}
if (i1 != i2) {
RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1];
}
i2++;
} }
RARRAY(ary)->len = i2; RARRAY(ary)->len = pos;
return del; return del;
} }
@ -1445,6 +1465,9 @@ Init_Array()
rb_define_method(rb_cArray, "[]", rb_ary_aref, -1); rb_define_method(rb_cArray, "[]", rb_ary_aref, -1);
rb_define_method(rb_cArray, "[]=", rb_ary_aset, -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, "concat", rb_ary_concat, 1);
rb_define_method(rb_cArray, "<<", rb_ary_push, 1); rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
rb_define_method(rb_cArray, "push", rb_ary_push_method, -1); rb_define_method(rb_cArray, "push", rb_ary_push_method, -1);

8
dir.c
Просмотреть файл

@ -570,6 +570,14 @@ dir_s_glob(dir, str)
} }
if (buf != buffer) if (buf != buffer)
free(buf); free(buf);
if (rb_iterator_p()) {
long len = RARRAY(ary)->len;
VALUE *ptr = RARRAY(ary)->ptr;
while (len--) {
rb_yield(*ptr++);
}
}
return ary; return ary;
} }

8
hash.c
Просмотреть файл

@ -264,7 +264,6 @@ rb_hash_s_create(argc, argv, klass)
hash = rb_hash_new2(klass); hash = rb_hash_new2(klass);
for (i=0; i<argc; i+=2) { for (i=0; i<argc; i+=2) {
if (NIL_P(argv[i+1])) continue;
st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]); st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
} }
@ -363,6 +362,9 @@ rb_hash_fetch(argc, argv, hash)
} }
return rb_yield(argv[0]); return rb_yield(argv[0]);
} }
if (argc == 1) {
rb_raise(rb_eIndexError, "key not found");
}
return if_none; return if_none;
} }
return val; return val;
@ -521,10 +523,6 @@ rb_hash_aset(hash, key, val)
VALUE hash, key, val; VALUE hash, key, val;
{ {
rb_hash_modify(hash); 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)) { if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->tbl, key, 0)) {
st_insert(RHASH(hash)->tbl, key, val); st_insert(RHASH(hash)->tbl, key, val);
} }

4
io.c
Просмотреть файл

@ -482,11 +482,15 @@ io_read(argc, argv, io)
} }
len = NUM2INT(length); len = NUM2INT(length);
if (len < 0) {
rb_raise(rb_eArgError, "negative length %d given", len);
}
GetOpenFile(io, fptr); GetOpenFile(io, fptr);
rb_io_check_readable(fptr); rb_io_check_readable(fptr);
if (feof(fptr->f)) return Qnil; if (feof(fptr->f)) return Qnil;
str = rb_str_new(0, len); str = rb_str_new(0, len);
if (len == 0) return str;
READ_CHECK(fptr->f); READ_CHECK(fptr->f);
n = io_fread(RSTRING(str)->ptr, len, fptr->f); n = io_fread(RSTRING(str)->ptr, len, fptr->f);

10
parse.y
Просмотреть файл

@ -1182,8 +1182,18 @@ primary : literal
} }
f_arglist f_arglist
compstmt compstmt
rescue
opt_else
ensure
kEND 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 */ /* NOEX_PRIVATE for toplevel */
$$ = NEW_DEFN($2, $4, $5, class_nest?0:1); $$ = NEW_DEFN($2, $4, $5, class_nest?0:1);
fixpos($$, $4); fixpos($$, $4);

Просмотреть файл

@ -9,6 +9,8 @@ if File.exist? CONFIG['LIBRUBY_SO']
dldpath = "SHLIB_PATH" dldpath = "SHLIB_PATH"
when /-aix/ when /-aix/
dldpath = "LIBPATH" dldpath = "LIBPATH"
when /-beos/
dldpath = "LIBRARY_PATH"
else else
dldpath = "LD_LIBRARY_PATH" dldpath = "LD_LIBRARY_PATH"
end end

Просмотреть файл

@ -298,7 +298,7 @@ posix_signal(signum, handler)
sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
#endif #endif
#ifdef SA_NOCLDWAIT #ifdef SA_NOCLDWAIT
if (signum == SIGCHLD && handler == (RETSIGTYPE)SIG_IGN) if (signum == SIGCHLD && handler == SIG_IGN)
sigact.sa_flags |= SA_NOCLDWAIT; sigact.sa_flags |= SA_NOCLDWAIT;
#endif #endif
sigaction(signum, &sigact, 0); sigaction(signum, &sigact, 0);

4
st.c
Просмотреть файл

@ -79,8 +79,8 @@ static long primes[] = {
32 + 5, 32 + 5,
64 + 3, 64 + 3,
128 + 3, 128 + 3,
256 + 29, 256 + 27,
512 + 17, 512 + 9,
1024 + 9, 1024 + 9,
2048 + 5, 2048 + 5,
4096 + 83, 4096 + 83,

Просмотреть файл

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.4.2" #define RUBY_VERSION "1.5.0"
#define RUBY_RELEASE_DATE "1999-09-18" #define RUBY_RELEASE_DATE "1999-10-12"
#define RUBY_VERSION_CODE 142 #define RUBY_VERSION_CODE 150
#define RUBY_RELEASE_CODE 19990918 #define RUBY_RELEASE_CODE 19991012