5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or https://opensource.org/licenses/CDDL-1.0.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2016 Nexenta Systems, Inc.
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 # @(#)cstyle 1.58 98/09/09 (from shannon)
28 #ident "%Z%%M% %I% %E% SMI"
30 # cstyle - check for some common stylistic errors.
32 # cstyle is a sort of "lint" for C coding style.
33 # It attempts to check for the style used in the
34 # kernel, sometimes known as "Bill Joy Normal Form".
36 # There's a lot this can't check for, like proper indentation
37 # of code blocks. There's also a lot more this could check for.
39 # A note to the non perl literate:
41 # perl regular expressions are pretty much like egrep
42 # regular expressions, with the following special symbols
44 # \s any space character
45 # \S any non-space character
46 # \w any "word" character [a-zA-Z0-9_]
47 # \W any non-word character
50 # \b word boundary (between \w and \W)
51 # \B non-word boundary
61 "usage: cstyle [-cgpvP] file...
62 -c check continuation indentation inside functions
63 -g print github actions' workflow commands
64 -p perform some of the more picky checks
66 -P check for use of non-POSIX types
71 if (!getopts
("cghpvCP", \
%opts)) {
76 my $check_continuation = $opts{'c'};
77 my $github_workflow = $opts{'g'} || $ENV{'CI'};
78 my $picky = $opts{'p'};
79 my $verbose = $opts{'v'};
80 my $check_posix_types = $opts{'P'};
82 my ($filename, $line, $prev); # shared globals
85 my $hdr_comment_start;
88 $fmt = "%s: %d: %s\n%s\n";
90 $fmt = "%s: %d: %s\n";
93 $hdr_comment_start = qr/^\s*\/\
*$/;
95 # Note, following must be in single quotes so that \s and \w work right.
96 my $typename = '(int|char|short|long|unsigned|float|double' .
97 '|\w+_t|struct\s+\w+|union\s+\w+|FILE)';
99 # mapping of old types to POSIX compatible types
101 'unchar' => 'uchar_t',
102 'ushort' => 'ushort_t',
104 'ulong' => 'ulong_t',
106 'u_short' => 'ushort_t',
107 'u_long' => 'ulong_t',
108 'u_char' => 'uchar_t',
112 my $lint_re = qr/\/\
*(?
:
113 NOTREACHED
|LINTLIBRARY
|VARARGS
[0-9]*|
114 CONSTCOND
|CONSTANTCOND
|CONSTANTCONDITION
|EMPTY
|
115 FALLTHRU
|FALLTHROUGH
|LINTED
.*?
|PRINTFLIKE
[0-9]*|
116 PROTOLIB
[0-9]*|SCANFLIKE
[0-9]*|CSTYLED
.*?
119 my $warlock_re = qr/\/\
*\s
*(?
:
120 VARIABLES\ PROTECTED\ BY
|
121 MEMBERS\ PROTECTED\ BY
|
122 ALL\ MEMBERS\ PROTECTED\ BY
|
123 READ
-ONLY\ VARIABLES
:|
125 VARIABLES\ READABLE\ WITHOUT\ LOCK
:|
126 MEMBERS\ READABLE\ WITHOUT\ LOCK
:|
128 LOCK\ UNNEEDED\ BECAUSE
|
130 LOCK\ HELD\ ON\ ENTRY
:|
131 READ\ LOCK\ HELD\ ON\ ENTRY
:|
132 WRITE\ LOCK\ HELD\ ON\ ENTRY
:|
133 LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT
:|
134 READ\ LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT
:|
135 WRITE\ LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT
:|
136 LOCK\ RELEASED\ AS\ SIDE\ EFFECT
:|
137 LOCK\ UPGRADED\ AS\ SIDE\ EFFECT
:|
138 LOCK\ DOWNGRADED\ AS\ SIDE\ EFFECT
:|
139 FUNCTIONS\ CALLED\ THROUGH\ POINTER
|
140 FUNCTIONS\ CALLED\ THROUGH\ MEMBER
|
144 my $err_stat = 0; # exit status
147 foreach my $arg (@ARGV) {
148 my $fh = new IO
::File
$arg, "r";
150 printf "%s: can not open\n", $arg;
157 &cstyle
("<stdin>", *STDIN
);
161 my $no_errs = 0; # set for CSTYLED-protected lines
167 printf $fmt, $filename, $., $error, $line;
169 printf $fmt, $filename, $., $error;
171 if ($github_workflow) {
172 printf "::error file=%s,line=%s::%s\n", $filename, $., $error;
179 my ($prevline, $error) = @_;
180 my $out = $prevline."\n".$line;
183 printf $fmt, $filename, $., $error, $out;
185 printf $fmt, $filename, $., $error;
195 printf $fmt, $filename, $. - 1, $error, $prev;
197 printf $fmt, $filename, $. - 1, $error;
205 my ($fn, $filehandle) = @_;
206 $filename = $fn; # share it globally
212 my $comment_done = 0;
213 my $in_warlock_comment = 0;
215 my $in_function_header = 0;
216 my $function_header_full_indent = 0;
217 my $in_declaration = 0;
224 my ($okmsg, $comment_prefix);
230 line
: while (<$filehandle>) {
231 s/\r?\n$//; # strip return and newline
233 # save the original line, then remove all text from within
234 # double or single quotes, we do not want to check such text.
239 # C allows strings to be continued with a backslash at the end of
240 # the line. We translate that into a quoted string on the previous
241 # line followed by an initial quote on the next line.
243 # (we assume that no-one will use backslash-continuation with character
246 $_ = '"' . $_ if ($in_string && !$nocheck && !$in_comment);
249 # normal strings and characters
251 s/'([^\\']|\\[^xX0]|\\0[0-9]*|\\[xX][0-9a-fA-F]*)'/''/g;
252 s/"([^\\"]|\\.)*"/\"\"/g;
255 # detect string continuation
257 if ($nocheck || $in_comment) {
261 # Now that all full strings are replaced with "", we check
262 # for unfinished strings continuing onto the next line.
265 (s/([^"](?:"")*)"([^\\"]|\\.)*\\$/$1""/ ||
266 s/^("")*"([^\\"]|\\.)*\\$/""/);
270 # figure out if we are in a cpp directive
272 $in_cpp = $next_in_cpp || /^\s*#/; # continued or started
273 $next_in_cpp = $in_cpp && /\\$/; # only if continued
275 # strip off trailing backslashes, which appear in long macros
278 # an /* END CSTYLED */ comment ends a no-check block.
280 if (/\/\
* *END *CSTYLED
*\
*\
//) {
288 # a /*CSTYLED*/ comment indicates that the next line is ok.
295 if (/\/\
* *CSTYLED
.*\
*\
//) {
296 /^.*\/\
* *CSTYLED
*(.*) *\
*\
/.*$/;
305 # check length of line.
306 # first, a quick check to see if there is any chance of being too long.
307 if (($line =~ tr/\t/\t/) * 7 + length($line) > 80) {
308 # yes, there is a chance.
309 # replace tabs with spaces and check again.
312 s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
313 if (length($eline) > 80) {
314 err
("line > 80 characters");
318 # ignore NOTE(...) annotations (assumes NOTE is on lines by itself).
319 if ($note_level || /\b_?NOTE\s*\(/) { # if in NOTE or this is NOTE
320 s/[^()]//g; # eliminate all non-parens
321 $note_level += s/\(//g - length; # update paren nest level
325 # a /* BEGIN CSTYLED */ comment starts a no-check block.
326 if (/\/\
* *BEGIN *CSTYLED
*\
*\
//) {
330 # a /*CSTYLED*/ comment indicates that the next line is ok.
331 if (/\/\
* *CSTYLED
.*\
*\
//) {
332 /^.*\/\
* *CSTYLED
*(.*) *\
*\
/.*$/;
336 if (/\/\
/ *CSTYLED/) {
337 /^.*\/\
/ *CSTYLED *(.*)$/;
342 # universal checks; apply to everything
344 err
("spaces between tabs");
347 err
("tabs between spaces");
350 err
("space or tab at end of line");
352 if (/[^ \t(]\/\
*/ && !/\w\
(\
/\*.*\*\/\
);/) {
353 err
("comment preceded by non-blank");
356 err
("ARGSUSED directive");
359 # is this the beginning or ending of a function?
360 # (not if "struct foo\n{\n")
361 if (/^\{$/ && $prev =~ /\)\s*(const\s*)?(\/\
*.*\
*\
/\s*)?\\?$/) {
364 $in_function_header = 0;
365 $function_header_full_indent = 0;
369 if (/^\}\s*(\/\
*.*\
*\
/\s*)*$/) {
370 if ($prev =~ /^\s*return\s*;/) {
371 err_prev
("unneeded return at end of function");
374 reset_indent
(); # we don't check between functions
378 if ($in_function_header && ! /^ (\w|\.)/ ) {
379 if (/^\{\}$/ # empty functions
380 || /;/ #run function with multiline arguments
381 || /#/ #preprocessor commands
382 || /^[^\s\\]*\(.*\)$/ #functions without ; at the end
383 || /^$/ #function declaration can't have empty line
385 $in_function_header = 0;
386 $function_header_full_indent = 0;
387 } elsif ($prev =~ /^__attribute__/) { #__attribute__((*))
388 $in_function_header = 0;
389 $function_header_full_indent = 0;
392 } elsif ($picky && ! (/^\t/ && $function_header_full_indent != 0)) {
394 err
("continuation line should be indented by 4 spaces");
399 # If this matches something of form "foo(", it's probably a function
400 # definition, unless it ends with ") bar;", in which case it's a declaration
401 # that uses a macro to generate the type.
403 if (/^\w+\(/ && !/\) \w+;/) {
404 $in_function_header = 1;
406 $function_header_full_indent = 1;
409 if ($in_function_header && /^\{$/) {
410 $in_function_header = 0;
411 $function_header_full_indent = 0;
414 if ($in_function_header && /\);$/) {
415 $in_function_header = 0;
416 $function_header_full_indent = 0;
418 if ($in_function_header && /\{$/ ) {
420 err
("opening brace on same line as function header");
422 $in_function_header = 0;
423 $function_header_full_indent = 0;
428 if ($in_warlock_comment && /\*\//) {
429 $in_warlock_comment = 0;
434 # a blank line terminates the declarations within a function.
435 # XXX - but still a problem in sub-blocks.
436 if ($in_declaration && /^$/) {
444 # does this looks like the start of a block comment?
445 if (/$hdr_comment_start/) {
447 err
("block comment not indented by tabs");
451 $comment_prefix = $1;
455 # are we still in the block comment?
457 if (/^$comment_prefix \*\/$/) {
461 err
("improper block comment close");
462 } elsif (!/^$comment_prefix \*[ \t]/ &&
463 !/^$comment_prefix \*$/) {
464 err
("improper block comment");
468 # check for errors that might occur in comments and in code.
470 # allow spaces to be used to draw pictures in all comments.
471 if (/[^ ] / && !/".* .*"/ && !$in_comment) {
472 err
("spaces instead of tabs");
474 if (/^ / && !/^ \*[ \t\/]/ && !/^ \
*$/ &&
475 (!/^ (\w|\.)/ || $in_function != 0)) {
476 err
("indent by spaces instead of tabs");
478 if (/^\t+ [^ \t\*]/ || /^\t+ \S/ || /^\t+ \S/) {
479 err
("continuation line not indented by 4 spaces");
481 if (/$warlock_re/ && !/\*\//) {
482 $in_warlock_comment = 1;
486 if (/^\s*\/\
*./ && !/^\s
*\
/\*.*\*\// && !/$hdr_comment_start/) {
487 err
("improper first line of block comment");
490 if ($in_comment) { # still in comment, don't do further checks
495 if ((/[^(]\/\
*\S
/ || /^\
/\*\S/) && !/$lint_re/) {
496 err
("missing blank after open comment");
498 if (/\S\*\/[^)]|\S\
*\
/$/ && !/$lint_re/) {
499 err
("missing blank before close comment");
501 # check for unterminated single line comments, but allow them when
502 # they are used to comment out the argument list of a function
504 if (/\S.*\/\
*/ && !/\S
.*\
/\*.*\*\// && !/\
(\
/\*/) {
505 err
("unterminated single line comment");
508 if (/^(#else|#endif|#include)(.*)$/) {
513 # Enforce ANSI rules for #else and #endif: no noncomment
514 # identifiers are allowed after #endif or #else. Allow
515 # C++ comments since they seem to be a fact of life.
516 if ((($1 eq "#endif") || ($1 eq "#else")) &&
518 (!($clause =~ /^\s+\/\
*.*\
*\
/$/)) &&
519 (!($clause =~ /^\s+\/\
/.*$/))) {
520 err
("non-comment text following " .
521 "$directive (or malformed $directive " .
529 # delete any comments and check everything else. Note that
530 # ".*?" is a non-greedy match, so that we don't get confused by
531 # multiple comments on the same line.
533 s/\/\*.*?\*\//\x01/g;
534 s/\/\/(?
:\s
.*)?
$/\x01/; # Valid C++ comments
536 # After stripping correctly spaced comments, check for (and strip) comments
537 # without a blank. By checking this after clearing out C++ comments that
538 # correctly have a blank, we guarantee URIs in a C++ comment will not cause
540 if (s!//.*$!\x01!) { # C++ comments
541 err
("missing blank after start comment");
544 # delete any trailing whitespace; we have already checked for that.
547 # following checks do not apply to text in comments.
549 if (/[^<>\s][!<>=]=/ || /[^<>][!<>=]=[^\s,]/ ||
550 (/[^->]>[^,=>\s]/ && !/[^->]>$/) ||
551 (/[^<]<[^,=<\s]/ && !/[^<]<$/) ||
552 /[^<\s]<[^<]/ || /[^->\s]>[^>]/) {
553 err
("missing space around relational operator");
555 if (/\S>>=/ || /\S<<=/ || />>=\S/ || /<<=\S/ || /\S[-+*\/&|^%]=/ ||
556 (/[^-+*\/&|^%!<>=\s
]=[^=]/ && !/[^-+*\
/&|^%!<>=\s]=$/) ||
557 (/[^!<>=]=[^=\s]/ && !/[^!<>=]=$/)) {
558 # XXX - should only check this for C++ code
559 # XXX - there are probably other forms that should be allowed
560 if (!/\soperator=/) {
561 err
("missing space around assignment operator");
564 if (/[,;]\S/ && !/\bfor \(;;\)/) {
565 err
("comma or semicolon followed by non-blank");
567 # allow "for" statements to have empty "while" clauses
568 if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
569 err
("comma or semicolon preceded by blank");
571 if (/^\s*(&&|\|\|)/) {
572 err
("improper boolean continuation");
574 if (/\S *(&&|\|\|)/ || /(&&|\|\|) *\S/) {
575 err
("more than one space around boolean operator");
577 if (/\b(for|if|while|switch|sizeof|return|case)\(/) {
578 err
("missing space between keyword and paren");
580 if (/(\b(for|if|while|switch|return)\b.*){2,}/ && !/^#define/) {
581 # multiple "case" and "sizeof" allowed
582 err
("more than one keyword on line");
584 if (/\b(for|if|while|switch|sizeof|return|case)\s\s+\(/ &&
586 err
("extra space between keyword and paren");
588 # try to detect "func (x)" but not "if (x)" or
589 # "#define foo (x)" or "int (*func)();"
592 # strip off all keywords on the line
593 s/\b(for|if|while|switch|return|case|sizeof)\s\(/XXX(/g;
595 s/^#define\s+\w+\s+\(/XXX(/;
596 # do not match things like "void (*f)();"
597 # or "typedef void (func_t)();"
599 s/\b($typename|void)\s+\(+/XXX(/og;
601 err
("extra space between function name and left paren");
605 # try to detect "int foo(x)", but not "extern int foo(x);"
606 # XXX - this still trips over too many legitimate things,
607 # like "int foo(x,\n\ty);"
608 # if (/^(\w+(\s|\*)+)+\w+\(/ && !/\)[;,](\s|\x01)*$/ &&
609 # !/^(extern|static)\b/) {
610 # err("return type of function not on separate line");
612 # this is a close approximation
613 if (/^(\w+(\s|\*)+)+\w+\(.*\)(\s|\x01)*$/ &&
614 !/^(extern|static)\b/) {
615 err
("return type of function not on separate line");
618 err
("#define followed by space instead of tab");
620 if (/^\s*return\W[^;]*;/ && !/^\s*return\s*\(.*\);/) {
621 err
("unparenthesized return expression");
623 if (/\bsizeof\b/ && !/\bsizeof\s*\(.*\)/) {
624 err
("unparenthesized sizeof expression");
627 err
("whitespace after left paren");
629 # Allow "for" statements to have empty "continue" clauses.
630 # Allow right paren on its own line unless we're being picky (-p).
631 if (/\s\)/ && !/^\s*for \([^;]*;[^;]*; \)/ && ($picky || !/^\s*\)/)) {
632 err
("whitespace before right paren");
634 if (/^\s*\(void\)[^ ]/) {
635 err
("missing space after (void) cast");
637 if (/\S\{/ && !/\{\{/) {
638 err
("missing space before left brace");
640 if ($in_function && /^\s+\{/ &&
641 ($prev =~ /\)\s*$/ || $prev =~ /\bstruct\s+\w+$/)) {
642 err
("left brace starting a line");
644 if (/\}(else|while)/) {
645 err
("missing space after right brace");
647 if (/\}\s\s+(else|while)/) {
648 err
("extra space after right brace");
650 if (/\b_VOID\b|\bVOID\b|\bSTATIC\b/) {
651 err
("obsolete use of VOID or STATIC");
653 if (/\b$typename\*/o) {
654 err
("missing space between type name and *");
657 err
("preprocessor statement not in column 1");
660 err
("blank after preprocessor #");
662 if (/!\s*(strcmp|strncmp|bcmp)\s*\(/) {
663 err
("don't use boolean ! with comparison functions");
667 # We completely ignore, for purposes of indentation:
668 # * lines outside of functions
669 # * preprocessor lines
671 if ($check_continuation && $in_function && !$in_cpp) {
675 # try to detect spaces after casts, but allow (e.g.)
676 # "sizeof (int) + 1", "void (*funcptr)(int) = foo;", and
677 # "int foo(int) __NORETURN;"
678 if ((/^\($typename( \*+)?\)\s/o ||
679 /\W\($typename( \*+)?\)\s/o) &&
680 !/sizeof\s*\($typename( \*)?\)\s/o &&
681 !/\($typename( \*+)?\)\s+=[^=]/o) {
682 err
("space after cast");
684 if (/\b$typename\s*\*\s/o &&
685 !/\b$typename\s*\*\s+const\b/o) {
686 err
("unary * followed by space");
689 if ($check_posix_types) {
690 # try to detect old non-POSIX types.
691 # POSIX requires all non-standard typedefs to end in _t,
692 # but historically these have been used.
693 if (/\b(unchar|ushort|uint|ulong|u_int|u_short|u_long|u_char|quad)\b/) {
694 err
("non-POSIX typedef $1 used: use $old2posix{$1} instead");
698 if ($prev =~ /^\s*\}$/) {
700 "else and right brace should be on same line");
707 err
("last line in file is blank");
713 # Continuation-line checking
715 # The rest of this file contains the code for the continuation checking
716 # engine. It's a pretty simple state machine which tracks the expression
717 # depth (unmatched '('s and '['s).
719 # Keep in mind that the argument to process_indent() has already been heavily
720 # processed; all comments have been replaced by control-A, and the contents of
721 # strings and character constants have been elided.
724 my $cont_in; # currently inside of a continuation
725 my $cont_off; # skipping an initializer or definition
726 my $cont_noerr; # suppress cascading errors
727 my $cont_start; # the line being continued
728 my $cont_base; # the base indentation
729 my $cont_first; # this is the first line of a statement
730 my $cont_multiseg; # this continuation has multiple segments
732 my $cont_special; # this is a C statement (if, for, etc.)
733 my $cont_macro; # this is a macro
734 my $cont_case; # this is a multi-line case
736 my @cont_paren; # the stack of unmatched ( and [s we've seen
749 # replace labels with tabs. Note that there may be multiple
754 while (/^(\t*)( *(?:(?:\w+\s*)|(?:case\b[^:]*)): *)(.*)$/) {
755 my ($pre_tabs, $label, $rest) = ($1, $2, $3);
757 while ($label =~ s/^([^\t]*)(\t+)//) {
758 $_ .= "\t" x
(length($2) + length($1) / 8);
760 $_ .= ("\t" x
(length($label) / 8)).$rest;
770 local $_ = $_[0]; # preserve the global $_
772 s/\x01//g; # No comments
773 s/\s+$//; # Strip trailing whitespace
775 return if (/^$/); # skip empty lines
777 # regexps used below; keywords taking (), macros, and continued cases
778 my $special = '(?:(?:\}\s*)?else\s+)?(?:if|for|while|switch)\b';
779 my $macro = '[A-Z_][A-Z_0-9]*\(';
780 my $case = 'case\b[^:]*$';
782 # skip over enumerations, array definitions, initializers, etc.
783 if ($cont_off <= 0 && !/^\s*$special/ &&
784 (/(?:(?:\b(?:enum|struct|union)\s*[^\{]*)|(?:\s+=\s*))\{/ ||
785 (/^\s*\{/ && $prev =~ /=\s*(?:\/\
*.*\
*\
/\s*)*$/))) {
787 $cont_off = tr/{/{/ - tr/}/}/;
791 $cont_off += tr/{/{/ - tr/}/}/;
799 err
("non-continuation indented 4 spaces");
800 $cont_noerr = 1; # stop reporting
802 $_ = delabel
($_); # replace labels with tabs
804 # check if the statement is complete
805 return if (/^\s*\}?$/);
806 return if (/^\s*\}?\s*else\s*\{?$/);
807 return if (/^\s*do\s*\{?$/);
809 return if (/\}[,;]?$/);
811 # Allow macros on their own lines
812 return if (/^\s*[A-Z_][A-Z_0-9]*$/);
814 # cases we don't deal with, generally non-kosher
816 err
("stuff after {");
820 # Get the base line, and set up the state machine
828 # certain things need special processing
829 $cont_special = /^\s*$special/?
1 : 0;
830 $cont_macro = /^\s*$macro/?
1 : 0;
831 $cont_case = /^\s*$case/?
1 : 0;
835 # Strings may be pulled back to an earlier (half-)tabstop
836 unless ($cont_noerr || /^$cont_base / ||
837 (/^\t*(?: )?(?:gettext\()?\"/ && !/^$cont_base\t/)) {
838 err_prefix
($cont_start,
839 "continuation should be indented 4 spaces");
843 my $rest = $_; # keeps the remainder of the line
846 # The split matches 0 characters, so that each 'special' character
847 # is processed separately. Parens and brackets are pushed and
848 # popped off the @cont_paren stack. For normal processing, we wait
849 # until a ; or { terminates the statement. "special" processing
850 # (if/for/while/switch) is allowed to stop when the stack empties,
851 # as is macro processing. Case statements are terminated with a :
852 # and an empty paren stack.
854 foreach $_ (split /[^\(\)\[\]\{\}\;\:]*/) {
855 next if (length($_) == 0);
857 # rest contains the remainder of the line
858 my $rxp = "[^\Q$_\E]*\Q$_\E";
862 push @cont_paren, $_;
863 } elsif (/\)/ || /\]/) {
867 my $old = (pop @cont_paren);
868 if (!defined($old)) {
869 err
("unexpected '$cur'");
872 } elsif ($old ne $_) {
873 err
("'$cur' mismatched with '$old'");
879 # If the stack is now empty, do special processing
880 # for if/for/while/switch and macro statements.
882 next if (@cont_paren != 0);
884 if ($rest =~ /^\s*\{?$/) {
888 if ($rest =~ /^\s*;$/) {
889 err
("empty if/for/while body ".
890 "not on its own line");
894 if (!$cont_first && $cont_multiseg == 1) {
895 err_prefix
($cont_start,
896 "multiple statements continued ".
897 "over multiple lines");
899 } elsif ($cont_multiseg == 0) {
902 # We've finished this section, start
903 # processing the next.
915 } elsif (!$cont_special) {
916 err
("unexpected ;") if (@cont_paren != 0);
917 if (!$cont_first && $cont_multiseg == 1) {
918 err_prefix
($cont_start,
919 "multiple statements continued ".
920 "over multiple lines");
922 } elsif ($cont_multiseg == 0) {
929 if ($rest =~ /^\s*special/) {
930 err
("if/for/while/switch not started ".
936 err
("{ while in parens/brackets") if (@cont_paren != 0);
937 err
("stuff after {") if ($rest =~ /[^\s}]/);
941 err
("} while in parens/brackets") if (@cont_paren != 0);
942 if (!$cont_special && $rest !~ /^\s*(while|else)\b/) {
946 err
("stuff after }");
951 } elsif (/\:/ && $cont_case && @cont_paren == 0) {
952 err
("stuff after multi-line case") if ($rest !~ /$^/);
958 # End of a statement or if/while/for loop. Reset
959 # cont_special and cont_macro based on the rest of the
961 $cont_special = ($rest =~ /^\s*$special/)?
1 : 0;
962 $cont_macro = ($rest =~ /^\s*$macro/)?
1 : 0;
966 $cont_noerr = 0 if (!$cont_in);