From nobody Thu Sep 7 14:51:00 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 4RhMch4268z4snX1; Thu, 7 Sep 2023 14:51:00 +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 4RhMch3Syyz4kNY; Thu, 7 Sep 2023 14:51:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694098260; 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=3PoWO8JC7Yr7iHssORAzlYI6AUoUS61wgY+Xxde/XF0=; b=OaizkoYyjtXurUA0SRmsMvSin+csWi1sYWatjie2O2MLyvgF6p75txEhvp6pIcRw+tIRIS GS96Gdtjv13Trcx9mgpx4ff3b/YOEQgDrNXtgGpXp9ehrFoc8fjCMcDqXfdVbTSV2/J4sR Q4Rro0jS2jpf+zxyY5f1yQNbJwXk5lg8Fyt0dwKm26+y4mcw87cYS2I/HzumPpWGt11+Yv W8461UWw0z776bKW1styJcwto9SJBVa+rz6pnMJ+/ypSrIdJD8nxXyiBM2XGETZoFXsCPl +bQRdc7uhq2+X5ZBIDq0iIcPU+oxE+Xq+TxrrHPPWM9b3JalAl+HpDieal1tqQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694098260; a=rsa-sha256; cv=none; b=cQ9j9+9Q1hn1QwyUjPO9yvi//AV5pP/0CQ82EDqRVPOa3FIZJoMvXjOfJlkyIwBjE8D+XQ YKa1uqDnLE56yJEmzanXvVzVj6ubtgzj886ZoRLRsSD5aObVJQxzOckbRFIhV5ScPTmJMH J/xCm5tLqE7uFkjA1xuFfScIpinmwATE3+RiU4VG3w5MINpGjpcbkbyNdhHOACWisFK5Rb ajVODmwj0odwQxoReNZa4QEpxHJDf4NJGYuuMSH8LOdA6sCLI8LnuCgN0rK7D08HDK66i+ AHLCrzuLzHSxoTf63ZvPynFjGeJs7xcAdfQI3Uxipx6x8Wo+JgObbLrtIArYrw== 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=1694098260; 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=3PoWO8JC7Yr7iHssORAzlYI6AUoUS61wgY+Xxde/XF0=; b=OElytRkZ2M6AdhMMMaeau6ePnGs8kQ5G+e9ZAG9GUP/MGLwpkKgzrLIJxKAXmUXg5Idvre hBfgJwQaAiw3T1Ptbp6Md7WfqDGyO3ETtLzibmewbtV5gzRJtuVjWEnCYOwRF08pfcp0YB rP+AtmDMrGKOfzblA10sNlDm/ljszoy33uPU8lQeANbJjZJ6sDx79q7ZETg/FdMbbWd6XW rZZBl846zAMYHc4wuSwGNfj1KI2QKWwyaBJESzEfZfk4pPR3bcPtuz/bjQ56uMqj4tFHj+ Mhyyo4n6MZ8MEbKX1Hdcb9VZOnfRHJfeik2eL9SaHYSUtRfYZj0pTMv2p66zmg== 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 4RhMch2LSxz13JT; Thu, 7 Sep 2023 14:51:00 +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 387Ep0IL010342; Thu, 7 Sep 2023 14:51:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 387Ep0Qf010339; Thu, 7 Sep 2023 14:51:00 GMT (envelope-from git) Date: Thu, 7 Sep 2023 14:51:00 GMT Message-Id: <202309071451.387Ep0Qf010339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: e441e0cf8ec9 - stable/13 - indent: Restore and document -ps / -nps option. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e441e0cf8ec93e009249d0c978bee110797f313d Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=e441e0cf8ec93e009249d0c978bee110797f313d commit e441e0cf8ec93e009249d0c978bee110797f313d Author: Dag-Erling Smørgrav AuthorDate: 2023-06-29 13:56:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-09-07 08:56:23 +0000 indent: Restore and document -ps / -nps option. Sponsored by: Klara, Inc. Reviewed by: pauamma_gundo.com, pstef, kevans Differential Revision: https://reviews.freebsd.org/D40788 (cherry picked from commit b5b9eaa96274a9c40b06999cadc777c8aeb71d09) --- usr.bin/indent/args.c | 2 ++ usr.bin/indent/indent.1 | 10 +++++++++- usr.bin/indent/indent_globs.h | 2 ++ usr.bin/indent/lexi.c | 8 +++++--- usr.bin/indent/tests/Makefile | 3 +++ usr.bin/indent/tests/ps.0 | 4 ++++ usr.bin/indent/tests/ps.0.pro | 1 + usr.bin/indent/tests/ps.0.stdout | 8 ++++++++ 8 files changed, 34 insertions(+), 4 deletions(-) diff --git a/usr.bin/indent/args.c b/usr.bin/indent/args.c index c54c5b9fde5f..2f8ea7659128 100644 --- a/usr.bin/indent/args.c +++ b/usr.bin/indent/args.c @@ -153,12 +153,14 @@ struct pro { {"npcs", PRO_BOOL, false, OFF, &opt.proc_calls_space}, {"npro", PRO_SPECIAL, 0, IGN, 0}, {"npsl", PRO_BOOL, true, OFF, &opt.procnames_start_line}, + {"nps", PRO_BOOL, false, OFF, &opt.pointer_as_binop}, {"nsc", PRO_BOOL, true, OFF, &opt.star_comment_cont}, {"nsob", PRO_BOOL, false, OFF, &opt.swallow_optional_blanklines}, {"nut", PRO_BOOL, true, OFF, &opt.use_tabs}, {"nv", PRO_BOOL, false, OFF, &opt.verbose}, {"pcs", PRO_BOOL, false, ON, &opt.proc_calls_space}, {"psl", PRO_BOOL, true, ON, &opt.procnames_start_line}, + {"ps", PRO_BOOL, false, ON, &opt.pointer_as_binop}, {"sc", PRO_BOOL, true, ON, &opt.star_comment_cont}, {"sob", PRO_BOOL, false, ON, &opt.swallow_optional_blanklines}, {"st", PRO_SPECIAL, 0, STDIN, 0}, diff --git a/usr.bin/indent/indent.1 b/usr.bin/indent/indent.1 index b6f10824c6f7..68c0fad2c021 100644 --- a/usr.bin/indent/indent.1 +++ b/usr.bin/indent/indent.1 @@ -29,7 +29,7 @@ .\" .\" @(#)indent.1 8.1 (Berkeley) 7/1/93 .\" -.Dd June 11, 2018 +.Dd June 28, 2023 .Dt INDENT 1 .Os .Sh NAME @@ -77,6 +77,7 @@ .Op Fl npro .Op Fl P Ns Ar file .Op Fl pcs | Fl npcs +.Op Fl ps | Fl nps .Op Fl psl | Fl npsl .Op Fl \&sc | Fl nsc .Bk -words @@ -420,6 +421,13 @@ all procedure calls will have a space inserted between the name and the `('. The default is .Fl npcs . +.It Fl ps , nps +If true +.Pq Fl ps +the pointer dereference operator (`->') is treated like any other +binary operator. +The default is +.Fl nps . .It Fl psl , npsl If true .Pq Fl psl diff --git a/usr.bin/indent/indent_globs.h b/usr.bin/indent/indent_globs.h index ba2afefefd8e..640ba1bf48ec 100644 --- a/usr.bin/indent/indent_globs.h +++ b/usr.bin/indent/indent_globs.h @@ -199,6 +199,8 @@ struct options { * lined-up code within the margin */ int lineup_to_parens; /* if true, continued code within parens * will be lined up to the open paren */ + int pointer_as_binop; /* if true, the pointer dereference operator + * will be treated as a binary operator */ int proc_calls_space; /* If true, procedure calls look like: * foo (bar) rather than foo(bar) */ int procnames_start_line; /* if true, the names of procedures diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 9fb7cf30afb7..7ad1ddc74fff 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -490,9 +490,11 @@ stop_lit: else if (*buf_ptr == '>') { /* check for operator -> */ *e_token++ = *buf_ptr++; - unary_delim = false; - code = unary_op; - state->want_blank = false; + if (!opt.pointer_as_binop) { + unary_delim = false; + code = unary_op; + state->want_blank = false; + } } break; /* buffer overflow will be checked at end of * switch */ diff --git a/usr.bin/indent/tests/Makefile b/usr.bin/indent/tests/Makefile index 57e7c4db71b1..2369999e268d 100644 --- a/usr.bin/indent/tests/Makefile +++ b/usr.bin/indent/tests/Makefile @@ -44,6 +44,9 @@ ${PACKAGE}FILES+= types_from_file.0.list ${PACKAGE}FILES+= types_from_file.0.pro ${PACKAGE}FILES+= wchar.0 ${PACKAGE}FILES+= wchar.0.stdout +${PACKAGE}FILES+= ps.0 +${PACKAGE}FILES+= ps.0.stdout +${PACKAGE}FILES+= ps.0.pro ATF_TESTS_SH+= functional_test diff --git a/usr.bin/indent/tests/ps.0 b/usr.bin/indent/tests/ps.0 new file mode 100644 index 000000000000..0dc72ccfddf2 --- /dev/null +++ b/usr.bin/indent/tests/ps.0 @@ -0,0 +1,4 @@ +struct s { int i; }; +void f(struct s *p) { + p->i--; +} diff --git a/usr.bin/indent/tests/ps.0.pro b/usr.bin/indent/tests/ps.0.pro new file mode 100644 index 000000000000..5fdebee73785 --- /dev/null +++ b/usr.bin/indent/tests/ps.0.pro @@ -0,0 +1 @@ +-ps diff --git a/usr.bin/indent/tests/ps.0.stdout b/usr.bin/indent/tests/ps.0.stdout new file mode 100644 index 000000000000..08f421e984ff --- /dev/null +++ b/usr.bin/indent/tests/ps.0.stdout @@ -0,0 +1,8 @@ +struct s { + int i; +}; +void +f(struct s *p) +{ + p -> i--; +}