Lines Matching +full:sub +full:- +full:spaces

2 # SPDX-License-Identifier: CDDL-1.0
11 # or https://opensource.org/licenses/CDDL-1.0.
31 # cstyle - check for some common stylistic errors.
46 # \S any non-space character
47 # \w any "word" character [a-zA-Z0-9_]
48 # \W any non-word character
49 # \d a digit [0-9]
50 # \D a non-digit
52 # \B non-word boundary
62 "usage: cstyle [-cgpvP] file...
63 -c check continuation indentation inside functions
64 -g print github actions' workflow commands
65 -p perform some of the more picky checks
66 -v verbose
67 -P check for use of non-POSIX types
114 NOTREACHED|LINTLIBRARY|VARARGS[0-9]*|
116 FALLTHRU|FALLTHROUGH|LINTED.*?|PRINTFLIKE[0-9]*|
117 PROTOLIB[0-9]*|SCANFLIKE[0-9]*|CSTYLED.*?
124 READ-ONLY\ VARIABLES:|
125 READ-ONLY\ MEMBERS:|
162 my $no_errs = 0; # set for CSTYLED-protected lines
164 sub err($) {
179 sub err_prefix($$) {
192 sub err_prev($) {
196 printf $fmt, $filename, $. - 1, $error, $prev;
198 printf $fmt, $filename, $. - 1, $error;
204 sub cstyle($$) {
245 # (we assume that no-one will use backslash-continuation with character
253 s/'([^\\']|\\[^xX0]|\\0[0-9]*|\\[xX][0-9a-fA-F]*)'/''/g;
280 # an /* END CSTYLED */ comment ends a no-check block.
311 # replace tabs with spaces and check again.
314 s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
322 s/[^()]//g; # eliminate all non-parens
323 $note_level += s/\(//g - length; # update paren nest level
327 # a /* BEGIN CSTYLED */ comment starts a no-check block.
346 err("spaces between tabs");
349 err("tabs between spaces");
355 err("comment preceded by non-blank");
396 err("continuation line should be indented by 4 spaces");
400 # If this looks like a top-level macro invocation, remember it so we
402 if (/^[A-Za-z_][A-Za-z_0-9]*\(/) {
443 # XXX - but still a problem in sub-blocks.
478 # allow spaces to be used to draw pictures in all comments.
480 err("spaces instead of tabs");
484 err("indent by spaces instead of tabs");
487 err("continuation line not indented by 4 spaces");
528 err("non-comment text following " .
538 # ".*?" is a non-greedy match, so that we don't get confused by
558 (/[^->]>[^,=>\s]/ && !/[^->]>$/) ||
560 /[^<\s]<[^<]/ || /[^->\s]>[^>]/) {
563 if (/\S>>=/ || /\S<<=/ || />>=\S/ || /<<=\S/ || /\S[-+*\/&|^%]=/ ||
564 (/[^-+*\/&|^%!<>=\s]=[^=]/ && !/[^-+*\/&|^%!<>=\s]=$/) ||
566 # XXX - should only check this for C++ code
567 # XXX - there are probably other forms that should be allowed
573 err("comma or semicolon followed by non-blank");
616 # XXX - this still trips over too many legitimate things,
640 # Allow right paren on its own line unless we're being picky (-p).
685 # try to detect spaces after casts, but allow (e.g.)
700 # try to detect old non-POSIX types.
701 # POSIX requires all non-standard typedefs to end in _t,
707 err("non-POSIX typedef $1 used: use $old2posix{$1} instead");
734 # Continuation-line checking
741 # processed; all comments have been replaced by control-A, and the contents of
755 my $cont_case; # this is a multi-line case
759 sub
766 sub
787 sub
800 my $macro = '[A-Z_][A-Z_0-9]*\(';
808 $cont_off = tr/{/{/ - tr/}/}/;
812 $cont_off += tr/{/{/ - tr/}/}/;
820 err("non-continuation indented 4 spaces");
833 return if (/^\s*[A-Z_][A-Z_0-9]*$/);
835 # cases we don't deal with, generally non-kosher
856 # Strings may be pulled back to an earlier (half-)tabstop
860 "continuation should be indented 4 spaces");
973 err("stuff after multi-line case") if ($rest !~ /$^/);