Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/misc style: don't require sorting variables in functions



details:   https://anonhg.NetBSD.org/src/rev/6ddf89e894e6
branches:  trunk
changeset: 374252:6ddf89e894e6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 14 16:53:13 2023 +0000

description:
style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html

diffstat:

 share/misc/style |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 78585bf86d7d -r 6ddf89e894e6 share/misc/style
--- a/share/misc/style  Fri Apr 14 16:51:46 2023 +0000
+++ b/share/misc/style  Fri Apr 14 16:53:13 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.70 2023/04/11 14:22:10 riastradh Exp $ */
+/* $NetBSD: style,v 1.71 2023/04/14 16:53:13 rillig Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.70 2023/04/11 14:22:10 riastradh Exp $");
+__RCSID("$NetBSD: style,v 1.71 2023/04/14 16:53:13 rillig Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -353,10 +353,10 @@ static char *
 function(int a1, int a2, float fl, int a4)
 {
        /*
-        * When declaring variables in functions declare them sorted by size,
-        * then in alphabetical order; multiple ones per line are okay.
+        * When declaring variables in functions, multiple variables per line
+        * are okay. If a line overflows reuse the type keyword.
+        *
         * Function prototypes should go in the include file "extern.h".
-        * If a line overflows reuse the type keyword.
         *
         * Avoid initializing variables in the declarations; move
         * declarations next to their first use, and initialize



Home | Main Index | Thread Index | Old Index