Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a59c0d6f authored by Joe Peterson's avatar Joe Peterson Committed by Linus Torvalds
Browse files

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: default avatarJoe Peterson <joe@skyrush.com>
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fc6f6238
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -351,10 +351,12 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
			tty->column--;
		break;
	default:
		if (!iscntrl(c)) {
			if (O_OLCUC(tty))
				c = toupper(c);
		if (!iscntrl(c) && !is_continuation(c, tty))
			if (!is_continuation(c, tty))
				tty->column++;
		}
		break;
	}

@@ -425,7 +427,9 @@ static ssize_t process_output_block(struct tty_struct *tty,
		nr = space;

	for (i = 0, cp = buf; i < nr; i++, cp++) {
		switch (*cp) {
		unsigned char c = *cp;

		switch (c) {
		case '\n':
			if (O_ONLRET(tty))
				tty->column = 0;
@@ -447,10 +451,12 @@ static ssize_t process_output_block(struct tty_struct *tty,
				tty->column--;
			break;
		default:
			if (!iscntrl(c)) {
				if (O_OLCUC(tty))
					goto break_out;
			if (!iscntrl(*cp))
				if (!is_continuation(c, tty))
					tty->column++;
			}
			break;
		}
	}