diff --git a/share/misc/style b/share/misc/style index 49c15be5b3e5..694c6a93dc96 100644 --- a/share/misc/style +++ b/share/misc/style @@ -1,4 +1,4 @@ -/* $NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $ */ +/* $NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $ */ /* * The revision control tag appears first, with a blank line after it. @@ -30,7 +30,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $"); +__RCSID("$NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $"); /* * VERY important single-line comments look like this. @@ -241,8 +241,9 @@ main(int argc, char *argv[]) errno = 0; num = strtol(optarg, &ep, 10); if (num <= 0 || *ep != '\0' || (errno == ERANGE && - (num == LONG_MAX || num == LONG_MIN)) ) + (num == LONG_MAX || num == LONG_MIN)) ) { errx(1, "illegal number -- %s", optarg); + } break; case '?': default: @@ -254,9 +255,9 @@ main(int argc, char *argv[]) argv += optind; /* - * Space after keywords (while, for, return, switch). No braces are - * required for control statements with only a single statement, - * unless it's a long statement. + * Space after keywords (while, for, return, switch). + * + * Braces around single-line bodies are optional; use discretion. * * Forever loops are done with for's, not while's. */ @@ -288,15 +289,14 @@ main(int argc, char *argv[]) } /* Second level indents are four spaces. */ - while (cnt < 20) + while (cnt < 20) { z = a + really + long + statement + that + needs + two + lines + gets + indented + four + spaces + on + the + second + and + subsequent + lines; + } /* * Closing and opening braces go on the same line as the else. - * Don't add braces that aren't necessary except in cases where - * there are ambiguity or readability issues. */ if (test) { /* @@ -310,8 +310,9 @@ main(int argc, char *argv[]) } else if (bar) { stmt; stmt; - } else + } else { stmt; + } /* No spaces after function names. */ if ((result = function(a1, a2, a3, a4)) == NULL)