From: jeffdb AT netzone DOT com ("Mikey") Subject: Patch for stty & info.exe 18 Mar 1997 01:42:29 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199703180041.RAA13424.cygnus.gnu-win32@nz1.netzone.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01BC32F6.36302600" Content-Transfer-Encoding: 7bit Original-To: "cygnus" X-MSMail-Priority: Normal X-Priority: 3 X-Mailer: Microsoft Internet Mail 4.70.1155 Original-Sender: owner-gnu-win32 AT cygnus DOT com This is a multi-part message in MIME format. ------=_NextPart_000_01BC32F6.36302600 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit insert your favorite disclaimer here, I ain't responsible for nuttin!! ;^) The enclosed dif files are to add better support for stty, ^S ^Q and some of the others work now, and an actual patch file for getting info.exe to work thanks to Tony Fitzpatrick. I'm working under win95, with all filesystems mounted -b, so the patches are LF only. (Tony, I moved ndelay_set to fhandler.h to get it out of the public eye) Possibly O_NDELAY & O_NONBLOCK would be better implemented by using FILE_FLAG_OVERLAPPED, but in this case, it wouldn't matter, because we're using FakeReadFile for input anyway. (and I'm too lazy ;) I believe that these patches will apply and work correctly with a virgin winsup/*, but when testing them, I had the following patches applied. (My own and Sergey's fixes to FakeReadFile are included in the info.dif) Patch for diropen() fixes access to / patch for open() fixes tar overwrite bug symlinks to directories and exe's _get_osfhandle and/or mmap under cygwin dll Noer's The #! shell script patch to winsup Noer's fix for rename Patch for termcap/info support for ncurses (and maybe a few others I forget) see http://wwwdim.uqac.uquebec.ca/ftp/pub (the names may not be exact) ------=_NextPart_000_01BC32F6.36302600 Content-Type: application/octet-stream; name="info.dif" Content-Transfer-Encoding: quoted-printable Content-Description: info.dif (DIF File) Content-Disposition: attachment; filename="info.dif" --- fhandler.cc 1997/03/05 21:50:29 1.1=0A= +++ fhandler.cc 1997/03/17 21:57:47=0A= @@ -2227,16 +2568,22 @@=0A= debug_printf("FakeReadFile, res =3D %d, flags =3D %x\n", res, = flags);=0A= =0A= /* if things are special, just do what we used to */=0A= - if ((!res) =0A= - || (flags & ENABLE_LINE_INPUT) =0A= - || (ov !=3D 0))=0A= + if ((!res) || (ov !=3D0))=0A= + {=0A= + return ReadFile (hndl, pv, lenin, done, ov); =0A= + }=0A= + if (flags & ENABLE_LINE_INPUT) =0A= {=0A= + FlushConsoleInputBuffer(hndl);=0A= return ReadFile (hndl, pv, lenin, done, ov);=0A= }=0A= =0A= /* otherwise, do something that works */=0A= unsigned int num_events =3D 0, ne2, st;=0A= =0A= + if(ndelay_set =3D=3D 1) =0A= + need_chars=3D0; =0A= +=0A= st =3D GetNumberOfConsoleInputEvents (hndl, &num_events);=0A= =0A= debug_printf("FakeReadFile, GetNumberOfConsoleInputEvents returned = =3D %d\n", st);=0A= @@ -2252,8 +2599,16 @@=0A= /* so are we blocking or what? FIONBIO isn't implemented... */=0A= /* either spin here and read at least one thing, return none... = */=0A= /* readfile blocks already, so we probably can't do worse... = */=0A= +=0A= + if(ndelay_set =3D=3D 1)=0A= + {=0A= + need_chars =3D 0;=0A= + }=0A= + else=0A= + {=0A= need_chars =3D 1;=0A= } =0A= + } =0A= =0A= INPUT_RECORD input_rec;=0A= =0A= @@ -2267,6 +2622,7 @@=0A= return 0; /* seems to be failure */=0A= }=0A= /* doc says it will return at least one event... */=0A= + if (num_events)=0A= num_events--;=0A= /* check if we're just disposing of this one */=0A= =0A= @@ -2332,7 +2688,18 @@=0A= need_chars =3D 0; =0A= }=0A= *done =3D copied_chars;=0A= - return 1; /* success =3D=3D true */=0A= +=0A= + /* if we haven't got anything of interest, and we don't want to wait = for=0A= + anything (O_NDELAY is set) force the calling read to error (ret 0) = */=0A= +=0A= + if (copied_chars =3D=3D 0 && need_chars =3D=3D 0)=0A= + {=0A= + return 0;=0A= + }=0A= + else=0A= + {=0A= + return 1;=0A= + } /* success =3D=3D true */=0A= }=0A= =0A= int=0A= --- fhandler.h 1997/03/05 22:43:17 1.2=0A= +++ fhandler.h 1997/03/17 22:05:19=0A= @@ -21,6 +21,8 @@=0A= =0A= #include =0A= =0A= +extern int ndelay_set; /* for fcntl O_NDELAY in FakeReadFile */=0A= +=0A= /* Classes=0A= =0A= fhandler_base normal I/O=0A= --- fcntl.cc 1997/03/17 04:26:20 1.1=0A= +++ fcntl.cc 1997/03/17 21:41:35=0A= @@ -20,6 +20,8 @@=0A= #include =0A= #include "winsup.h"=0A= =0A= +int ndelay_set;=0A= +=0A= extern "C"=0A= int=0A= _fcntl (int fd, int cmd,...)=0A= @@ -88,6 +90,10 @@=0A= res |=3D O_WRONLY;=0A= if (this_procinfo ()->hmap[fd].h->get_access () & = GENERIC_ALL)=0A= res |=3D O_RDWR;=0A= + if (ndelay_set)=0A= + res |=3D O_NDELAY;=0A= + syscall_printf ("fcntl (F_GETFL, %d);\n", res); =0A= +=0A= goto done;=0A= =0A= case F_SETFL:=0A= @@ -101,6 +107,14 @@=0A= temp |=3D GENERIC_READ;=0A= if (arg & O_WRONLY)=0A= temp |=3D GENERIC_WRITE;=0A= + if (arg & O_NDELAY)=0A= + {=0A= + ndelay_set =3D 1;=0A= + }=0A= + else =0A= + {=0A= + ndelay_set =3D 0;=0A= + }=0A= =0A= syscall_printf ("fcntl (%d, F_SETFL, %d);\n", arg); =0A= =0A= ------=_NextPart_000_01BC32F6.36302600 Content-Type: application/octet-stream; name="stty.dif" Content-Transfer-Encoding: 7bit Content-Description: stty.dif (DIF File) Content-Disposition: attachment; filename="stty.dif" --- fhandler.cc 1997/03/05 22:43:17 1.2 +++ fhandler.cc 1997/03/17 21:57:47 @@ -180,18 +180,13 @@ int fhandler_tty::linearize(unsigned char *buf) { - int len = sizeof(vmin_) + sizeof(vtime_); + int len = 0 ; if(buf == 0) { len += this->fhandler_base::linearize(buf); return len; } - memcpy(buf,(char *)&vmin_, sizeof(vmin_)); - buf += sizeof(vmin_); - memcpy(buf,(char *)&vtime_, sizeof(vtime_)); - buf += sizeof(vtime_); - len += this->fhandler_base::linearize(buf); return len; } @@ -200,11 +195,6 @@ { const unsigned char *orig_buf = buf; - memcpy((char *)&vmin_, buf, sizeof(vmin_)); - buf += sizeof(vmin_); - memcpy((char *)&vtime_, buf, sizeof(vtime_)); - buf += sizeof(vtime_); - int len = buf - orig_buf; return (len + this->fhandler_base::de_linearize(buf)); } @@ -212,12 +202,17 @@ int fhandler_tty::raw_read (void *ptr, size_t ulen) { - if (vtime_ || vmin_) +if (s->c_cc_[VMIN] || s->c_cc_[VTIME]) + { + if (s->c_cc_[VMIN] == 0) { - if (vmin_ == 0) ulen = 1; - else if (vmin_ < ulen) - ulen = vmin_; + } + else + { + if (s->c_cc_[VMIN] < ulen) + ulen = s->c_cc_[VMIN]; + } syscall_printf ("timeout len %d\n", ulen); } return fhandler_base::raw_read (ptr, ulen); @@ -1235,8 +1230,8 @@ fhandler_tty::fhandler_tty (const char *name) : fhandler_base(name) { - vmin_ = 0; - vtime_ = 0; + s->c_cc_[VMIN] = 0; + s->c_cc_[VTIME] = 0; } int @@ -1376,13 +1371,14 @@ set_r_binary ((t->c_iflag & IGNCR) ? 0 : 1); set_w_binary ((t->c_oflag & ONLCR) ? 0 : 1); - vtime_ = t->c_cc[VTIME]; - vmin_ = t->c_cc[VMIN]; +for (int i=0;i<=NCCS;i++) + { + s->c_cc_[i] = t->c_cc[i]; + } memset (&to, 0, sizeof (to)); - to.ReadTotalTimeoutConstant = vtime_ * 100; - + to.ReadTotalTimeoutConstant = s->c_cc_[VTIME] * 100; int res = SetCommTimeouts (get_handle (), &to); if (!res) { @@ -1467,8 +1463,10 @@ if (!get_w_binary ()) t->c_oflag |= ONLCR; - t->c_cc[VTIME] =vtime_; - t->c_cc[VMIN] = vmin_; +for (int i=0;i<=NCCS;i++) + { + t->c_cc[i] = s->c_cc_[i]; + } // tdump (fd); return 0; @@ -1722,6 +1720,11 @@ /* What about ENABLE_WINDOW_INPUT and ENABLE_MOUSE_INPUT ? */ +for (int i=0;i<=NCCS;i++) + { + s->c_cc_[i] = t->c_cc[i]; + } + int res = SetConsoleMode (get_input_handle (), flags) ? 0 : -1; if (res < 0) __seterrno (); @@ -1778,7 +1781,10 @@ /* What about ENABLE_WINDOW_INPUT and ENABLE_MOUSE_INPUT ? */ - + for (int i=0;i<=NCCS;i++) + { + t->c_cc[i] = s->c_cc_[i]; + } /* All the output bits we can ignore */ res = 0; } @@ -2836,7 +2864,19 @@ /* Ensure both input and output console handles are open */ open(0,0); - + debug_printf("fhandler_console::init"); + memset (&t, 0, sizeof (t)); + t.c_cc[VEOF] = '\004'; /* ^D */ + t.c_cc[VEOL] = '\012'; /* ^J */ + t.c_cc[VERASE] = '\010'; /* ^H */ + t.c_cc[VINTR] = '\003'; /* ^C */ + t.c_cc[VKILL] = '\025'; /* ^U */ + t.c_cc[VQUIT] = '\034'; /* FS or ^\ */ + t.c_cc[VSUSP] = '\032'; /* ^Z */ + t.c_cc[VSTART] = '\021'; /* ^Q */ + t.c_cc[VSTOP] = '\023'; /* ^S */ + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; /* IGNCR doesn't work yet */ t.c_iflag = ICRNL /* | IGNCR */; t.c_oflag = bin ? 0 : ONLCR; --- fhandler.h 1997/03/05 22:43:17 1.2 +++ fhandler.h 1997/03/17 22:05:19 @@ -186,10 +190,6 @@ class fhandler_tty: public fhandler_base { -private: - unsigned int vmin_; /* from termios */ - unsigned int vtime_; /* from termios */ - public: /* Constructor */ fhandler_tty (const char *name = 0); --- winsup.h 1997/03/17 22:00:09 1.1 +++ winsup.h 1997/03/17 22:01:47 @@ -27,7 +27,7 @@ #undef sigaddset #include - +#include /* for cc_t */ #include "syscalls.h" #include "fhandler.h" #include "path.h" @@ -322,6 +322,7 @@ delqueue_list delqueue; void initialize (); + cc_t c_cc_[NCCS]; /* probably should be in registry */ }; extern shared_info *s; ------=_NextPart_000_01BC32F6.36302600-- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".