aboutsummaryrefslogtreecommitdiff
path: root/term/munge.c
diff options
context:
space:
mode:
Diffstat (limited to 'term/munge.c')
-rw-r--r--term/munge.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/term/munge.c b/term/munge.c
index 03ea9106..660a99bd 100644
--- a/term/munge.c
+++ b/term/munge.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1999, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -49,7 +49,11 @@ poutput (int c)
else if (c == '\r')
output_psize = 0;
else if (c == '\t')
- output_psize += (output_psize + 8) % 8;
+ {
+ output_psize++;
+ while (output_psize % 8)
+ output_psize++;
+ }
else if (c == '\b')
output_psize--;
@@ -131,7 +135,7 @@ output_width (int c, int loc)
int n = loc + 1;
while (n % 8)
n++;
- return n;
+ return n - loc;
}
if ((c >= ' ') && (c < '\177'))
return 1;
@@ -229,7 +233,7 @@ echo_char (char c, int hderase, int quoted)
if (echo_double (c, quoted))
{
output_character ('^');
- output_character (c + ('A' - CHAR_SOH));
+ output_character (c ^ CTRL_BIT);
}
else
output_character (c);
@@ -401,8 +405,10 @@ input_character (int c)
else
{
drop_output ();
+ poutput (cc[VDISCARD]);
termflags |= FLUSH_OUTPUT;
}
+ goto alldone;
}
}
@@ -446,13 +452,13 @@ input_character (int c)
{
if (CCEQ (cc[VSTOP], c))
{
- termflags |= USER_OUTPUT_SUSP;
- (*bottom->suspend_physical_output) ();
-
- if (!(CCEQ(cc[VSTART], c))) /* toggle if VSTART == VSTOP */
- /* Alldone code always turns off USER_OUTPUT_SUSP. */
+ if (CCEQ(cc[VSTART], c) && (termflags & USER_OUTPUT_SUSP))
+ /* Toggle if VSTART == VSTOP. Alldone code always turns
+ off USER_OUTPUT_SUSP. */
goto alldone;
+ termflags |= USER_OUTPUT_SUSP;
+ (*bottom->suspend_physical_output) ();
return flush;
}
if (CCEQ (cc[VSTART], c))
@@ -576,7 +582,7 @@ input_character (int c)
echo_char (c, 0, 0);
if (CCEQ (cc[VEOF], c) && (lflag & ECHO))
{
- /* Special bizzare echo processing for VEOF character. */
+ /* Special bizarre echo processing for VEOF character. */
int n;
n = echo_double (c, 0) ? 2 : output_width (c, output_psize);
while (n--)
@@ -636,7 +642,7 @@ input_break ()
enqueue_quote (qp, '\0');
}
-/* Called when a character is recived with a framing error. */
+/* Called when a character is received with a framing error. */
void
input_framing_error (int c)
{
@@ -675,20 +681,24 @@ rescan_inputq ()
n = qsize (inputq);
buf = alloca (n * sizeof (quoted_char));
- bcopy (inputq->cs, buf, n * sizeof (quoted_char));
+ memcpy (buf, inputq->cs, n * sizeof (quoted_char));
clear_queue (inputq);
for (i = 0; i < n; i++)
input_character (unquote_char (buf[i]));
}
-void
+
+error_t
drop_output ()
{
- clear_queue (outputq);
- (*bottom->abandon_physical_output) ();
+ error_t err = (*bottom->abandon_physical_output) ();
+ if (!err)
+ clear_queue (outputq);
+ return err;
}
+
error_t
drain_output ()
{
@@ -709,12 +719,16 @@ create_queue (int size, int lowat, int hiwat)
struct queue *q;
q = malloc (sizeof (struct queue) + size * sizeof (quoted_char));
+ assert (q);
+
q->susp = 0;
q->lowat = lowat;
q->hiwat = hiwat;
q->cs = q->ce = q->array;
q->arraylen = size;
q->wait = malloc (sizeof (struct condition));
+ assert (q->wait);
+
condition_init (q->wait);
return q;
}