From nobody Thu Jun 29 14:02:06 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 4QsKrZ4zX5z4klgN; Thu, 29 Jun 2023 14:02:06 +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 4QsKrZ4Z67z3LQQ; Thu, 29 Jun 2023 14:02:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688047326; 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=C5TUxalqVEThMrK+fngqO1sYAU3X2KaHnuHrht5MzWU=; b=CY3TLHOmRG9RakHmHHBU2T7cYeVHIFsHxgVvyE32wdBCihBIy+/3kRDqF4eqh41BC6QLlO 8IMtGfhGz+yEZrZeKSV4MRcZhFr8KmiFaKOm3DyQf8zsg3Ev/c+uosksYioq9pD7waKk2T qSu1AE3NkZlroMSz/QznnzkDJCQzbn+PzDRznqEWKnLkrTw0KwECFWfAciOzeb/f+a0cDj WPrqMeftiYIimSG3ZrmKAOPNy9qx+PtVhNhQZ0S912LSUmwf8+ZK8q6oQP00edmDjvjb7d AEOOjjTQsEkqiG0nqzrAOZiozOuAKJkPWCTcPJAQr6eHnuJcD2uFVcQ30Jl4Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688047326; 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=C5TUxalqVEThMrK+fngqO1sYAU3X2KaHnuHrht5MzWU=; b=N1v+H77ZVnFkwsEDdynwWCbSHcKckuNkzPCl0pu6L5MhcIHqm8GFC8OQIKLitsnpefxCPP bo0mroL9SRKIs1Kb2e4wWbxy27vXw0Jrj2hBIIXq/22oEMiMOwZLWZhL2oWfE+XoaDaS5d 74oq5U33x08w99SU5fUhM3SGF2aUpU9DrIKXM57h0grRZWw95m/dIWo0DLylaoUy6az62M Izj5+Q6ZY5yzhzOZ5EUlgV1G9ac1pqkINoxvqsMf7cnU62/iWEYmpN6kWUXgJjdKhZwAY4 qayYIKUwk1w3YxtVEr9YX837Mmzy5kx8tCCvoBlz5lXDQ41x6cqmY1i6NVtwAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688047326; a=rsa-sha256; cv=none; b=tffPKnbLk33Xw3nYykiYMm0KDkwsPgwjRB/LzgtpXAu+2g4ld/LkWxIG2BRhiFS7cDYYPG y3lnQNCjPYP+F2IYNNCZ8sbyekpy+DoqmSFoAs0Gp8y9yTCckY2YJgmyyEz1c/p+VGhL+P 5rwCKj0BWDt9uLbKBg+z8rIMvn91yku5mRTxFBKopiUUTPyQF5EdjiB2CedxofaaBQO7RF e7Ui3MLMlmQ+MQ68w2e5wB/+VM0jEznHzA4wCw/7fC74I39+mN2QTPaVIBVXHruUfwmMkR edpr/N3xqeEiWANCoXQwJ554rkQQCLRaY5sukcEiZblw7SNLTuPY3I53vaQ/HQ== 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 4QsKrZ3fBhzJPc; Thu, 29 Jun 2023 14:02:06 +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 35TE26rr054200; Thu, 29 Jun 2023 14:02:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 35TE264f054199; Thu, 29 Jun 2023 14:02:06 GMT (envelope-from git) Date: Thu, 29 Jun 2023 14:02:06 GMT Message-Id: <202306291402.35TE264f054199@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: b5b9eaa96274 - main - 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/main X-Git-Reftype: branch X-Git-Commit: b5b9eaa96274a9c40b06999cadc777c8aeb71d09 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b5b9eaa96274a9c40b06999cadc777c8aeb71d09 commit b5b9eaa96274a9c40b06999cadc777c8aeb71d09 Author: Dag-Erling Smørgrav AuthorDate: 2023-06-29 13:56:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-06-29 13:59:49 +0000 Restore and document -ps / -nps option. Sponsored by: Klara, Inc. Reviewed by: pauamma_gundo.com, pstef, kevans Differential Revision: https://reviews.freebsd.org/D40788 --- 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 4d4cc32373a0..58ab9bf4b9f2 100644 --- a/usr.bin/indent/args.c +++ b/usr.bin/indent/args.c @@ -155,12 +155,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 04e8ad355e28..5a7ca371b0ae 100644 --- a/usr.bin/indent/indent.1 +++ b/usr.bin/indent/indent.1 @@ -30,7 +30,7 @@ .\" @(#)indent.1 8.1 (Berkeley) 7/1/93 .\" $FreeBSD$ .\" -.Dd June 11, 2018 +.Dd June 28, 2023 .Dt INDENT 1 .Os .Sh NAME @@ -78,6 +78,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 @@ -421,6 +422,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 ffb70861f5d2..cadf442a2c98 100644 --- a/usr.bin/indent/indent_globs.h +++ b/usr.bin/indent/indent_globs.h @@ -200,6 +200,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 83178a72b4f6..c47db6baead3 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -492,9 +492,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 ede9e5ab246c..b9d208cb8285 100644 --- a/usr.bin/indent/tests/Makefile +++ b/usr.bin/indent/tests/Makefile @@ -45,6 +45,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--; +}