Skip to content

Commit

Permalink
cstyle: Allow URLs in C++ comments
Browse files Browse the repository at this point in the history
If a C++ comment contained a URL, the `://` part of the URL would
trigger an error because there was no trailing blank, but trailing
blanks make for an invalid URL.  Modify the check to ignore text
within the C++ comment.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chris Lindee <[email protected]>
Closes #13987
  • Loading branch information
ColMelvin authored Oct 13, 2022
1 parent ab8d9c1 commit 642c2de
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/cstyle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ ($$)
if (/\S\*\/[^)]|\S\*\/$/ && !/$lint_re/) {
err("missing blank before close comment");
}
if (/\/\/\S/) { # C++ comments
err("missing blank after start comment");
}
# check for unterminated single line comments, but allow them when
# they are used to comment out the argument list of a function
# declaration.
Expand Down Expand Up @@ -534,7 +531,15 @@ ($$)
# multiple comments on the same line.
#
s/\/\*.*?\*\///g;
s/\/\/.*$//; # C++ comments
s/\/\/(?:\s.*)?$//; # Valid C++ comments

# After stripping correctly spaced comments, check for (and strip) comments
# without a blank. By checking this after clearing out C++ comments that
# correctly have a blank, we guarantee URIs in a C++ comment will not cause
# an error.
if (s!//.*$!!) { # C++ comments
err("missing blank after start comment");
}

# delete any trailing whitespace; we have already checked for that.
s/\s*$//;
Expand Down

0 comments on commit 642c2de

Please sign in to comment.