@@ -211,7 +211,7 @@ wait_mode_sym(VALUE mode)
211
211
/*
212
212
* call-seq:
213
213
* io.wait(events, timeout) -> event mask or false.
214
- * io.wait(timeout = nil, mode = :read) -> event mask or false (deprecated)
214
+ * io.wait(timeout = nil, mode = :read) -> event mask or false.
215
215
*
216
216
* Waits until the IO becomes ready for the specified events and returns the
217
217
* subset of events that become ready, or +false+ when times out.
@@ -222,34 +222,31 @@ wait_mode_sym(VALUE mode)
222
222
* Returns +true+ immediately when buffered data is available.
223
223
*
224
224
* Optional parameter +mode+ is one of +:read+, +:write+, or
225
- * +:read_write+ (deprecated) .
225
+ * +:read_write+.
226
226
*/
227
227
228
228
static VALUE
229
229
io_wait (int argc , VALUE * argv , VALUE io )
230
230
{
231
- VALUE timeout = Qnil ;
231
+ VALUE timeout = Qundef ;
232
232
rb_io_event_t events = 0 ;
233
233
234
- if (argc < 2 || (argc >= 2 && RB_SYMBOL_P (argv [1 ]))) {
235
- if (argc > 0 ) {
236
- timeout = argv [0 ];
237
- }
238
-
239
- for (int i = 1 ; i < argc ; i += 1 ) {
240
- events |= wait_mode_sym (argv [i ]);
234
+ if (argc != 2 || (RB_SYRB_SYMBOL_P (argv [0 ]) || RB_SYMBOL_P (argv [1 ]))) {
235
+ for (int i = 0 ; i < argc ; i += 1 ) {
236
+ if (RB_SYMBOL_P (argv [i ])) {
237
+ events |= wait_mode_sym (argv [i ]);
238
+ }
239
+ else if (timeout == Qundef ) {
240
+ rb_time_interval (timeout = argv [i ]);
241
+ }
242
+ else {
243
+ rb_raise (rb_eArgError , "timeout given more than once" );
244
+ }
241
245
}
242
246
}
243
- else if ( argc == 2 ) {
247
+ else /* argc == 2 */ {
244
248
events = RB_NUM2UINT (argv [0 ]);
245
-
246
- if (argv [1 ] != Qnil ) {
247
- timeout = argv [1 ];
248
- }
249
- }
250
- else {
251
- // TODO error
252
- return Qnil ;
249
+ timeout = argv [1 ];
253
250
}
254
251
255
252
if (events == 0 ) {
0 commit comments