summaryrefslogtreecommitdiffstats
path: root/share/man/man9/style.9
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-01-30 04:17:14 +0000
committerjulian <julian@FreeBSD.org>1999-01-30 04:17:14 +0000
commitc7eb1145227f9d1c114e01185f0e09263ad5f144 (patch)
treed36b4479aaa4208311ebf3bedc6f39b7f347277f /share/man/man9/style.9
parent929979007147cb4176d4788fef5d69fb8b920239 (diff)
downloadFreeBSD-src-c7eb1145227f9d1c114e01185f0e09263ad5f144.zip
FreeBSD-src-c7eb1145227f9d1c114e01185f0e09263ad5f144.tar.gz
Slightly relax the requirements fro removing extra braces and parenthesis.
Objected to by: bde
Diffstat (limited to 'share/man/man9/style.9')
-rw-r--r--share/man/man9/style.923
1 files changed, 19 insertions, 4 deletions
diff --git a/share/man/man9/style.9 b/share/man/man9/style.9
index cf3cdb8..07fa7d5 100644
--- a/share/man/man9/style.9
+++ b/share/man/man9/style.9
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: style.9,v 1.21 1997/12/07 20:19:20 wollman Exp $
+.\" $Id: style.9,v 1.22 1997/12/07 20:25:45 wollman Exp $
.\"
.Dd December 14, 1995
.Dt STYLE 9
@@ -256,13 +256,23 @@ have a NOTREACHED comment.
.Ed
.Pp
Space after keywords (if, while, for, return, switch). No braces are
-used for control statements with zero or only a single statement.
+used for control statements with zero or only a single statement unless that
+statement is more than a single line in which case they are permitted.
Forever loops are done with for's, not while's.
.Bd -literal -offset 0i
for (p = buf; *p != '\e0'; ++p)
; /* nothing */
for (;;)
stmt;
+ for (;;) {
+ z = a + really + long + statement + that + needs +
+ two lines + gets + indented + four + spaces +
+ on + the + second + and + subsequent + lines;
+ }
+ for (;;) {
+ if (cond)
+ stmt;
+ }
if (val != NULL)
val = realloc(val, newsize);
.Ed
@@ -290,7 +300,7 @@ to form the indentation. Do not use more spaces than a tab will produce
and do not use spaces in front of tabs.
.Pp
Closing and opening braces go on the same line as the else.
-Don't add braces that aren't necessary.
+Braces that aren't necessary may be left out.
.Bd -literal -offset 0i
if (test)
stmt;
@@ -318,7 +328,8 @@ characters.
.Pp
Unary operators don't require spaces, binary operators do. Don't
use parentheses unless they're required for precedence, or the
-statement is really confusing without them.
+statement is confusing without them. Remember that other people may
+confuse easier then you. Do YOU understand the following?
.Bd -literal -offset 0i
a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
k = !(l & FLAGS);
@@ -481,6 +492,10 @@ Stylistic changes (including whitespace changes) are hard on the source
repository and are to be avoided without good reason. Code that is
approximately KNF compliant in the repository must not diverge from
compliance.
+.Pp
+Whenever possible, code should be run through a code checker
+(e.g., "gcc -Wall" or xlint(1)) and produce minimal warnings.
+
.Sh SEE ALSO
.Xr indent 1 ,
.Xr err 3 ,
OpenPOWER on IntegriCloud