summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-07 15:34:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-07 15:34:31 +0000
commit9481face427a93e1a557ecd980ec82f5d04da8d5 (patch)
tree62cdfef0f5cf342039ea74934348a4de34d77007 /io.c
parenta4c37a4b7fb14c1eb81cbd3226761c522f3a49bc (diff)
* parse.y (value_expr0): class and module statements should not be
warned for "void value expression". [ruby-talk:72989] * gc.c (add_final): should determine type by respond_to? * gc.c (define_final): ditto. * io.c (rb_io_ctl): should not depend on respond_to? * range.c (range_step): rb_check_string_type(). * process.c (proc_setgroups): new functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/io.c b/io.c
index 79c2ea3461..8fac72a0ce 100644
--- a/io.c
+++ b/io.c
@@ -3338,32 +3338,35 @@ rb_io_ctl(io, req, arg, io_p)
else if (arg == Qtrue) {
narg = 1;
}
- else if (rb_obj_is_kind_of(arg, rb_cInteger)) {
- narg = NUM2LONG(arg);
- }
else {
- StringValue(arg);
+ VALUE tmp = rb_check_string_type(arg);
+ if (NIL_P(tmp)) {
+ narg = NUM2LONG(arg);
+ }
+ else {
+ arg = tmp;
#ifdef IOCPARM_MASK
#ifndef IOCPARM_LEN
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
#endif
#endif
#ifdef IOCPARM_LEN
- len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
+ len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
#else
- len = 256; /* otherwise guess at what's safe */
+ len = 256; /* otherwise guess at what's safe */
#endif
- rb_str_modify(arg);
+ rb_str_modify(arg);
- if (len <= RSTRING(arg)->len) {
- len = RSTRING(arg)->len;
- }
- if (RSTRING(arg)->len < len) {
- rb_str_resize(arg, len+1);
+ if (len <= RSTRING(arg)->len) {
+ len = RSTRING(arg)->len;
+ }
+ if (RSTRING(arg)->len < len) {
+ rb_str_resize(arg, len+1);
+ }
+ RSTRING(arg)->ptr[len] = 17; /* a little sanity check here */
+ narg = (long)RSTRING(arg)->ptr;
}
- RSTRING(arg)->ptr[len] = 17; /* a little sanity check here */
- narg = (long)RSTRING(arg)->ptr;
}
retval = io_cntl(fileno(fptr->f), cmd, narg, io_p);
if (retval < 0) rb_sys_fail(fptr->path);