aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBojan Novković <bojan.novkovic@fer.hr>2023-10-07 17:59:57 +0000
committerChristos Margiolis <christos@FreeBSD.org>2023-10-21 14:28:34 +0000
commitb53fe14843ab1d5fc73d3e0ae2b14c182c6ee577 (patch)
treeb1a256b66dc3e69a406511cf3172aa7b82ccc5d6 /bin
parent4533fa42ad912537a15d72068f2cfca46a465521 (diff)
downloadsrc-b53fe14843ab1d5fc73d3e0ae2b14c182c6ee577.tar.gz
src-b53fe14843ab1d5fc73d3e0ae2b14c182c6ee577.zip
(s)tty: add support for IUTF8 input flag
This patch adds the necessary kernel and stty code to support setting the IUTF8 flag for ttys. It is the first of two patches that fix backspace behaviour for UTF-8 encoded characters when in canonical mode. Reported by: christos Reviewed by: christos, imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42066 (cherry picked from commit 128f63cedc14ae21b35f74e11e2fe1a5659c58e8)
Diffstat (limited to 'bin')
-rw-r--r--bin/stty/modes.c2
-rw-r--r--bin/stty/print.c1
-rw-r--r--bin/stty/stty.13
3 files changed, 6 insertions, 0 deletions
diff --git a/bin/stty/modes.c b/bin/stty/modes.c
index ce39083d7d63..3818677ddc4e 100644
--- a/bin/stty/modes.c
+++ b/bin/stty/modes.c
@@ -126,6 +126,8 @@ static const struct modes imodes[] = {
{ "-decctlq", IXANY, 0 },
{ "imaxbel", IMAXBEL, 0 },
{ "-imaxbel", 0, IMAXBEL },
+ { "iutf8", IUTF8, 0 },
+ { "-iutf8", 0, IUTF8 },
{ NULL, 0, 0 },
};
diff --git a/bin/stty/print.c b/bin/stty/print.c
index 07a3c2058474..33472bbccea1 100644
--- a/bin/stty/print.c
+++ b/bin/stty/print.c
@@ -127,6 +127,7 @@ print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
put("-inpck", INPCK, 0);
put("-ignpar", IGNPAR, 0);
put("-parmrk", PARMRK, 0);
+ put("-iutf8", IUTF8, 1);
/* output flags */
tmp = tp->c_oflag;
diff --git a/bin/stty/stty.1 b/bin/stty/stty.1
index 9e9405928c67..c572a657a997 100644
--- a/bin/stty/stty.1
+++ b/bin/stty/stty.1
@@ -224,6 +224,9 @@ if
.Cm imaxbel
is unset and the input queue is full, the next input character causes
the entire input and output queues to be discarded.
+.It Cm iutf8 Pq Fl iutf8
+Assume that input characters are UTF-8 encoded. Setting this flag
+causes backspace to properly delete multibyte characters in canonical mode.
.El
.Ss Output Modes:
This corresponds to the c_oflag of the termios structure.