From nobody Sat Oct 21 14:29:32 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SCP3c6jrRz4y5Bj; Sat, 21 Oct 2023 14:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SCP3c696pz4Fh6; Sat, 21 Oct 2023 14:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697898572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YXxJhCBb07vbsMUV2yeJ13miKTDoMTYaECKz8PBdPXo=; b=mN+po/d97YxEoqzXSfVGNJ6sNwYlqMoL5K2HdImK3n7OeJoPvEbOjOz7mn2eCt2gmD6E9N oElaXx7Iy8GXCn7eFGA+xMC2oD01eWUoisFahXjFlbnrFZhDo+oPs5rll3AHAQhxNLuoxV xlsNLO3JVlhwZrnpmBP6Gl+f4fn5h3d7Wufg+yvD35N8o+e235NgHOXqBAqYBWGNic9EQG xTPkWNsNBWpgfwEXLc4lRTPhkfbj0vNGZICoa1T2Ds3XdnZ0RR7w56sWIIrRQnn/ZxATaX RRbjLVNJFQErkhu5Q3qz+J04Deu2G0j7Q17ep140VPPV+thY/PFc55rSzHwaiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697898572; a=rsa-sha256; cv=none; b=da/ClmvQTx/ueIIQzqRe5nQyheeqdSxUZaB1m8/x7+exeAl0kzdEt3jFts1zp722tGgq2o NaDqzc89WA2Nhasq59tJFj71vo5LyMeCb7F0zmef7PBnqW1Pw2c4g3WHH4wamuqWXQhSG2 euDScakMx6T244Q9FPvz+yWI+CNK1legqIZ9jzv86nKQpD7UxTqDKAMYVlasEmT4Ey/oJG PzD5PaGoI0J76ykpVorKyuaKDSfc9RUDh2WDLIxYNUT8H6/Iutv1EgQRlKNbKCoFPuGr3a XY5rNZ5mFTk5ZjzSzPeoFDi2qCUobfjGqehmiBZR1XppJKwhihtd4lY2VMv6kQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697898572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YXxJhCBb07vbsMUV2yeJ13miKTDoMTYaECKz8PBdPXo=; b=WCnrn8iucxRGu57wQBe0ja2B58bCuHecGwPwgxcjqjVx4Dsc2TILp+icRSdo4mj/DXQD8C dgaAqKmc5GY5RoQ8/hptIDUyJzGlGuqSgzh82OUX/31x41+2KF2nvcoakc89OZdhH8XLMz RLU+6S4SjC3xwdTvo5UyF7PNuMAj7f4/+jXLX2okSlKhn1870qrtSRF9c90/f/aYEfzxoL qJMHj9coHNm7sLGes/AOKsxBlBl9pGz6Dt/g6mFxY5UNms2ZQ7lEiaIvqpEAnEO4C7AshW bBad5d3A5Nl7achHUu/JC4VFCSweMX8DB2tspeJS8B3zqu5XfWTz9KPbrwe6jg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SCP3c5DX4z4BW; Sat, 21 Oct 2023 14:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39LETWEB071509; Sat, 21 Oct 2023 14:29:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39LETWb2071506; Sat, 21 Oct 2023 14:29:32 GMT (envelope-from git) Date: Sat, 21 Oct 2023 14:29:32 GMT Message-Id: <202310211429.39LETWb2071506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: b53fe14843ab - stable/14 - (s)tty: add support for IUTF8 input flag List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b53fe14843ab1d5fc73d3e0ae2b14c182c6ee577 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b53fe14843ab1d5fc73d3e0ae2b14c182c6ee577 commit b53fe14843ab1d5fc73d3e0ae2b14c182c6ee577 Author: Bojan Novković AuthorDate: 2023-10-07 17:59:57 +0000 Commit: Christos Margiolis CommitDate: 2023-10-21 14:28:34 +0000 (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) --- bin/stty/modes.c | 2 ++ bin/stty/print.c | 1 + bin/stty/stty.1 | 3 +++ share/man/man4/termios.4 | 2 ++ sys/kern/tty.c | 4 ++-- sys/sys/_termios.h | 1 + 6 files changed, 11 insertions(+), 2 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. diff --git a/share/man/man4/termios.4 b/share/man/man4/termios.4 index d3a5c8fa582d..80015025345e 100644 --- a/share/man/man4/termios.4 +++ b/share/man/man4/termios.4 @@ -884,6 +884,8 @@ following masks: /* any char will restart after stop */ .It Dv IMAXBEL /* ring bell on input queue full */ +.It Dv IUTF8 +/* assume input is UTF-8 encoded */ .El .Pp In the context of asynchronous serial data transmission, a break diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 134c1dfba98b..620233947410 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -85,8 +85,8 @@ static const char *dev_console_filename; /* * Flags that are supported and stored by this implementation. */ -#define TTYSUP_IFLAG (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|\ - INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL) +#define TTYSUP_IFLAG (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|\ + IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL|IUTF8) #define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) #define TTYSUP_LFLAG (ECHOKE|ECHOE|ECHOK|ECHO|ECHONL|ECHOPRT|\ ECHOCTL|ISIG|ICANON|ALTWERASE|IEXTEN|TOSTOP|\ diff --git a/sys/sys/_termios.h b/sys/sys/_termios.h index 327ffcb2f98b..823752732ee2 100644 --- a/sys/sys/_termios.h +++ b/sys/sys/_termios.h @@ -97,6 +97,7 @@ #endif #if __BSD_VISIBLE #define IMAXBEL 0x00002000 /* ring bell on input queue full */ +#define IUTF8 0x00004000 /* assume input is utf-8 encoded */ #endif /*