From 1e238c5aa2e86dd64d2137968a72b26ad57923c2 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 27 Aug 2013 08:02:34 +0000 Subject: io.c: common oflags * io.c (copy_stream_body): move common open flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index d4d6642002..5cffc6eeec 100644 --- a/io.c +++ b/io.c @@ -10163,6 +10163,11 @@ copy_stream_body(VALUE arg) VALUE src_io, dst_io; rb_io_t *src_fptr = 0, *dst_fptr = 0; int src_fd, dst_fd; + const int common_oflags = 0 +#ifdef O_NOCTTY + | O_NOCTTY +#endif + ; stp->th = rb_thread_current(); @@ -10178,10 +10183,7 @@ copy_stream_body(VALUE arg) src_io = RB_TYPE_P(stp->src, T_FILE) ? stp->src : Qnil; if (NIL_P(src_io)) { VALUE args[2]; - int oflags = O_RDONLY; -#ifdef O_NOCTTY - oflags |= O_NOCTTY; -#endif + const int oflags = O_RDONLY|common_oflags; FilePathValue(stp->src); args[0] = stp->src; args[1] = INT2NUM(oflags); @@ -10205,10 +10207,7 @@ copy_stream_body(VALUE arg) dst_io = RB_TYPE_P(stp->dst, T_FILE) ? stp->dst : Qnil; if (NIL_P(dst_io)) { VALUE args[3]; - int oflags = O_WRONLY|O_CREAT|O_TRUNC; -#ifdef O_NOCTTY - oflags |= O_NOCTTY; -#endif + const int oflags = O_WRONLY|O_CREAT|O_TRUNC|common_oflags; FilePathValue(stp->dst); args[0] = stp->dst; args[1] = INT2NUM(oflags); -- cgit v1.2.3