git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-07-04 07:04:42 +00:00
Родитель 38402e0415
Коммит 7909682940
8 изменённых файлов: 268 добавлений и 16 удалений

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

@ -1,3 +1,14 @@
Tue Jul 4 13:51:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* ext/dbm/dbm.c: add methods added to Hash in 1.5.x.
* ext/gdbm/gdbm.c: ditto.
* ext/sdbm/init.c: ditto.
* eval.c (proc_call): args may be Qundef (means no argument), do
not call TYPE() for args.
Tue Jul 4 13:20:56 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* ext/extmk.rb.in: make command line must be single-quoted.

2
eval.c
Просмотреть файл

@ -5919,7 +5919,7 @@ proc_call(proc, args)
PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;
if (TYPE(args) == T_ARRAY) {
if (args != Qundef && TYPE(args) == T_ARRAY) {
args = callargs(args);
}

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

@ -106,8 +106,8 @@ fdbm_close(obj)
}
static VALUE
fdbm_fetch(obj, keystr)
VALUE obj, keystr;
fdbm_fetch(obj, keystr, ifnone)
VALUE obj, keystr, ifnone;
{
datum key, value;
struct dbmdata *dbmp;
@ -121,11 +121,55 @@ fdbm_fetch(obj, keystr)
dbm = dbmp->di_dbm;
value = dbm_fetch(dbm, key);
if (value.dptr == 0) {
return Qnil;
if (ifnone == Qnil && rb_block_given_p())
return rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
return ifnone;
}
return rb_tainted_str_new(value.dptr, value.dsize);
}
static VALUE
fdbm_aref(obj, keystr)
VALUE obj, keystr;
{
return fdbm_fetch(obj, keystr, Qnil);
}
static VALUE
fdbm_fetch_m(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
VALUE keystr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
return fdbm_fetch(obj, keystr, ifnone);
}
static VALUE
fdbm_index(obj, valstr)
VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
Check_Type(valstr, T_STRING);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return rb_tainted_str_new(key.dptr, key.dsize);
}
return Qnil;
}
static VALUE
fdbm_indexes(argc, argv, obj)
int argc;
@ -539,6 +583,35 @@ fdbm_to_a(obj)
return ary;
}
static VALUE
fdbm_to_hash(obj)
VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
VALUE hash;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
hash = rb_hash_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
rb_tainted_str_new(val.dptr, val.dsize));
}
return hash;
}
static VALUE
fdbm_reject(obj)
VALUE obj;
{
return rb_hash_delete_if(fdbm_to_hash(obj));
}
void
Init_dbm()
{
@ -548,8 +621,11 @@ Init_dbm()
rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
rb_define_singleton_method(cDBM, "new", fdbm_s_open, -1);
rb_define_method(cDBM, "close", fdbm_close, 0);
rb_define_method(cDBM, "[]", fdbm_fetch, 1);
rb_define_method(cDBM, "[]", fdbm_aref, 1);
rb_define_method(cDBM, "fetch", fdbm_fetch_m, -1);
rb_define_method(cDBM, "[]=", fdbm_store, 2);
rb_define_method(cDBM, "store", fdbm_store, 2);
rb_define_method(cDBM, "index", fdbm_index, 1);
rb_define_method(cDBM, "indexes", fdbm_indexes, -1);
rb_define_method(cDBM, "indices", fdbm_indexes, -1);
rb_define_method(cDBM, "length", fdbm_length, 0);
@ -564,6 +640,8 @@ Init_dbm()
rb_define_method(cDBM, "shift", fdbm_shift, 1);
rb_define_method(cDBM, "delete", fdbm_delete, 1);
rb_define_method(cDBM, "delete_if", fdbm_delete_if, 0);
rb_define_method(cDBM, "reject!", fdbm_delete_if, 0);
rb_define_method(cDBM, "reject", fdbm_reject, 0);
rb_define_method(cDBM, "clear", fdbm_clear, 0);
rb_define_method(cDBM,"invert", fdbm_invert, 0);
rb_define_method(cDBM,"update", fdbm_update, 1);
@ -571,9 +649,11 @@ Init_dbm()
rb_define_method(cDBM, "include?", fdbm_has_key, 1);
rb_define_method(cDBM, "has_key?", fdbm_has_key, 1);
rb_define_method(cDBM, "member?", fdbm_has_key, 1);
rb_define_method(cDBM, "has_value?", fdbm_has_value, 1);
rb_define_method(cDBM, "key?", fdbm_has_key, 1);
rb_define_method(cDBM, "value?", fdbm_has_value, 1);
rb_define_method(cDBM, "to_a", fdbm_to_a, 0);
rb_define_method(cDBM, "to_hash", fdbm_to_hash, 0);
}

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

