# - check formatting of C source according to OpenSSL coding style
#
# usage:
-# check-format.pl [-l|--sloppy-len] [-l|--sloppy-bodylen]
+# check-format.pl [-l|--strict-len] [-b|--sloppy-bodylen]
# [-s|--sloppy-space] [-c|--sloppy-comment]
# [-m|--sloppy-macro] [-h|--sloppy-hang]
# [-e|--eol-comment] [-1|--1-stmt]
# Still it should be useful for detecting most typical glitches.
#
# options:
-# -l | --sloppy-len increase accepted max line length from 80 to 84
-# -l | --sloppy-bodylen do not report function body length > 200
+# -l | --strict-len decrease accepted max line length from 100 to 80
+# -b | --sloppy-bodylen do not report function body length > 200
# -s | --sloppy-space do not report whitespace nits
# -c | --sloppy-comment do not report indentation of comments
# Otherwise for each multi-line comment the indentation of
use POSIX;
use constant INDENT_LEVEL => 4;
-use constant MAX_LINE_LENGTH => 80;
+use constant MAX_LINE_LENGTH => 100;
+use constant STRICT_LINE_LENGTH => 80;
use constant MAX_BODY_LENGTH => 200;
# global variables @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
while ($ARGV[0] =~ m/^-(\w|-[\w\-]+)$/) {
my $arg = $1; shift;
- if ($arg =~ m/^(l|-sloppy-len)$/) {
- $max_length += INDENT_LEVEL;
+ if ($arg =~ m/^(l|-strict-len)$/) {
+ $max_length = STRICT_LINE_LENGTH;
} elsif ($arg =~ m/^(b|-sloppy-bodylen)$/) {
$sloppy_bodylen = 1;
} elsif ($arg =~ m/^(s|-sloppy-space)$/) {
# do not report if contents have been shifted left of nested expr indent (but not as far as stmt indent)
# apparently aligned to the right in order to fit within line length limit
return if $stmt_indent < $count && $count < $expr_indent &&
- length($contents) == MAX_LINE_LENGTH + length("\n");
+ length($contents) == $max_length + length("\n");
}
report("indent = $count != $ref_indent for $ref_desc".
&& length($1) < $max_length)
# this allows over-long trailing string literals with beginning col before $max_length
) {
- report("line length = $len > ".MAX_LINE_LENGTH);
+ report("line length = $len > ".$max_length);
}
# handle C++ / C99 - style end-of-line comments