aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-12-05 16:24:52 +0000
committerChristopher Faylor <me@cgf.cx>2002-12-05 16:24:52 +0000
commit49dd6fc61e991a533ae3f1167d48bb07b3391311 (patch)
treeadd58e9624eafa48ed31834cdfade456a4e0550f
parent94d815b251f6e5743f629aea73406fd9937feca3 (diff)
downloadnewlib-49dd6fc61e991a533ae3f1167d48bb07b3391311.zip
newlib-49dd6fc61e991a533ae3f1167d48bb07b3391311.tar.gz
newlib-49dd6fc61e991a533ae3f1167d48bb07b3391311.tar.bz2
* fhandler.h (fhandler_termios::line_edit): Change return from an int to an
enum to allow the function to return an error. * fhandler_console.cc (fhandler_console::read): Update the line_edit call to use the new enum. * fhandler_termios.cc (fhandler_termios::line_edit): Change return from an int to an enum to allow the function to return an error. Put put_readahead call before doecho for future patch. * fhandler_tty.cc (fhandler_pty_master::write): Change to call line_edit one character at a time, and stop if an error occurs.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/fhandler.h10
-rw-r--r--winsup/cygwin/fhandler_console.cc6
-rw-r--r--winsup/cygwin/fhandler_termios.cc14
-rw-r--r--winsup/cygwin/fhandler_tty.cc10
5 files changed, 40 insertions, 12 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 8b5b145..b09b90d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,15 @@
+2002-12-04 Steve Osborn <bub@io.com>
+
+ * fhandler.h (fhandler_termios::line_edit): Change return from an int
+ to an enum to allow the function to return an error.
+ * fhandler_console.cc (fhandler_console::read): Update the line_edit
+ call to use the new enum.
+ * fhandler_termios.cc (fhandler_termios::line_edit): Change return from
+ an int to an enum to allow the function to return an error. Put
+ put_readahead call before doecho for future patch.
+ * fhandler_tty.cc (fhandler_pty_master::write): Change to call
+ line_edit one character at a time, and stop if an error occurs.
+
2002-12-04 Craig McGeachie <slapdau@yahoo.com.au>
* netdb.cc: New file.
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 0e42670..3dcc8b6 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -118,6 +118,14 @@ typedef struct __DIR DIR;
struct dirent;
struct iovec;
+enum line_edit_status
+{
+ line_edit_signalled = -1,
+ line_edit_ok = 0,
+ line_edit_input_done = 1,
+ line_edit_error = 2
+};
+
enum bg_check_types
{
bg_error = -1,
@@ -693,7 +701,7 @@ class fhandler_termios: public fhandler_base
set_need_fork_fixup ();
}
HANDLE& get_output_handle () { return output_handle; }
- int line_edit (const char *rptr, int nread, int always_accept = 0);
+ line_edit_status line_edit (const char *rptr, int nread, int always_accept = 0);
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 70e7199..a7b13c6 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -457,10 +457,10 @@ fhandler_console::read (void *pv, size_t buflen)
if (toadd)
{
- int res = line_edit (toadd, nread);
- if (res < 0)
+ line_edit_status res = line_edit (toadd, nread);
+ if (res == line_edit_signalled)
goto sig_exit;
- else if (res)
+ else if (res == line_edit_input_done)
break;
}
#undef ich
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index cfdb157..6fa5cf9 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -186,9 +186,10 @@ fhandler_termios::echo_erase (int force)
doecho ("\b \b", 3);
}
-int
+line_edit_status
fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
{
+ line_edit_status ret = line_edit_ok;
char c;
int input_done = 0;
bool sawsig = FALSE;
@@ -321,20 +322,23 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
if (tc->ti.c_iflag & IUCLC && isupper (c))
c = cyg_tolower (c);
+ put_readahead (c);
if (tc->ti.c_lflag & ECHO)
doecho (&c, 1);
- put_readahead (c);
}
if (!iscanon || always_accept)
set_input_done (ralen > 0);
if (sawsig)
- input_done = -1;
+ ret = line_edit_signalled;
else if (input_done)
- (void) accept_input ();
+ {
+ ret = line_edit_input_done;
+ (void) accept_input ();
+ }
- return input_done;
+ return ret;
}
void
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index dc0f0fc..3b47f56 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -167,7 +167,7 @@ fhandler_pty_master::accept_input ()
get_ttyp ()->read_retval = -1;
break;
}
- else
+ else
get_ttyp ()->read_retval = 1;
p += written;
@@ -1077,8 +1077,12 @@ fhandler_pty_master::close ()
int
fhandler_pty_master::write (const void *ptr, size_t len)
{
- (void) line_edit ((char *) ptr, len);
- return len;
+ size_t i;
+ char *p = (char *) ptr;
+ for (i=0; i<len; i++)
+ if (line_edit (p++, 1) == line_edit_error)
+ break;
+ return i;
}
int __stdcall