@ -103,8 +103,8 @@ fgdbm_close(obj)
}
static VALUE
fgdbm_fetch(obj, keystr)
VALUE obj, keystr;
fgdbm_fetch(obj, keystr, ifnone)
VALUE obj, keystr, ifnone;
{
datum key, value;
struct dbmdata *dbmp;
@ -118,11 +118,55 @@ fgdbm_fetch(obj, keystr)
dbm = dbmp->di_dbm;
value = gdbm_fetch(dbm, key);
if (value.dptr == 0) {
return Qnil;
if (ifnone == Qnil && rb_block_given_p())
return rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
return ifnone;
}
return rb_tainted_str_new(value.dptr, value.dsize);
}
static VALUE
fgdbm_aref(obj, keystr)
VALUE obj, keystr;
{
return fgdbm_fetch(obj, keystr, Qnil);
}
static VALUE
fgdbm_fetch_m(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
VALUE keystr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
return fgdbm_fetch(obj, keystr, ifnone);
}
static VALUE
fgdbm_index(obj, valstr)
VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
Check_Type(valstr, T_STRING);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
val = gdbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return rb_tainted_str_new(key.dptr, key.dsize);
}
return Qnil;
}
static VALUE
fgdbm_indexes(argc, argv, obj)
int argc;
@ -548,6 +592,35 @@ fgdbm_reorganize(obj)
return obj;
}
static VALUE
fgdbm_to_hash(obj)
VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
VALUE hash;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
hash = rb_hash_new();
for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
val = gdbm_fetch(dbm, key);
rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
rb_tainted_str_new(val.dptr, val.dsize));
}
return hash;
}
static VALUE
fgdbm_reject(obj)
VALUE obj;
{
return rb_hash_delete_if(fgdbm_to_hash(obj));
}
void
Init_gdbm()
{
@ -557,8 +630,11 @@ Init_gdbm()
rb_define_singleton_method(cGDBM, "open", fgdbm_s_open, -1);
rb_define_singleton_method(cGDBM, "new", fgdbm_s_open, -1);
rb_define_method(cGDBM, "close", fgdbm_close, 0);
rb_define_method(cGDBM, "[]", fgdbm_fetch, 1);
rb_define_method(cGDBM, "[]", fgdbm_aref, 1);
rb_define_method(cGDBM, "fetch", fgdbm_fetch_m, -1);
rb_define_method(cGDBM, "[]=", fgdbm_store, 2);
rb_define_method(cGDBM, "store", fgdbm_store, 2);
rb_define_method(cGDBM, "index", fgdbm_index, 1);
rb_define_method(cGDBM, "indexes", fgdbm_indexes, -1);
rb_define_method(cGDBM, "indices", fgdbm_indexes, -1);
rb_define_method(cGDBM, "length", fgdbm_length, 0);
@ -573,6 +649,8 @@ Init_gdbm()
rb_define_method(cGDBM, "shift", fgdbm_shift, 1);
rb_define_method(cGDBM, "delete", fgdbm_delete, 1);
rb_define_method(cGDBM, "delete_if", fgdbm_delete_if, 0);
rb_define_method(cGDBM, "reject!", fgdbm_delete_if, 0);
rb_define_method(cGDBM, "reject", fgdbm_reject, 0);
rb_define_method(cGDBM, "clear", fgdbm_clear, 0);
rb_define_method(cGDBM,"invert", fgdbm_invert, 0);
rb_define_method(cGDBM,"update", fgdbm_update, 1);
@ -581,9 +659,11 @@ Init_gdbm()
rb_define_method(cGDBM, "include?", fgdbm_has_key, 1);
rb_define_method(cGDBM, "has_key?", fgdbm_has_key, 1);
rb_define_method(cGDBM, "member?", fgdbm_has_key, 1);
rb_define_method(cGDBM, "has_value?", fgdbm_has_value, 1);
rb_define_method(cGDBM, "key?", fgdbm_has_key, 1);
rb_define_method(cGDBM, "value?", fgdbm_has_value, 1);
rb_define_method(cGDBM, "to_a", fgdbm_to_a, 0);
rb_define_method(cGDBM, "to_hash", fgdbm_to_hash, 0);
}

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

