提交 a59c0d6f 编写于 作者: J Joe Peterson 提交者: Linus Torvalds

n_tty: Fix handling of control characters and continuations

Fix process_output_block to detect continuation characters correctly
and to handle control characters even when O_OLCUC is enabled.  Make
similar change to do_output_char().
Signed-off-by: NJoe Peterson <joe@skyrush.com>
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 fc6f6238
...@@ -351,10 +351,12 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space) ...@@ -351,10 +351,12 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
tty->column--; tty->column--;
break; break;
default: default:
if (O_OLCUC(tty)) if (!iscntrl(c)) {
c = toupper(c); if (O_OLCUC(tty))
if (!iscntrl(c) && !is_continuation(c, tty)) c = toupper(c);
tty->column++; if (!is_continuation(c, tty))
tty->column++;
}
break; break;
} }
...@@ -425,7 +427,9 @@ static ssize_t process_output_block(struct tty_struct *tty, ...@@ -425,7 +427,9 @@ static ssize_t process_output_block(struct tty_struct *tty,
nr = space; nr = space;
for (i = 0, cp = buf; i < nr; i++, cp++) { for (i = 0, cp = buf; i < nr; i++, cp++) {
switch (*cp) { unsigned char c = *cp;
switch (c) {
case '\n': case '\n':
if (O_ONLRET(tty)) if (O_ONLRET(tty))
tty->column = 0; tty->column = 0;
...@@ -447,10 +451,12 @@ static ssize_t process_output_block(struct tty_struct *tty, ...@@ -447,10 +451,12 @@ static ssize_t process_output_block(struct tty_struct *tty,
tty->column--; tty->column--;
break; break;
default: default:
if (O_OLCUC(tty)) if (!iscntrl(c)) {
goto break_out; if (O_OLCUC(tty))
if (!iscntrl(*cp)) goto break_out;
tty->column++; if (!is_continuation(c, tty))
tty->column++;
}
break; break;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册