@@ -2444,17 +2444,16 @@ struct gzfile {
24442444
24452445#define GZFILE_READ_SIZE 2048
24462446
2447+ enum { read_raw_arg_len , read_raw_arg_buf , read_raw_arg__count };
24472448struct read_raw_arg {
24482449 VALUE io ;
2449- union {
2450- const VALUE argv [2 ]; /* for rb_funcallv */
2451- struct {
2452- VALUE len ;
2453- VALUE buf ;
2454- } in ;
2455- } as ;
2450+ const VALUE argv [read_raw_arg__count ]; /* for rb_funcallv */
24562451};
24572452
2453+ #define read_raw_arg_argc (ra ) \
2454+ ((int)read_raw_arg__count - NIL_P((ra)->argv[read_raw_arg__count - 1]))
2455+ #define read_raw_arg_init (io , len , buf ) { io, { len, buf } }
2456+
24582457static void
24592458gzfile_mark (void * p )
24602459{
@@ -2580,9 +2579,9 @@ gzfile_read_raw_partial(VALUE arg)
25802579{
25812580 struct read_raw_arg * ra = (struct read_raw_arg * )arg ;
25822581 VALUE str ;
2583- int argc = NIL_P (ra -> as . argv [ 1 ]) ? 1 : 2 ;
2582+ int argc = read_raw_arg_argc (ra ) ;
25842583
2585- str = rb_funcallv (ra -> io , id_readpartial , argc , ra -> as . argv );
2584+ str = rb_funcallv (ra -> io , id_readpartial , argc , ra -> argv );
25862585 Check_Type (str , T_STRING );
25872586 return str ;
25882587}
@@ -2593,8 +2592,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
25932592 struct read_raw_arg * ra = (struct read_raw_arg * )arg ;
25942593 VALUE str = Qnil ;
25952594 if (rb_obj_is_kind_of (rb_errinfo (), rb_eNoMethodError )) {
2596- int argc = NIL_P (ra -> as . argv [ 1 ]) ? 1 : 2 ;
2597- str = rb_funcallv (ra -> io , id_read , argc , ra -> as . argv );
2595+ int argc = read_raw_arg_argc (ra ) ;
2596+ str = rb_funcallv (ra -> io , id_read , argc , ra -> argv );
25982597 if (!NIL_P (str )) {
25992598 Check_Type (str , T_STRING );
26002599 }
@@ -2605,11 +2604,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
26052604static VALUE
26062605gzfile_read_raw (struct gzfile * gz , VALUE outbuf )
26072606{
2608- struct read_raw_arg ra ;
2609-
2610- ra .io = gz -> io ;
2611- ra .as .in .len = INT2FIX (GZFILE_READ_SIZE );
2612- ra .as .in .buf = outbuf ;
2607+ struct read_raw_arg ra =
2608+ read_raw_arg_init (gz -> io , INT2FIX (GZFILE_READ_SIZE ), outbuf );
26132609
26142610 return rb_rescue2 (gzfile_read_raw_partial , (VALUE )& ra ,
26152611 gzfile_read_raw_rescue , (VALUE )& ra ,
0 commit comments