From b1f55fa0b2181fe1afe7961eb69050f4933aa9be Mon Sep 17 00:00:00 2001 From: pstef Date: Fri, 1 Jun 2018 19:56:41 +0000 Subject: [PATCH] indent(1): restore working -pcs My previous indent(1) commit accidentally broke the -pcs option (which adds space between function name and opening parenthesis in function calls) by copying all but one of a few conditions in an if clause. Reinstate the condition. Add a regression test to lower the chances of breaking it again. Correct a comment with description of what the option does. --- usr.bin/indent/indent.c | 1 + usr.bin/indent/indent_globs.h | 2 +- usr.bin/indent/tests/Makefile | 3 +++ usr.bin/indent/tests/pcs.0 | 7 +++++++ usr.bin/indent/tests/pcs.0.pro | 2 ++ usr.bin/indent/tests/pcs.0.stdout | 9 +++++++++ 6 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 usr.bin/indent/tests/pcs.0 create mode 100644 usr.bin/indent/tests/pcs.0.pro create mode 100644 usr.bin/indent/tests/pcs.0.stdout diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 2b3e4e329570..a9f6aa4fd79b 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -556,6 +556,7 @@ check_type: } else if (ps.want_blank && *token != '[' && ((ps.last_token != ident && ps.last_token != funcname) || + proc_calls_space || /* offsetof (1) is never allowed a space; sizeof (2) gets * one iff -bs; all other keywords (>2) always get a space * before lparen */ diff --git a/usr.bin/indent/indent_globs.h b/usr.bin/indent/indent_globs.h index bdc00647e1a4..b373688a9111 100644 --- a/usr.bin/indent/indent_globs.h +++ b/usr.bin/indent/indent_globs.h @@ -168,7 +168,7 @@ int procnames_start_line; /* if true, the names of procedures * the type of the procedure and its * name) */ int proc_calls_space; /* If true, procedure calls look like: - * foo(bar) rather than foo (bar) */ + * foo (bar) rather than foo(bar) */ int format_block_comments; /* true if comments beginning with * `/ * \n' are to be reformatted */ int format_col1_comments; /* If comments which start in column 1 diff --git a/usr.bin/indent/tests/Makefile b/usr.bin/indent/tests/Makefile index 2f05019485d0..95b9f71d053b 100644 --- a/usr.bin/indent/tests/Makefile +++ b/usr.bin/indent/tests/Makefile @@ -26,6 +26,9 @@ ${PACKAGE}FILES+= offsetof.0.stdout ${PACKAGE}FILES+= parens.0 ${PACKAGE}FILES+= parens.0.stdout ${PACKAGE}FILES+= parens.0.pro +${PACKAGE}FILES+= pcs.0 +${PACKAGE}FILES+= pcs.0.stdout +${PACKAGE}FILES+= pcs.0.pro ${PACKAGE}FILES+= sac.0 ${PACKAGE}FILES+= sac.0.stdout ${PACKAGE}FILES+= sac.0.pro diff --git a/usr.bin/indent/tests/pcs.0 b/usr.bin/indent/tests/pcs.0 new file mode 100644 index 000000000000..aed296b1ca16 --- /dev/null +++ b/usr.bin/indent/tests/pcs.0 @@ -0,0 +1,7 @@ +/* $FreeBSD$ */ +#include + +int main(void) { + puts("Hello"); + return 0; +} diff --git a/usr.bin/indent/tests/pcs.0.pro b/usr.bin/indent/tests/pcs.0.pro new file mode 100644 index 000000000000..41027f063dfa --- /dev/null +++ b/usr.bin/indent/tests/pcs.0.pro @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +-pcs diff --git a/usr.bin/indent/tests/pcs.0.stdout b/usr.bin/indent/tests/pcs.0.stdout new file mode 100644 index 000000000000..c96fb5442ae6 --- /dev/null +++ b/usr.bin/indent/tests/pcs.0.stdout @@ -0,0 +1,9 @@ +/* $FreeBSD$ */ +#include + +int +main(void) +{ + puts ("Hello"); + return 0; +}