Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.
/ ruby-discid Public archive

Commit c8aa155

Browse files
author
phw
committed
Fixed calling +read+ method without argument
git-svn-id: svn://rubyforge.org/var/svn/rbrainz/mb-discid/trunk@301 b628d043-b88c-46ef-b09a-645d37a1a36e
1 parent 9cff9c0 commit c8aa155

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
= Changelog
22

3+
== 0.1.4 (2009-11-19)
4+
* Fixed calling +read+ method without argument
5+
36
== 0.1.3 (2009-11-19)
47
* Added singleton method +sectors_to_seconds+ to convert sectors into seconds
58
* Added method +seconds+ to retrieve disc length in seconds

ext/mb_discid.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static VALUE mb_discid_tracks(VALUE self)
186186
INT2FIX(discid_get_track_offset(disc, track)),
187187
INT2FIX(discid_get_track_length(disc, track)) );
188188

189-
if (rb_block_given_p())
189+
if (rb_block_given_p())
190190
rb_yield(tuple);
191191
else
192192
rb_ary_push(result, tuple);
@@ -221,17 +221,18 @@ static VALUE mb_discid_read(int argc, VALUE *argv, VALUE self)
221221
Data_Get_Struct(self, DiscId, disc);
222222

223223
/* Check the number and types of arguments */
224-
rb_scan_args(argc, argv, "1", &device);
225-
if(rb_respond_to(device, rb_intern("to_s")))
226-
device = rb_funcall(device, rb_intern("to_s"), 0, 0);
227-
else
228-
rb_raise(rb_eTypeError, "wrong argument type (expected String)");
229-
224+
rb_scan_args(argc, argv, "01", &device);
225+
230226
/* Use the default device if none was given. */
231227
if (device == Qnil)
232228
cdevice = discid_get_default_device();
233-
else
229+
else if (rb_respond_to(device, rb_intern("to_s")))
230+
{
231+
device = rb_funcall(device, rb_intern("to_s"), 0, 0);
234232
cdevice = StringValuePtr(device);
233+
}
234+
else
235+
rb_raise(rb_eTypeError, "wrong argument type (expected String)");
235236

236237
/* Mark the disc id as unread in case something goes wrong. */
237238
rb_iv_set(self, "@read", Qfalse);

0 commit comments

Comments
 (0)