summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 04:03:15 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 04:03:15 +0000
commit1434fc3fa86b51a344c0d6176229229b50d87a95 (patch)
tree094306fe910429085fb25745ffa202de9243ad04
parent0eb420cc78e5027a2611057a535fd255e87723fb (diff)
* enumerator.c (enumerator_allocate, enumerator_ptr): Properly
detect if the object is initialized and raise error when appropriate. (enumerator_initialize): Fix a typo in rdoc. [ruby-core:17052] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--enumerator.c22
-rw-r--r--version.h2
3 files changed, 24 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a638fdf05..16fb072edd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jun 3 12:51:57 2008 Akinori MUSHA <knu@iDaemons.org>
+
+ * enumerator.c (enumerator_allocate, enumerator_ptr): Properly
+ detect if the object is initialized and raise error when
+ appropriate.
+ (enumerator_initialize): Fix a typo in rdoc. [ruby-core:17052]
+
Tue Jun 3 10:16:40 2008 Akinori MUSHA <knu@iDaemons.org>
* lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug
diff --git a/enumerator.c b/enumerator.c
index e0365fc5bc..8d5061d308 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -55,7 +55,7 @@ enumerator_ptr(obj)
"wrong argument type %s (expected Enumerable::Enumerator)",
rb_obj_classname(obj));
}
- if (!ptr) {
+ if (!ptr || ptr->obj == Qundef) {
rb_raise(rb_eArgError, "uninitialized enumerator");
}
return ptr;
@@ -214,8 +214,13 @@ enumerator_allocate(klass)
VALUE klass;
{
struct enumerator *ptr;
- return Data_Make_Struct(klass, struct enumerator,
- enumerator_mark, -1, ptr);
+ VALUE enum_obj;
+
+ enum_obj = Data_Make_Struct(klass, struct enumerator,
+ enumerator_mark, -1, ptr);
+ ptr->obj = Qundef;
+
+ return enum_obj;
}
static VALUE enumerator_each_i _((VALUE, VALUE));
@@ -235,7 +240,13 @@ enumerator_init(enum_obj, obj, meth, argc, argv)
int argc;
VALUE *argv;
{
- struct enumerator *ptr = enumerator_ptr(enum_obj);
+ struct enumerator *ptr;
+
+ Data_Get_Struct(enum_obj, struct enumerator, ptr);
+
+ if (!ptr) {
+ rb_raise(rb_eArgError, "unallocated enumerator");
+ }
ptr->obj = obj;
ptr->meth = rb_to_id(meth);
@@ -253,8 +264,7 @@ enumerator_init(enum_obj, obj, meth, argc, argv)
* used as an Enumerable object using the given object's given
* method with the given arguments.
*
- * Use of this method is not discouraged. Use Kernel#enum_for()
- * instead.
+ * Use of this method is discouraged. Use Kernel#enum_for() instead.
*/
static VALUE
enumerator_initialize(argc, argv, obj)
diff --git a/version.h b/version.h
index bfda2b1cc6..9866b0878b 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-06-03"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20080603
-#define RUBY_PATCHLEVEL 2
+#define RUBY_PATCHLEVEL 3
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8