@ -100,8 +100,8 @@ fsdbm_close(obj)
}
static VALUE
fsdbm_fetch(obj, keystr)
VALUE obj, keystr;
fsdbm_fetch(obj, keystr, ifnone)
VALUE obj, keystr, ifnone;
{
datum key, value;
struct dbmdata *dbmp;
@ -115,11 +115,55 @@ fsdbm_fetch(obj, keystr)
dbm = dbmp->di_dbm;
value = sdbm_fetch(dbm, key);
if (value.dptr == 0) {
return Qnil;
if (ifnone == Qnil && rb_block_given_p())
return rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
return ifnone;
}
return rb_tainted_str_new(value.dptr, value.dsize);
}
static VALUE
fsdbm_aref(obj, keystr)
VALUE obj, keystr;
{
return fsdbm_fetch(obj, keystr, Qnil);
}
static VALUE
fsdbm_fetch_m(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
VALUE keystr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
return fsdbm_fetch(obj, keystr, ifnone);
}
static VALUE
fsdbm_index(obj, valstr)
VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
Check_Type(valstr, T_STRING);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return rb_tainted_str_new(key.dptr, key.dsize);
}
return Qnil;
}
static VALUE
fsdbm_indexes(argc, argv, obj)
int argc;
@ -540,6 +584,35 @@ fsdbm_to_a(obj)
return ary;
}
static VALUE
fsdbm_to_hash(obj)
VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
VALUE hash;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
hash = rb_hash_new();
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
rb_tainted_str_new(val.dptr, val.dsize));
}
return hash;
}
static VALUE
fsdbm_reject(obj)
VALUE obj;
{
return rb_hash_delete_if(fsdbm_to_hash(obj));
}
void
Init_sdbm()
{
@ -549,8 +622,11 @@ Init_sdbm()
rb_define_singleton_method(cSDBM, "open", fsdbm_s_open, -1);
rb_define_singleton_method(cSDBM, "new", fsdbm_s_open, -1);
rb_define_method(cSDBM, "close", fsdbm_close, 0);
rb_define_method(cSDBM, "[]", fsdbm_fetch, 1);
rb_define_method(cSDBM, "[]", fsdbm_aref, 1);
rb_define_method(cSDBM, "fetch", fsdbm_fetch_m, -1);
rb_define_method(cSDBM, "[]=", fsdbm_store, 2);
rb_define_method(cSDBM, "store", fsdbm_store, 2);
rb_define_method(cSDBM, "index", fsdbm_index, 1);
rb_define_method(cSDBM, "indexes", fsdbm_indexes, -1);
rb_define_method(cSDBM, "indices", fsdbm_indexes, -1);
rb_define_method(cSDBM, "length", fsdbm_length, 0);
@ -565,6 +641,8 @@ Init_sdbm()
rb_define_method(cSDBM, "shift", fsdbm_shift, 1);
rb_define_method(cSDBM, "delete", fsdbm_delete, 1);
rb_define_method(cSDBM, "delete_if", fsdbm_delete_if, 0);
rb_define_method(cSDBM, "reject!", fsdbm_delete_if, 0);
rb_define_method(cSDBM, "reject", fsdbm_reject, 0);
rb_define_method(cSDBM, "clear", fsdbm_clear, 0);
rb_define_method(cSDBM,"invert", fsdbm_invert, 0);
rb_define_method(cSDBM,"update", fsdbm_update, 1);
@ -572,9 +650,11 @@ Init_sdbm()
rb_define_method(cSDBM, "include?", fsdbm_has_key, 1);
rb_define_method(cSDBM, "has_key?", fsdbm_has_key, 1);
rb_define_method(cSDBM, "member?", fsdbm_has_key, 1);
rb_define_method(cSDBM, "has_value?", fsdbm_has_value, 1);
rb_define_method(cSDBM, "key?", fsdbm_has_key, 1);
rb_define_method(cSDBM, "value?", fsdbm_has_value, 1);
rb_define_method(cSDBM, "to_a", fsdbm_to_a, 0);
rb_define_method(cSDBM, "to_hash", fsdbm_to_hash, 0);
}

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

@ -475,7 +475,7 @@ delete_if_i(key, value)
return ST_CONTINUE;
}
static VALUE
VALUE
rb_hash_delete_if(hash)
VALUE hash;
{

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

@ -186,6 +186,7 @@ VALUE rb_hash_new _((void));
VALUE rb_hash_freeze _((VALUE));
VALUE rb_hash_aref _((VALUE, VALUE));
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
VALUE rb_hash_delete_if _((VALUE));
int rb_path_check _((char *));
int rb_env_path_tainted _((void));
/* io.c */

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

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.4"
#define RUBY_RELEASE_DATE "2000-07-03"
#define RUBY_RELEASE_DATE "2000-07-04"
#define RUBY_VERSION_CODE 154
#define RUBY_RELEASE_CODE 20000703
#define RUBY_RELEASE_CODE 20000704