From 9cf9c146685aaf111b9bf267db771d8905072deb Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 23 Apr 2001 17:29:33 +0000 Subject: [PATCH] * fhandler.h (fhandler_base::clear_r_binary): New method. (fhandler_base::clear_w_binary): New method. * syscalls.cc (setmode): Accept 0 as mode value. Resets text/binary behavior for fd to default. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler.h | 2 ++ winsup/cygwin/syscalls.cc | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d2224146a..b0fc4af7d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 23 13:28:35 2001 Christopher Faylor + + * fhandler.h (fhandler_base::clear_r_binary): New method. + (fhandler_base::clear_w_binary): New method. + * syscalls.cc (setmode): Accept 0 as mode value. Resets text/binary + behavior for fd to default. + Mon Apr 23 12:46:07 2001 Christopher Faylor * net.cc [errmap]: Add '0' condition. diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index fc54376da..6c432f7c9 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -197,6 +197,8 @@ public: void set_w_binary (int b) { FHCONDSETF (b, WBINARY); FHSETF (WBINSET); } void set_r_binary (int b) { FHCONDSETF (b, RBINARY); FHSETF (RBINSET); } + void clear_w_binary () {FHCLEARF (WBINARY); FHCLEARF (WBINSET); } + void clear_r_binary () {FHCLEARF (RBINARY); FHCLEARF (RBINSET); } int get_default_fmode (int flags); diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 4e862a21f..3211ab934 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1646,19 +1646,26 @@ setmode (int fd, int mode) int res; if (p->get_w_binary () && p->get_r_binary ()) res = O_BINARY; + else if (p->get_w_binset () && p->get_r_binset ()) + res = O_TEXT; /* Specifically set O_TEXT */ else - res = O_TEXT; + res = 0; if (mode & O_BINARY) { p->set_w_binary (1); p->set_r_binary (1); } - else + else if (mode & O_TEXT) { p->set_w_binary (0); p->set_r_binary (0); } + else + { + p->clear_w_binary (); + p->clear_r_binary (); + } if (_cygwin_istext_for_stdio (fd)) setmode_mode = O_TEXT;