aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/n_tty.c
diff options
context:
space:
mode:
authorJoe Peterson <joe@skyrush.com>2009-09-09 17:03:47 -0400
committerLive-CD User <linux@linux.site>2009-09-19 16:13:34 -0400
commit62b263585bb5005d44a764c90d80f9c4bb8188c1 (patch)
tree18c71c8f09672ac097da5ea5a87e1c40a42e95b7 /drivers/char/n_tty.c
parentee5aa7b8b98774f408d20a2f61f97a89ac66c29b (diff)
n_tty: move echoctl check and clean up logic
Check L_ECHOCTL before insertting a character in the echo buffer (rather than as the buffer is processed), to be more consistent with when all other L_ flags are checked. Also cleaned up the related logic. Note that this and the previous patch ("n_tty: honor opost flag for echoes") were verified together by the reporters of the bug that patch addresses (http://bugs.linuxbase.org/show_bug.cgi?id=2692), and the test now passes. Signed-off-by: Joe Peterson <joe@skyrush.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/n_tty.c')
-rw-r--r--drivers/char/n_tty.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index e6eeeb234e5d..2e50f4dfc79c 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -576,33 +576,23 @@ static void process_echoes(struct tty_struct *tty)
576 break; 576 break;
577 577
578 default: 578 default:
579 if (iscntrl(op)) {
580 if (L_ECHOCTL(tty)) {
581 /*
582 * Ensure there is enough space
583 * for the whole ctrl pair.
584 */
585 if (space < 2) {
586 no_space_left = 1;
587 break;
588 }
589 tty_put_char(tty, '^');
590 tty_put_char(tty, op ^ 0100);
591 tty->column += 2;
592 space -= 2;
593 } else {
594 if (!space) {
595 no_space_left = 1;
596 break;
597 }
598 tty_put_char(tty, op);
599 space--;
600 }
601 }
602 /* 579 /*
603 * If above falls through, this was an 580 * If the op is not a special byte code,
604 * undefined op. 581 * it is a ctrl char tagged to be echoed
582 * as "^X" (where X is the letter
583 * representing the control char).
584 * Note that we must ensure there is
585 * enough space for the whole ctrl pair.
586 *
605 */ 587 */
588 if (space < 2) {
589 no_space_left = 1;
590 break;
591 }
592 tty_put_char(tty, '^');
593 tty_put_char(tty, op ^ 0100);
594 tty->column += 2;
595 space -= 2;
606 cp += 2; 596 cp += 2;
607 nr -= 2; 597 nr -= 2;
608 } 598 }
@@ -809,8 +799,8 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
809 * Echo user input back onto the screen. This must be called only when 799 * Echo user input back onto the screen. This must be called only when
810 * L_ECHO(tty) is true. Called from the driver receive_buf path. 800 * L_ECHO(tty) is true. Called from the driver receive_buf path.
811 * 801 *
812 * This variant tags control characters to be possibly echoed as 802 * This variant tags control characters to be echoed as "^X"
813 * as "^X" (where X is the letter representing the control char). 803 * (where X is the letter representing the control char).
814 * 804 *
815 * Locking: echo_lock to protect the echo buffer 805 * Locking: echo_lock to protect the echo buffer
816 */ 806 */
@@ -823,7 +813,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
823 add_echo_byte(ECHO_OP_START, tty); 813 add_echo_byte(ECHO_OP_START, tty);
824 add_echo_byte(ECHO_OP_START, tty); 814 add_echo_byte(ECHO_OP_START, tty);
825 } else { 815 } else {
826 if (iscntrl(c) && c != '\t') 816 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
827 add_echo_byte(ECHO_OP_START, tty); 817 add_echo_byte(ECHO_OP_START, tty);
828 add_echo_byte(c, tty); 818 add_echo_byte(c, tty);
829 } 819 }