зеркало из https://github.com/github/ruby.git
* ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
GDBM#{each,each_pair,each_key,each_value}: Return an enumerator if no block is given. * ext/gdbm/gdbm.c (fgdbm_each_value, fgdbm_each_key, fgdbm_each_pair): GDBM#{each,each_pair,each_key,each_value}: Return an enumerator if no block is given. * ext/openssl/ossl_config.c (ossl_config_each): OpenSSL::Config#each: Return an enumerator if no block is given. * ext/readline/readline.c (hist_each): Readline::HISTORY#each: Return an enumerator if no block is given. * ext/sdbm/init.c (fsdbm_each_value, fsdbm_each_key, fsdbm_each_pair): SDBM#{each,each_pair,each_key,each_value}: Return an enumerator if no block is given. * ext/stringio/stringio.c (strio_each_byte, strio_each): StringIO#{each,each_line,each_byte}: Return an enumerator if no block is given. * ext/stringio/stringio.c (Init_stringio): Add #lines and #bytes, which are aliases to #each_line and #each_byte, respectively. * ext/win32ole/win32ole.c (fole_each): WIN32OLE#each: Return an enumerator if no block is given. * ext/zlib/zlib.c (rb_gzreader_each_byte, rb_gzreader_each): Zlib::GzipReader#{each,each_line,each_byte}: Return an enumerator if no block is given. * ext/zlib/zlib.c (Init_zlib): Add Zlib::GzipReader#lines and #bytes, which are aliases to #each_line and #each_byte, respectively. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
eeceb720a9
Коммит
ffc456d0ed
38
ChangeLog
38
ChangeLog
|
@ -1,3 +1,41 @@
|
|||
Mon Apr 21 17:45:27 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
|
||||
GDBM#{each,each_pair,each_key,each_value}: Return an enumerator
|
||||
if no block is given.
|
||||
|
||||
* ext/gdbm/gdbm.c (fgdbm_each_value, fgdbm_each_key,
|
||||
fgdbm_each_pair): GDBM#{each,each_pair,each_key,each_value}:
|
||||
Return an enumerator if no block is given.
|
||||
|
||||
* ext/openssl/ossl_config.c (ossl_config_each):
|
||||
OpenSSL::Config#each: Return an enumerator if no block is given.
|
||||
|
||||
* ext/readline/readline.c (hist_each): Readline::HISTORY#each:
|
||||
Return an enumerator if no block is given.
|
||||
|
||||
* ext/sdbm/init.c (fsdbm_each_value, fsdbm_each_key,
|
||||
fsdbm_each_pair): SDBM#{each,each_pair,each_key,each_value}:
|
||||
Return an enumerator if no block is given.
|
||||
|
||||
* ext/stringio/stringio.c (strio_each_byte, strio_each):
|
||||
StringIO#{each,each_line,each_byte}: Return an enumerator if no
|
||||
block is given.
|
||||
|
||||
* ext/stringio/stringio.c (Init_stringio): Add #lines and #bytes,
|
||||
which are aliases to #each_line and #each_byte, respectively.
|
||||
|
||||
* ext/win32ole/win32ole.c (fole_each): WIN32OLE#each: Return an
|
||||
enumerator if no block is given.
|
||||
|
||||
* ext/zlib/zlib.c (rb_gzreader_each_byte, rb_gzreader_each):
|
||||
Zlib::GzipReader#{each,each_line,each_byte}: Return an
|
||||
enumerator if no block is given.
|
||||
|
||||
* ext/zlib/zlib.c (Init_zlib): Add Zlib::GzipReader#lines and
|
||||
#bytes, which are aliases to #each_line and #each_byte,
|
||||
respectively.
|
||||
|
||||
Mon Apr 21 17:01:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* iseq.c (rb_iseq_compile_with_option): check if src is a string.
|
||||
|
|
|
@ -505,6 +505,8 @@ fdbm_each_value(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
DBM *dbm;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
||||
val = dbm_fetch(dbm, key);
|
||||
|
@ -521,6 +523,8 @@ fdbm_each_key(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
DBM *dbm;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
||||
rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
|
||||
|
@ -537,6 +541,8 @@ fdbm_each_pair(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
VALUE keystr, valstr;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
|
||||
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
||||
|
|
|
@ -801,6 +801,8 @@ fgdbm_each_value(VALUE obj)
|
|||
GDBM_FILE dbm;
|
||||
VALUE keystr;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
|
||||
keystr = rb_gdbm_nextkey(dbm, keystr)) {
|
||||
|
@ -825,6 +827,8 @@ fgdbm_each_key(VALUE obj)
|
|||
GDBM_FILE dbm;
|
||||
VALUE keystr;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
|
||||
keystr = rb_gdbm_nextkey(dbm, keystr)) {
|
||||
|
@ -849,6 +853,8 @@ fgdbm_each_pair(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
VALUE keystr;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
|
||||
keystr = rb_gdbm_nextkey(dbm, keystr)) {
|
||||
|
|
|
@ -389,6 +389,8 @@ ossl_config_each(VALUE self)
|
|||
{
|
||||
CONF *conf;
|
||||
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
|
||||
GetConfig(self, conf);
|
||||
lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(each_conf_value), (void*)NULL);
|
||||
|
||||
|
|
|
@ -620,6 +620,8 @@ hist_each(VALUE self)
|
|||
HIST_ENTRY *entry;
|
||||
int i;
|
||||
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
|
||||
rb_secure(4);
|
||||
for (i = 0; i < history_length; i++) {
|
||||
entry = history_get(history_base + i);
|
||||
|
|
|
@ -486,6 +486,8 @@ fsdbm_each_value(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
DBM *dbm;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
|
||||
val = sdbm_fetch(dbm, key);
|
||||
|
@ -502,6 +504,8 @@ fsdbm_each_key(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
DBM *dbm;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
|
||||
rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
|
||||
|
@ -518,6 +522,8 @@ fsdbm_each_pair(VALUE obj)
|
|||
struct dbmdata *dbmp;
|
||||
VALUE keystr, valstr;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
GetDBM2(obj, dbmp, dbm);
|
||||
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
|
||||
val = sdbm_fetch(dbm, key);
|
||||
|
|
|
@ -614,6 +614,9 @@ static VALUE
|
|||
strio_each_byte(VALUE self)
|
||||
{
|
||||
struct StringIO *ptr = readable(StringIO(self));
|
||||
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
|
||||
while (ptr->pos < RSTRING_LEN(ptr->string)) {
|
||||
char c = RSTRING_PTR(ptr->string)[ptr->pos++];
|
||||
rb_yield(CHR2FIX(c));
|
||||
|
@ -926,6 +929,8 @@ strio_each(int argc, VALUE *argv, VALUE self)
|
|||
struct StringIO *ptr = StringIO(self);
|
||||
VALUE line;
|
||||
|
||||
RETURN_ENUMERATOR(self, argc, argv);
|
||||
|
||||
while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
|
||||
rb_yield(line);
|
||||
}
|
||||
|
@ -1233,7 +1238,9 @@ Init_stringio()
|
|||
|
||||
rb_define_method(StringIO, "each", strio_each, -1);
|
||||
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
|
||||
rb_define_method(StringIO, "bytes", strio_each_byte, -1);
|
||||
rb_define_method(StringIO, "each_line", strio_each, -1);
|
||||
rb_define_method(StringIO, "lines", strio_each, -1);
|
||||
rb_define_method(StringIO, "getc", strio_getc, 0);
|
||||
rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
|
||||
rb_define_method(StringIO, "readchar", strio_readchar, 0);
|
||||
|
|
|
@ -3699,6 +3699,8 @@ fole_each(VALUE self)
|
|||
HRESULT hr;
|
||||
IEnumVARIANT *pEnum = NULL;
|
||||
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
|
||||
VariantInit(&result);
|
||||
dispParams.rgvarg = NULL;
|
||||
dispParams.rgdispidNamedArgs = NULL;
|
||||
|
|
|
@ -2934,6 +2934,9 @@ static VALUE
|
|||
rb_gzreader_each_byte(VALUE obj)
|
||||
{
|
||||
VALUE c;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
while (!NIL_P(c = rb_gzreader_getc(obj))) {
|
||||
rb_yield(c);
|
||||
}
|
||||
|
@ -3102,6 +3105,9 @@ static VALUE
|
|||
rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE str;
|
||||
|
||||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
|
||||
rb_yield(str);
|
||||
}
|
||||
|
@ -3361,11 +3367,13 @@ void Init_zlib()
|
|||
rb_define_method(cGzipReader, "getc", rb_gzreader_getc, 0);
|
||||
rb_define_method(cGzipReader, "readchar", rb_gzreader_readchar, 0);
|
||||
rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
|
||||
rb_define_method(cGzipReader, "bytes", rb_gzreader_each_byte, 0);
|
||||
rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
|
||||
rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
|
||||
rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
|
||||
rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
|
||||
rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
|
||||
rb_define_method(cGzipReader, "lines", rb_gzreader_each, -1);
|
||||
rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
|
||||
|
||||
rb_define_const(mZlib, "OS_CODE", INT2FIX(OS_CODE));
|
||||
|
|
Загрузка…
Ссылка в новой задаче