[patch] C99 & /usr/share/misc/style

Joseph Koshy <[email protected]>
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <[email protected]>
Greetings,

I would like to suggest the following C99-specific changes to
"share/misc/style".

Please let me know if these changes look reasonable (or if not).

Regards,
Joseph Koshy

https://paste.sr.ht/blob/2532c3cc6fe753a82a3d49ff2421160e0a234a91

Index: style
===================================================================
RCS file: /cvsroot/src/share/misc/style,v
retrieving revision 1.65
diff -u -r1.65 style
--- style	29 Dec 2022 18:23:37 -0000	1.65
+++ style	29 Dec 2022 19:11:47 -0000
@@ -43,6 +43,11 @@
  * them so they look like real paragraphs.
  */
 
+// C99 single-line comments are allowed.
+
+// C99 single-line comments can also be used to write longer form
+// comments.  Fill these so they look like real paragraphs.
+
 /*
  * Attempt to wrap lines longer than 80 characters appropriately.
  * Refer to the examples below for more information.
@@ -147,10 +152,13 @@
 
 #define	DOUBLE(x) ((x) * 2)
 
-/* Enum constants are capitalized.  No comma on the last element. */
+/*
+ * Enum constants are capitalized.  Commas are recommended for the last
+ * element as using them can minimize diffs.
+ */
 enum enumtype {
 	ONE,
-	TWO
+	TWO,
 };
 
 /*
@@ -260,8 +268,10 @@
 	 * Braces around single-line bodies are optional; use discretion.
 	 *
 	 * Forever loops are done with for's, not while's.
+	 *
+	 * Use narrow scopes for loop variables where possible.
 	 */
-	for (p = buf; *p != '\0'; ++p)
+	for (char *p = buf; *p != '\0'; ++p)
 		continue;		/* Explicit no-op */
 	for (;;)
 		stmt;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.