summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-12-19 19:50:16 +0100
committerDr. David von Oheimb <dev@ddvo.net>2021-01-19 17:23:39 +0100
commitc972577684f8627267556f0bffa3c4035e9456e4 (patch)
treea54d3a3b79d7e79cc7a26bda376299038444f6a2
parent83b6dc8dc739ce7ca82652461bea92c31e634a57 (diff)
util/check-format.pl: Minor improvements of whitespace checks
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13710)
-rw-r--r--util/check-format-test-negatives.c4
-rw-r--r--util/check-format-test-positives.c4
-rwxr-xr-xutil/check-format.pl12
3 files changed, 11 insertions, 9 deletions
diff --git a/util/check-format-test-negatives.c b/util/check-format-test-negatives.c
index 3ce0740bc1..eb67d39a3d 100644
--- a/util/check-format-test-negatives.c
+++ b/util/check-format-test-negatives.c
@@ -242,9 +242,9 @@ struct s_type
#define X 1 + 1
#define Y /* .. */ 2 + 2
-#define Z 3 + 3
+#define Z 3 + 3 * (*a++)
-static varref cmp_vars[] = { /* comment */
+static varref cmp_vars[] = { /* comment. comment? comment! */
{&opt_config}, {&opt_section},
{&opt_server}, {&opt_proxy}, {&opt_path},
diff --git a/util/check-format-test-positives.c b/util/check-format-test-positives.c
index c2ad61f0d2..cd64ee7997 100644
--- a/util/check-format-test-positives.c
+++ b/util/check-format-test-positives.c
@@ -42,7 +42,9 @@
*@ multi-line comment indent off by -1
*X*@ no spc after leading '*' in multi-line comment, reported unless sloppy-spc
*@0 more than two spaces after . in comment, reported unless sloppy-spc
-*/ /*@2 multi-line comment end indent off by -1 (relative to comment start) */
+ *@0 more than two spaces after ? in comment, reported unless sloppy-spc
+ *@0 more than two spaces after ! in comment, reported unless sloppy-spc
+*/ /*@ multi-line comment end indent off by -1 (relative to comment start) */
*/ /*@ unexpected comment ending delimiter outside comment */
/*@ comment line is 4 columns tooooooooooooooooo wide, reported unless sloppy-len */
/*@ comment line is 5 columns toooooooooooooooooooooooooooooooooooooooooooooo wide */
diff --git a/util/check-format.pl b/util/check-format.pl
index 3230dc31fb..a1f796c749 100755
--- a/util/check-format.pl
+++ b/util/check-format.pl
@@ -241,7 +241,7 @@ sub blind_nonspace { # blind non-space text of comment as @, preserving length a
# the @ character is used because it cannot occur in normal program code so there is no confusion
# comment text is not blinded to whitespace in order to be able to check double SPC also in comments
my $comment_text = shift;
- $comment_text =~ s/\.\s\s/.. /g; # in double SPC checks allow one extra space after period '.' in comments
+ $comment_text =~ s/([\.\?\!])\s\s/$1. /g; # in double SPC checks allow one extra space after period '.', '?', or '!' in comments
return $comment_text =~ tr/ /@/cr;
}
@@ -675,17 +675,17 @@ while (<>) { # loop over all lines of all input files
report("no SPC before '=' or '<op>='") if $intra_line =~ m/\S(=)/; # '=' etc. without preceding space
report("no SPC before '$1'") if $intra_line =~ m/\S([|\/%<>^\?])/; # |/%<>^? without preceding space
# TODO ternary ':' without preceding SPC, while allowing no SPC before ':' after 'case'
- report("no SPC before '$1'") if $intra_line =~ m/[^\s{()\[]([+\-])/;# +/- without preceding space or {()[
+ report("no SPC before binary '$1'") if $intra_line =~ m/[^\s{()\[]([+\-])/;# +/- without preceding space or {()[
# or ')' (which is used f type casts)
- report("no SPC before '$1'") if $intra_line =~ m/[^\s{()\[*]([*])/; # '*' without preceding space or {()[*
- report("no SPC before '$1'") if $intra_line =~ m/[^\s{()\[]([&])/; # '&' without preceding space or {()[
+ report("no SPC before binary '$1'") if $intra_line =~ m/[^\s{()\[*]([*])/; # '*' without preceding space or {()[*
+ report("no SPC before binary '$1'") if $intra_line =~ m/[^\s{()\[]([&])/; # '&' without preceding space or {()[
report("no SPC after ternary '$1'") if $intra_line =~ m/(:)[^\s\d]/; # ':' without following space or digit
report("no SPC after '$1'") if $intra_line =~ m/([,;=|\/%<>^\?])\S/; # ,;=|/%<>^? without following space
- report("no SPC after binary '$1'") if $intra_line=~m/([*])[^\sa-zA-Z_(),*]/;# '*' w/o space or \w(),* after
+ report("no SPC after binary '$1'") if $intra_line=~m/[^{(\[]([*])[^\sa-zA-Z_(),*]/;# '*' w/o space or \w(),* after
# TODO unary '*' must not be followed by SPC
report("no SPC after binary '$1'") if $intra_line=~m/([&])[^\sa-zA-Z_(]/; # '&' w/o following space or \w(
# TODO unary '&' must not be followed by SPC
- report("no SPC after binary '$1'") if $intra_line=~m/([+\-])[^\s\d(]/; # +/- w/o following space or \d(
+ report("no SPC after binary '$1'") if $intra_line=~m/[^{(\[]([+\-])[^\s\d(]/; # +/- w/o following space or \d(
# TODO unary '+' and '-' must not be followed by SPC
report("no SPC after '$2'") if $intra_line =~ m/(^|\W)(if|while|for|switch|case)[^\w\s]/; # kw w/o SPC
report("no SPC after '$2'") if $intra_line =~ m/(^|\W)(return)[^\w\s;]/; # return w/o SPC or ';'