]> code.ossystems Code Review - openembedded-core.git/blob
3a7e0fd9421b0b3584a29e956679807441f837e9
[openembedded-core.git] /
1 commit 62b263585bb5005d44a764c90d80f9c4bb8188c1
2 Author: Joe Peterson <joe@skyrush.com>
3 Date:   Wed Sep 9 15:03:47 2009 -0600
4
5     n_tty: move echoctl check and clean up logic
6     
7     Check L_ECHOCTL before insertting a character in the echo buffer
8     (rather than as the buffer is processed), to be more consistent with
9     when all other L_ flags are checked.  Also cleaned up the related logic.
10     
11     Note that this and the previous patch ("n_tty: honor opost flag for echoes")
12     were verified together by the reporters of the bug that patch addresses
13     (http://bugs.linuxbase.org/show_bug.cgi?id=2692), and the test now passes.
14     
15     Signed-off-by: Joe Peterson <joe@skyrush.com>
16     Cc: Linus Torvalds <torvalds@linux-foundation.org>
17     Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18
19 diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
20 index e6eeeb2..2e50f4d 100644
21 --- a/drivers/char/n_tty.c
22 +++ b/drivers/char/n_tty.c
23 @@ -576,33 +576,23 @@ static void process_echoes(struct tty_struct *tty)
24                                 break;
25  
26                         default:
27 -                               if (iscntrl(op)) {
28 -                                       if (L_ECHOCTL(tty)) {
29 -                                               /*
30 -                                                * Ensure there is enough space
31 -                                                * for the whole ctrl pair.
32 -                                                */
33 -                                               if (space < 2) {
34 -                                                       no_space_left = 1;
35 -                                                       break;
36 -                                               }
37 -                                               tty_put_char(tty, '^');
38 -                                               tty_put_char(tty, op ^ 0100);
39 -                                               tty->column += 2;
40 -                                               space -= 2;
41 -                                       } else {
42 -                                               if (!space) {
43 -                                                       no_space_left = 1;
44 -                                                       break;
45 -                                               }
46 -                                               tty_put_char(tty, op);
47 -                                               space--;
48 -                                       }
49 -                               }
50                                 /*
51 -                                * If above falls through, this was an
52 -                                * undefined op.
53 +                                * If the op is not a special byte code,
54 +                                * it is a ctrl char tagged to be echoed
55 +                                * as "^X" (where X is the letter
56 +                                * representing the control char).
57 +                                * Note that we must ensure there is
58 +                                * enough space for the whole ctrl pair.
59 +                                *
60                                  */
61 +                               if (space < 2) {
62 +                                       no_space_left = 1;
63 +                                       break;
64 +                               }
65 +                               tty_put_char(tty, '^');
66 +                               tty_put_char(tty, op ^ 0100);
67 +                               tty->column += 2;
68 +                               space -= 2;
69                                 cp += 2;
70                                 nr -= 2;
71                         }
72 @@ -809,8 +799,8 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
73   *     Echo user input back onto the screen. This must be called only when
74   *     L_ECHO(tty) is true. Called from the driver receive_buf path.
75   *
76 - *     This variant tags control characters to be possibly echoed as
77 - *     as "^X" (where X is the letter representing the control char).
78 + *     This variant tags control characters to be echoed as "^X"
79 + *     (where X is the letter representing the control char).
80   *
81   *     Locking: echo_lock to protect the echo buffer
82   */
83 @@ -823,7 +813,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
84                 add_echo_byte(ECHO_OP_START, tty);
85                 add_echo_byte(ECHO_OP_START, tty);
86         } else {
87 -               if (iscntrl(c) && c != '\t')
88 +               if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
89                         add_echo_byte(ECHO_OP_START, tty);
90                 add_echo_byte(c, tty);
91         }