summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-03-05 02:17:04 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-03-05 02:17:04 +0000
commit1536fb3ea57668f41c8c160288b3daeab2163639 (patch)
treee9b2ec8c65756107dda79b7cad91f3a8fade4fbe /term
parent7c66508fb414b4d9271e0772c67d4e6383d912e2 (diff)
2002-03-05 Marcus Brinkmann <marcus@gnu.org>
* main.c (main): Use memset instead bzero. Fix error message, and formatting of some comments. * ptyio.c (pty_io_read): Use memcpy instead bcopy. * users.c (S_tioctl_tiocflush): Ignore error by bottom handler's notice_input_flushed. * users.c (set_state): Likewise. If bottom handler's set_bits fails, don't adjust terminal state but return success anyway.
Diffstat (limited to 'term')
-rw-r--r--term/ChangeLog12
-rw-r--r--term/main.c14
-rw-r--r--term/ptyio.c2
-rw-r--r--term/users.c71
4 files changed, 54 insertions, 45 deletions
diff --git a/term/ChangeLog b/term/ChangeLog
index 5d38d198..1441a370 100644
--- a/term/ChangeLog
+++ b/term/ChangeLog
@@ -1,3 +1,15 @@
+2002-03-05 Marcus Brinkmann <marcus@gnu.org>
+
+ * main.c (main): Use memset instead bzero.
+ Fix error message, and formatting of some comments.
+ * ptyio.c (pty_io_read): Use memcpy instead bcopy.
+
+ * users.c (S_tioctl_tiocflush): Ignore error by bottom handler's
+ notice_input_flushed.
+ * users.c (set_state): Likewise.
+ If bottom handler's set_bits fails, don't adjust terminal state
+ but return success anyway.
+
2002-02-10 Marcus Brinkmann <marcus@gnu.org>
* term.h: Declare rdev.
diff --git a/term/main.c b/term/main.c
index e56ed73f..769a8114 100644
--- a/term/main.c
+++ b/term/main.c
@@ -1,4 +1,4 @@
-/*
+/* main.c - A translator that emulates a terminal.
Copyright (C) 1995, 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
@@ -84,8 +84,8 @@ parse_opt (int opt, char *arg, struct argp_state *state)
rdev = strtoul (start, &end, 0);
if (*end == ',')
- /* MAJOR,MINOR form */
{
+ /* MAJOR,MINOR form. */
start = end;
rdev = (rdev << 8) + strtoul (start, &end, 0);
}
@@ -206,7 +206,7 @@ main (int argc, char **argv)
default:
/* Should not happen. */
- fprintf (stderr, "Unknown terminal type is unknown.\n");
+ fprintf (stderr, "Unknown terminal type\n");
exit (1);
}
@@ -218,7 +218,7 @@ main (int argc, char **argv)
exit (1);
}
- /* Set our node */
+ /* Set our node. */
errno = trivfs_startup (bootstrap, 0,
ourcntlclass, term_bucket, ourclass, term_bucket,
ourcntl);
@@ -232,7 +232,7 @@ main (int argc, char **argv)
the hook to store the nodename. */
(*ourcntl)->hook = tty_name;
- /* Set peer */
+ /* Set peer. */
if (peerclass)
{
char *peer_name = tty_arg;
@@ -262,7 +262,7 @@ main (int argc, char **argv)
ports_port_deref (*peercntl);
}
- bzero (&termstate, sizeof (termstate));
+ memset (&termstate, 0, sizeof (termstate));
termflags = NO_CARRIER | NO_OWNER;
mutex_init (&global_lock);
@@ -301,7 +301,7 @@ main (int argc, char **argv)
condition_implies (inputq->wait, &select_alert);
condition_implies (outputq->wait, &select_alert);
- /* Launch */
+ /* Launch. */
ports_manage_port_operations_multithread (term_bucket, demuxer, 0, 0, 0);
return 0;
diff --git a/term/ptyio.c b/term/ptyio.c
index f2ff96e6..1bdb43d7 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -352,7 +352,7 @@ pty_io_read (struct trivfs_protid *cred,
{
**data = control_byte;
if (packet_mode && (control_byte & TIOCPKT_IOCTL))
- bcopy (&termstate, *data + 1, size - 1);
+ memcpy (*data + 1, &termstate, size - 1);
control_byte = 0;
}
else
diff --git a/term/users.c b/term/users.c
index 5597a522..cc3f4acc 100644
--- a/term/users.c
+++ b/term/users.c
@@ -47,10 +47,10 @@
#define TTYDEFCHARS
#include <sys/ttydefaults.h>
-/* Count of active opens */
+/* Count of active opens. */
int nperopens;
-/* io_async requests */
+/* io_async requests. */
struct async_req
{
mach_port_t notify;
@@ -74,7 +74,7 @@ static int input_sig_wakeup;
static error_t carrier_error;
-/* Attach this on the hook of any protid that is a ctty. */
+/* Attach this on the hook of any protid that is a ctty. */
struct protid_hook
{
int refcnt;
@@ -318,7 +318,7 @@ po_destroy_hook (struct trivfs_peropen *po)
void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *)
= po_destroy_hook;
-/* Tell if CRED can do foreground terminal operations */
+/* Tell if CRED can do foreground terminal operations. */
static inline int
fg_p (struct trivfs_protid *cred)
{
@@ -347,7 +347,7 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st)
st->st_gid = term_group;
}
-/* Implement term_getctty as described in <hurd/term.defs>. */
+/* Implement term_getctty as described in <hurd/term.defs>. */
kern_return_t
S_term_getctty (mach_port_t arg,
mach_port_t *id,
@@ -375,7 +375,7 @@ S_term_getctty (mach_port_t arg,
return err;
}
-/* Implement termctty_open_terminal as described in <hurd/term.defs>. */
+/* Implement termctty_open_terminal as described in <hurd/term.defs>. */
kern_return_t
S_termctty_open_terminal (mach_port_t arg,
int flags,
@@ -412,7 +412,7 @@ S_termctty_open_terminal (mach_port_t arg,
return err;
}
-/* Implement term_become_ctty as described in <hurd/term.defs>. */
+/* Implement term_become_ctty as described in <hurd/term.defs>. */
kern_return_t
S_term_open_ctty (mach_port_t arg,
pid_t pid,
@@ -448,7 +448,7 @@ S_term_open_ctty (mach_port_t arg,
hook->refcnt = 1;
if (newcred->hook)
- /* We inherited CRED's hook, get rid of our ref to it. */
+ /* We inherited CRED's hook, get rid of our ref to it. */
pi_destroy_hook (newcred);
newcred->hook = hook;
@@ -465,7 +465,7 @@ S_term_open_ctty (mach_port_t arg,
}
/* Implement chown locally; don't pass the value down to the
- underlying node. */
+ underlying node. */
error_t
trivfs_S_file_chown (struct trivfs_protid *cred,
mach_port_t reply,
@@ -511,7 +511,7 @@ out:
return err;
}
-/* Implement chmod locally */
+/* Implement chmod locally. */
error_t
trivfs_S_file_chmod (struct trivfs_protid *cred,
mach_port_t reply,
@@ -553,8 +553,8 @@ out:
}
-/* Called for user writes to the terminal as described
- in <hurd/io.defs>. */
+/* Called for user writes to the terminal as described in
+ <hurd/io.defs>. */
error_t
trivfs_S_io_write (struct trivfs_protid *cred,
mach_port_t reply,
@@ -631,7 +631,7 @@ trivfs_S_io_write (struct trivfs_protid *cred,
return ((cancel && datalen && !*amt) ? (err ?: EINTR) : 0);
}
-/* Called for user reads from the terminal. */
+/* Called for user reads from the terminal. */
error_t
trivfs_S_io_read (struct trivfs_protid *cred,
mach_port_t reply,
@@ -749,7 +749,7 @@ trivfs_S_io_read (struct trivfs_protid *cred,
{
/* The CANCEL flag is being used here to tell the return
below to make sure we don't signal EOF on a VDUSP that
- happens at the front of a line. */
+ happens at the front of a line. */
send_signal (SIGTSTP);
cancel = 1;
break;
@@ -762,7 +762,7 @@ trivfs_S_io_read (struct trivfs_protid *cred,
*datalen = cp - *data;
- /* If we really read something, set atime */
+ /* If we really read something, set atime. */
if (*datalen || !cancel)
trivfs_set_atime (termctl);
@@ -1036,9 +1036,8 @@ S_tioctl_tiocflush (io_t port,
if (flags & O_READ)
{
- err = (*bottom->notice_input_flushed) ();
- if (!err)
- clear_queue (inputq);
+ (*bottom->notice_input_flushed) ();
+ clear_queue (inputq);
}
if (!err && (flags & O_WRITE))
@@ -1094,7 +1093,6 @@ set_state (io_t port,
{
struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- int oldlflag;
struct termios state;
if (!cred)
@@ -1110,7 +1108,7 @@ set_state (io_t port,
mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
- err = EBADF;
+ err = EBADF;
else if (!fg_p (cred))
err = EBACKGROUND;
else
@@ -1132,9 +1130,7 @@ set_state (io_t port,
if (flushi)
{
- err = (*bottom->notice_input_flushed) ();
- if (err)
- goto leave;
+ (*bottom->notice_input_flushed) ();
clear_queue (inputq);
}
@@ -1153,22 +1149,23 @@ set_state (io_t port,
state.c_lflag &= ~EXTPROC;
err = (*bottom->set_bits) (&state);
- if (err)
- goto leave;
-
- oldlflag = termstate.c_lflag;
- termstate = state;
-
- if (oldlflag & ICANON)
- {
- if (!(termstate.c_lflag & ICANON))
- copy_rawq ();
- }
- else
+ if (!err)
{
- if (termstate.c_lflag & ICANON)
- rescan_inputq ();
+ int oldlflag = termstate.c_lflag;
+
+ termstate = state;
+ if (oldlflag & ICANON)
+ {
+ if (!(termstate.c_lflag & ICANON))
+ copy_rawq ();
+ }
+ else
+ {
+ if (termstate.c_lflag & ICANON)
+ rescan_inputq ();
+ }
}
+ err = 0;
}
leave: