From nobody Sun Oct 22 11:57:34 2023 X-Original-To: dev-commits-src-all@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 4SCxdq0R8Dz4xC3D; Sun, 22 Oct 2023 11:57:35 +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 4SCxdp6t1Wz3W0F; Sun, 22 Oct 2023 11:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697975855; 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=8uie+XyN6+B7Hu+qYlXV3K54/Iq5enmU6I/S/O/OYIs=; b=Z1D6wCllzSsyeK8L94jYkZ2RVMU/Q4C+KxR9JDqCLqxk0L77BcS4g+4Ys/25rpoXi+Pey5 uAuIryVziwuHuZCzaEMVDLhDc3bE5eIBCeyXY2c7WZaxz5CAsF2AIJVJbbbqQZDh2kMUQ6 JoacNTf/uKWzNImN4DZf8zhxR80Avpc1RXFXrlUw0tVog4JSO4lFuEafEeV9/3D3RK7MlV umn2WtdzLWaPxwYmD+DDXrJf9kOn4yaOH5g1AMrRwROhmARNdN/dRd6d4Y/oXm71PLg6Ip iJDthAlWrQkhPhH7Bh4gX6942UYpwxybXKqRejl6EZjaujKjG7InpW34eIA2lw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697975855; a=rsa-sha256; cv=none; b=Ncr4oZyD9BWz+F4Aj7DtEmWV+Wf3/3y+SVfVKKhO1q/yPYmG4b0gKg1Ry8rejLmHmj3MZL F9eBUOuAUb/ZRDgRM9Glf+iSqHVYZrhXa73QN8K4rP6RdBC0YvHdkNaA/yTvH1fa8sTAbV 8ZxRNhM0bis+b0g2b4oQyftVy0Fr3llw91DnhJenFNwsnOXTijPUGgC1uF6ql6f8F6PJZl SDWWlo8ifGz3C0ndtBvcHQFG1cZA8wtl2fOqcS/jZ+y7mi+yFul+rbB0h7+RJ5aGpO4rqp LksTEfFhkBBlEe2/whrK4vyJumgl/goWXi+xsWy2vRRd910GtTajI2DO7U2nXg== 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=1697975855; 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=8uie+XyN6+B7Hu+qYlXV3K54/Iq5enmU6I/S/O/OYIs=; b=RndUlYecj2aRcu5zHDswTJcAmgBQmzwDJDOG0U1V3DtrupJzz2PiWq2+dIoloNTs6vKmTK BiIEak1A7oFJfFUYTGs9PjVpoKU3DIehhlDYBS9lGvpa9t0AE89Ahj+7n8K2jv0/ZxeXVE IcoEqb3kehqzNd96F+PZbZtI/COS5h6/l39aXiuefkX4lZEhSw+yg/R7lMO17f9lOsD7HK pGz2MT7xCgyHMeOt6I5I68FPSGQh+a3DOAtZuNqGHqBS4Axz+z/0yIwtKsqFHC5u4Q6NW1 JRN7GYX7IvlxSMq1LFuA9dzHsEDHu2LdG8kpxF0TJLHXc1Ez6CaIzEhuFltXcA== 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 4SCxdp5wl1zx0T; Sun, 22 Oct 2023 11:57:34 +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 39MBvYmh015185; Sun, 22 Oct 2023 11:57:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39MBvYw6015182; Sun, 22 Oct 2023 11:57:34 GMT (envelope-from git) Date: Sun, 22 Oct 2023 11:57:34 GMT Message-Id: <202310221157.39MBvYw6015182@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: ad8c7f909e33 - releng/14.0 - (s)tty: add support for IUTF8 input flag List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: ad8c7f909e3315a31f654ab7dca75840a4561cb0 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=ad8c7f909e3315a31f654ab7dca75840a4561cb0 commit ad8c7f909e3315a31f654ab7dca75840a4561cb0 Author: Bojan Novković AuthorDate: 2023-10-07 17:59:57 +0000 Commit: Christos Margiolis CommitDate: 2023-10-22 11:56:32 +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) Approved by: re (gjb) --- 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 /*