Restore and document -ps / -nps option.

Sponsored by:	Klara, Inc.
Reviewed by:	pauamma_gundo.com, pstef, kevans
Differential Revision:	https://reviews.freebsd.org/D40788
This commit is contained in:
Dag-Erling Smørgrav 2023-06-29 13:56:28 +00:00
parent 81b4bf0895
commit b5b9eaa962
8 changed files with 34 additions and 4 deletions

View file

@ -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},

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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

View file

@ -0,0 +1,4 @@
struct s { int i; };
void f(struct s *p) {
p->i--;
}

View file

@ -0,0 +1 @@
-ps

View file

@ -0,0 +1,8 @@
struct s {
int i;
};
void
f(struct s *p)
{
p -> i--;
}