From 711ded6d2866e00b42e4d7c1136b201944e16578 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 29 Oct 2001 05:28:24 +0000 Subject: [PATCH] * fhandler.h (fhandler_serial::fhandler_serial): Change to only accept unit argument. * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. (fhandler_serial::open): Avoid else when previous clause is a return(). * path.cc (get_devn): Alias /dev/ttyS0 -> /dev/com1, etc. (get_device_number): Reallow standalone "com1" as a valid name for /dev/com1. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/fhandler.h | 3 +-- winsup/cygwin/fhandler_serial.cc | 8 ++++---- winsup/cygwin/fhandler_socket.cc | 4 ++-- winsup/cygwin/fhandler_tty.cc | 4 ++-- winsup/cygwin/path.cc | 18 ++++++++++++++---- winsup/cygwin/select.cc | 2 +- 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ab60d444e..0be1193f7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2001-10-29 Christopher Faylor + + * fhandler.h (fhandler_serial::fhandler_serial): Change to only accept + unit argument. + * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. + (fhandler_serial::open): Avoid else when previous clause is a return(). + * path.cc (get_devn): Alias /dev/ttyS0 -> /dev/com1, etc. + (get_device_number): Reallow standalone "com1" as a valid name for + /dev/com1. + 2001-10-26 Christopher Faylor * select.cc (MAKEready): Check for read_ready in loop since select_read diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5294292a6..7307a8fdc 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -159,7 +159,6 @@ class fhandler_base { protected: DWORD status; -public: private: int access; HANDLE io_handle; @@ -579,7 +578,7 @@ public: OVERLAPPED io_status; /* Constructor */ - fhandler_serial (DWORD devtype = FH_SERIAL, int unit = 0); + fhandler_serial (int unit); int open (path_conv *, int flags, mode_t mode); int close (); diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index f0b1de876..a52dbb4ba 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -24,8 +24,8 @@ details. */ /**********************************************************************/ /* fhandler_serial */ -fhandler_serial::fhandler_serial (DWORD devtype, int unit) - : fhandler_base (devtype, unit), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid) +fhandler_serial::fhandler_serial (int unit) + : fhandler_base (FH_SERIAL, unit), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid) { set_need_fork_fixup (); } @@ -219,8 +219,8 @@ fhandler_serial::open (path_conv *, int flags, mode_t mode) if (!(res = this->fhandler_base::open (NULL, flags, mode))) return 0; - else - res = 1; + + res = 1; (void) SetCommMask (get_handle (), EV_RXCHAR); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index f53f7e95c..ae8df07a1 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -41,8 +41,8 @@ fhandler_dev_random* entropy_source; /**********************************************************************/ /* fhandler_socket */ -fhandler_socket::fhandler_socket () : - fhandler_base (FH_SOCKET) +fhandler_socket::fhandler_socket () + : fhandler_base (FH_SOCKET) { set_need_fork_fixup (); prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF, diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index e69930034..d8d546dbd 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -35,8 +35,8 @@ static DWORD WINAPI process_input (void *); // Input queue thread static DWORD WINAPI process_output (void *); // Output queue thread static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread -fhandler_tty_master::fhandler_tty_master (int unit) : - fhandler_pty_master (FH_TTYM, unit), console (NULL), hThread (NULL) +fhandler_tty_master::fhandler_tty_master (int unit) + : fhandler_pty_master (FH_TTYM, unit), console (NULL), hThread (NULL) { } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index ad3008c08..3115d3b8d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -846,7 +846,10 @@ get_devn (const char *name, int &unit) else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0) devn = FH_SERIAL; else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0) - devn = FH_SERIAL; + { + devn = FH_SERIAL; + unit++; + } else if (deveq ("pipe") || deveq ("piper") || deveq ("pipew")) devn = FH_PIPE; else if (deveq ("tcp") || deveq ("udp") || deveq ("streamsocket") @@ -979,14 +982,21 @@ get_device_number (const char *unix_path, const char *w32_path, int &unit) devn = get_devn (unix_path, unit); if (devn == FH_BAD && *w32_path == '\\' && wdeveqn ("\\dev\\", 5)) devn = get_devn (w32_path, unit); - if (devn == FH_BAD && udeveqn ("com", 3) - && (unit = digits (unix_path + 3)) >= 0) - devn = FH_SERIAL; if (devn == FH_BAD && wdeveqn ("\\\\.\\", 4)) devn = get_raw_device_number (unix_path + 5, w32_path + 4, unit); if (devn == FH_BAD) devn = get_raw_device_number (unix_path + 5, NULL, unit); } + else + { + char *p = strrchr (unix_path, '/'); + if (p) + unix_path = p + 1; + if (udeveqn ("com", 3) + && (unit = digits (unix_path + 3)) >= 0) + devn = FH_SERIAL; + } + return devn; } diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index e07c23bb0..78a18d316 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -352,7 +352,7 @@ out: static int set_bits (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds) + fd_set *exceptfds) { int ready = 0; select_printf ("me %p, testing fd %d (%s)", me, me->fd, me->fh->get_name ());