summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog38
-rw-r--r--ext/dbm/dbm.c6
-rw-r--r--ext/gdbm/gdbm.c6
-rw-r--r--ext/openssl/ossl_config.c2
-rw-r--r--ext/readline/readline.c2
-rw-r--r--ext/sdbm/init.c6
-rw-r--r--ext/stringio/stringio.c7
-rw-r--r--ext/win32ole/win32ole.c2
-rw-r--r--ext/zlib/zlib.c8
9 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 85b238a..2ac3a89 100644
--- a/ChangeLog
+++ b/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.
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 818eaa7..8cad97c 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -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)) {
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 8a1acbc..04fdf88 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -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)) {
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
index cc8e324..9252f7c 100644
--- a/ext/openssl/ossl_config.c
+++ b/ext/openssl/ossl_config.c
@@ -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);
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index ffa4a5d..6481e48 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -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);
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 3810b21..239e7f2 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -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);
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 6b86708..fc589ef 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -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);
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 569fdd0..3df2506 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -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;
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 4002b75..2546daa 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -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));