ruby-changes:4631
From: ko1@a...
Date: Mon, 21 Apr 2008 17:48:58 +0900 (JST)
Subject: [ruby-changes:4631] knu - Ruby:r16125 (trunk): * ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
knu 2008-04-21 17:48:33 +0900 (Mon, 21 Apr 2008)
New Revision: 16125
Modified files:
trunk/ChangeLog
trunk/ext/dbm/dbm.c
trunk/ext/gdbm/gdbm.c
trunk/ext/openssl/ossl_config.c
trunk/ext/readline/readline.c
trunk/ext/sdbm/init.c
trunk/ext/stringio/stringio.c
trunk/ext/win32ole/win32ole.c
trunk/ext/zlib/zlib.c
Log:
* 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.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_config.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/win32ole/win32ole.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/stringio/stringio.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/readline/readline.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/gdbm/gdbm.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/dbm/dbm.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/sdbm/init.c?r1=16125&r2=16124&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/zlib/zlib.c?r1=16125&r2=16124&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16124)
+++ ChangeLog (revision 16125)
@@ -1,3 +1,41 @@
+Mon Apr 21 17:45:27 2008 Akinori MUSHA <knu@i...>
+
+ * 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@r...>
* iseq.c (rb_iseq_compile_with_option): check if src is a string.
Index: ext/sdbm/init.c
===================================================================
--- ext/sdbm/init.c (revision 16124)
+++ ext/sdbm/init.c (revision 16125)
@@ -486,6 +486,8 @@
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 @@
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 @@
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);
Index: ext/zlib/zlib.c
===================================================================
--- ext/zlib/zlib.c (revision 16124)
+++ ext/zlib/zlib.c (revision 16125)
@@ -2934,6 +2934,9 @@
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 @@
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 @@
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));
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c (revision 16124)
+++ ext/win32ole/win32ole.c (revision 16125)
@@ -3699,6 +3699,8 @@
HRESULT hr;
IEnumVARIANT *pEnum = NULL;
+ RETURN_ENUMERATOR(self, 0, 0);
+
VariantInit(&result);
dispParams.rgvarg = NULL;
dispParams.rgdispidNamedArgs = NULL;
Index: ext/readline/readline.c
===================================================================
--- ext/readline/readline.c (revision 16124)
+++ ext/readline/readline.c (revision 16125)
@@ -620,6 +620,8 @@
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);
Index: ext/openssl/ossl_config.c
===================================================================
--- ext/openssl/ossl_config.c (revision 16124)
+++ ext/openssl/ossl_config.c (revision 16125)
@@ -389,6 +389,8 @@
{
CONF *conf;
+ RETURN_ENUMERATOR(self, 0, 0);
+
GetConfig(self, conf);
lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(each_conf_value), (void*)NULL);
Index: ext/stringio/stringio.c
===================================================================
--- ext/stringio/stringio.c (revision 16124)
+++ ext/stringio/stringio.c (revision 16125)
@@ -614,6 +614,9 @@
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 @@
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 @@
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);
Index: ext/dbm/dbm.c
===================================================================
--- ext/dbm/dbm.c (revision 16124)
+++ ext/dbm/dbm.c (revision 16125)
@@ -505,6 +505,8 @@
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 @@
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 @@
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)) {
Index: ext/gdbm/gdbm.c
===================================================================
--- ext/gdbm/gdbm.c (revision 16124)
+++ ext/gdbm/gdbm.c (revision 16125)
@@ -801,6 +801,8 @@
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 @@
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 @@
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)) {
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/