changeset 14978:83fead99ff46

Merge pull request #135 from rzezeski/cstyle-continuation fixes #134 cstyle: check binary op continuations
author Garrett D'Amore <garrett@damore.org>
date Mon, 15 Dec 2014 19:41:31 -0500
parents 014608f1fae0 (current diff) 0da0e797a593 (diff)
children d2edcd520a84
files
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/tools/scripts/cstyle.pl	Wed Dec 10 08:46:44 2014 -0800
+++ b/usr/src/tools/scripts/cstyle.pl	Mon Dec 15 19:41:31 2014 -0500
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-#
+# Copyright 2014 Ryan Zezeski
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
@@ -539,8 +539,18 @@
 	if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
 		err("comma or semicolon preceded by blank");
 	}
-	if (/^\s*(&&|\|\|)/) {
-		err("improper boolean continuation");
+	# binary and assignment operators must not start a
+	# continuation line
+	#
+	# `[|<>\/^%=]` - covers |, ||, |=, <, <=, <<, <<=, >, >=, >>, =, ==
+	#                >>=, /, /=, ^, ^=, %, %=, =, ==
+	#
+	# `[-*+&] ` - covers `- `, `* `, `+ `, `& `
+	#
+	# `[-+*&!]=` - covers -=, +=, *=, &=, !=
+	#
+	if (/^\s*([|<>\/^%=]|[-*+&] |[-+*&!]=|&&)/) {
+		err("binary or assignment operator at start of continuation");
 	}
 	if (/\S   *(&&|\|\|)/ || /(&&|\|\|)   *\S/) {
 		err("more than one space around boolean operator");