Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-12-27 06:50:29 +0300
committerChristopher Faylor <me@cgf.cx>2002-12-27 06:50:29 +0300
commit46b73ef192bc8e1ef3db88d1da99dfbe28bb371b (patch)
tree0df82ef446efc511b01e4cae86426ef1050f7115
parent4a5c645e6280415fc3fab8d0ae8d1b2da129ee6c (diff)
* fhandler.h (fhandler_termios::line_edit): Replace third argument with
passed-in termios struct. * fhandler_console.cc (fhandler_console::read): Prior to loop, make a copy of current termios for passing to line_edit prior so that all characters are processed consistently. * fhandler_tty.cc (fhandler_pty_master::write): Ditto. (process_input): Make a copy of curent termios prior to read for use in subsequent line_edit. * fhandler_termios.cc (fhandler_termios::line_edit): Replace third parameter with passed-in termios struct and use it throughout rather than the data from the current fhandler_termios class.
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_console.cc3
-rw-r--r--winsup/cygwin/fhandler_termios.cc60
-rw-r--r--winsup/cygwin/fhandler_tty.cc9
5 files changed, 53 insertions, 35 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 252aacd05..763e5fdf9 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,17 @@
+2002-12-26 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler.h (fhandler_termios::line_edit): Replace third argument with
+ passed-in termios struct.
+ * fhandler_console.cc (fhandler_console::read): Prior to loop, make a
+ copy of current termios for passing to line_edit prior so that all
+ characters are processed consistently.
+ * fhandler_tty.cc (fhandler_pty_master::write): Ditto.
+ (process_input): Make a copy of curent termios prior to read for use in
+ subsequent line_edit.
+ * fhandler_termios.cc (fhandler_termios::line_edit): Replace third
+ parameter with passed-in termios struct and use it throughout rather
+ than the data from the current fhandler_termios class.
+
2002-12-25 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number.
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index c38789b97..43db4442e 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -705,7 +705,7 @@ class fhandler_termios: public fhandler_base
set_need_fork_fixup ();
}
HANDLE& get_output_handle () { return output_handle; }
- line_edit_status line_edit (const char *rptr, int nread, int always_accept = 0);
+ line_edit_status line_edit (const char *rptr, int nread, termios&);
void set_output_handle (HANDLE h) { output_handle = h; }
void tcinit (tty_min *this_tc, int force = FALSE);
virtual int is_tty () { return 1; }
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 96ef4284f..41c1cca21 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -247,6 +247,7 @@ fhandler_console::read (void *pv, size_t& buflen)
nwait = 2;
}
+ termios ti = tc->ti;
for (;;)
{
int bgres;
@@ -461,7 +462,7 @@ fhandler_console::read (void *pv, size_t& buflen)
if (toadd)
{
- line_edit_status res = line_edit (toadd, nread);
+ line_edit_status res = line_edit (toadd, nread, ti);
if (res == line_edit_signalled)
goto sig_exit;
else if (res == line_edit_input_done)
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index 2a14db308..7b922b0f8 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -187,13 +187,13 @@ fhandler_termios::echo_erase (int force)
}
line_edit_status
-fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
+fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
{
line_edit_status ret = line_edit_ok;
char c;
int input_done = 0;
bool sawsig = false;
- int iscanon = tc->ti.c_lflag & ICANON;
+ int iscanon = ti.c_lflag & ICANON;
while (nread-- > 0)
{
@@ -205,9 +205,9 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
if (c == '\r')
{
- if (tc->ti.c_iflag & IGNCR)
+ if (ti.c_iflag & IGNCR)
continue;
- if (tc->ti.c_iflag & ICRNL)
+ if (ti.c_iflag & ICRNL)
{
c = '\n';
set_input_done (iscanon);
@@ -215,22 +215,22 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
}
else if (c == '\n')
{
- if (tc->ti.c_iflag & INLCR)
+ if (ti.c_iflag & INLCR)
c = '\r';
else
set_input_done (iscanon);
}
- if (tc->ti.c_iflag & ISTRIP)
+ if (ti.c_iflag & ISTRIP)
c &= 0x7f;
- if (tc->ti.c_lflag & ISIG)
+ if (ti.c_lflag & ISIG)
{
int sig;
- if (CCEQ (tc->ti.c_cc[VINTR], c))
+ if (CCEQ (ti.c_cc[VINTR], c))
sig = SIGINT;
- else if (CCEQ (tc->ti.c_cc[VQUIT], c))
+ else if (CCEQ (ti.c_cc[VQUIT], c))
sig = SIGQUIT;
- else if (CCEQ (tc->ti.c_cc[VSUSP], c))
+ else if (CCEQ (ti.c_cc[VSUSP], c))
sig = SIGTSTP;
else
goto not_a_sig;
@@ -238,14 +238,14 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
termios_printf ("got interrupt %d, sending signal %d", c, sig);
eat_readahead (-1);
tc->kill_pgrp (sig);
- tc->ti.c_lflag &= ~FLUSHO;
+ ti.c_lflag &= ~FLUSHO;
sawsig = true;
goto restart_output;
}
not_a_sig:
- if (tc->ti.c_iflag & IXON)
+ if (ti.c_iflag & IXON)
{
- if (CCEQ (tc->ti.c_cc[VSTOP], c))
+ if (CCEQ (ti.c_cc[VSTOP], c))
{
if (!tc->output_stopped)
{
@@ -254,30 +254,30 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
}
continue;
}
- else if (CCEQ (tc->ti.c_cc[VSTART], c))
+ else if (CCEQ (ti.c_cc[VSTART], c))
{
restart_output:
tc->output_stopped = 0;
release_output_mutex ();
continue;
}
- else if ((tc->ti.c_iflag & IXANY) && tc->output_stopped)
+ else if ((ti.c_iflag & IXANY) && tc->output_stopped)
goto restart_output;
}
- if (iscanon && tc->ti.c_lflag & IEXTEN && CCEQ (tc->ti.c_cc[VDISCARD], c))
+ if (iscanon && ti.c_lflag & IEXTEN && CCEQ (ti.c_cc[VDISCARD], c))
{
- tc->ti.c_lflag ^= FLUSHO;
+ ti.c_lflag ^= FLUSHO;
continue;
}
if (!iscanon)
/* nothing */;
- else if (CCEQ (tc->ti.c_cc[VERASE], c))
+ else if (CCEQ (ti.c_cc[VERASE], c))
{
if (eat_readahead (1))
echo_erase ();
continue;
}
- else if (CCEQ (tc->ti.c_cc[VWERASE], c))
+ else if (CCEQ (ti.c_cc[VWERASE], c))
{
int ch;
do
@@ -288,43 +288,43 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
while ((ch = peek_readahead (1)) >= 0 && !isspace (ch));
continue;
}
- else if (CCEQ (tc->ti.c_cc[VKILL], c))
+ else if (CCEQ (ti.c_cc[VKILL], c))
{
int nchars = eat_readahead (-1);
- if (tc->ti.c_lflag & ECHO)
+ if (ti.c_lflag & ECHO)
while (nchars--)
echo_erase (1);
continue;
}
- else if (CCEQ (tc->ti.c_cc[VREPRINT], c))
+ else if (CCEQ (ti.c_cc[VREPRINT], c))
{
- if (tc->ti.c_lflag & ECHO)
+ if (ti.c_lflag & ECHO)
{
doecho ("\n\r", 2);
doecho (rabuf, ralen);
}
continue;
}
- else if (CCEQ (tc->ti.c_cc[VEOF], c))
+ else if (CCEQ (ti.c_cc[VEOF], c))
{
termios_printf ("EOF");
(void) accept_input();
ret = line_edit_input_done;
continue;
}
- else if (CCEQ (tc->ti.c_cc[VEOL], c) ||
- CCEQ (tc->ti.c_cc[VEOL2], c) ||
+ else if (CCEQ (ti.c_cc[VEOL], c) ||
+ CCEQ (ti.c_cc[VEOL2], c) ||
c == '\n')
{
set_input_done (1);
termios_printf ("EOL");
}
- if (tc->ti.c_iflag & IUCLC && isupper (c))
+ if (ti.c_iflag & IUCLC && isupper (c))
c = cyg_tolower (c);
put_readahead (c);
- if (!iscanon || always_accept || input_done)
+ if (!iscanon || input_done)
{
int status = accept_input ();
if (status != 1)
@@ -336,11 +336,11 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
ret = line_edit_input_done;
input_done = 0;
}
- if (tc->ti.c_lflag & ECHO)
+ if (ti.c_lflag & ECHO)
doecho (&c, 1);
}
- if ((!iscanon || always_accept) && ralen > 0)
+ if (!iscanon && ralen > 0)
ret = line_edit_input_done;
if (sawsig)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index ef15f9f40..45afbcab1 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -198,8 +198,9 @@ process_input (void *)
while (1)
{
size_t nraw = INP_BUFFER_SIZE;
+ termios ti = tty_master->get_ttyp ()->ti;
tty_master->console->read ((void *) rawbuf, nraw);
- (void) tty_master->line_edit (rawbuf, nraw);
+ (void) tty_master->line_edit (rawbuf, nraw, ti);
}
}
@@ -1080,9 +1081,11 @@ fhandler_pty_master::write (const void *ptr, size_t len)
{
int i;
char *p = (char *) ptr;
- for (i=0; i < (int) len; i++)
+ termios ti = tc->ti;
+
+ for (i = 0; i < (int) len; i++)
{
- line_edit_status status = line_edit (p++, 1);
+ line_edit_status status = line_edit (p++, 1, ti);
if (status > line_edit_signalled)
{
if (status != line_edit_pipe_full)