check-format.pl: Allow nested indentation of labels (not only at line pos 1)

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13019)
This commit is contained in:
Dr. David von Oheimb 2020-09-28 09:18:01 +02:00
parent 8e655da022
commit 13a574d8bb
3 changed files with 10 additions and 2 deletions

View File

@ -282,10 +282,17 @@ static void *fun(void)
/* comment */
return NULL;
label0:
label1: /* allow special indent 1 for label at outermost level in body */
do {
label2:
size_t available_len, data_len;
const char *curr = txt, *next = txt;
char *tmp;
{
label3:
}
} while (1);
char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";

View File

@ -117,7 +117,9 @@ int f (int a, /*@ space after fn before '(', reported unless sloppy-spc */
do f(c, c); /*@ (non-brace) code after 'do' */
while ( 2); /*@ space after '(', reported unless sloppy-spc */
b; c; /*@ more than one statement per line */
outer: /*@ outer label special indent off by 1 */
do{ /*@ no space before '{', reported unless sloppy-spc */
inner: /*@ inner label normal indent off by 1 */
f (3, /*@ space after fn before '(', reported unless sloppy-spc */
4); /*@0 false negative: should report single stmt in braces */
} /*@0 'while' not on same line as preceding '}' */
@ -127,7 +129,6 @@ int f (int a, /*@ space after fn before '(', reported unless sloppy-spc */
case(2): /*@ no space after 'case', reported unless sloppy-spc */
default: ; /*@ code after 'default:' */
} /*@ statement indent off by -4 */
label: /*@ label special statement indent off by 1 */
return( /*@ no space after 'return', reported unless sloppy-spc */
x); } /*@ code before block-level '}' */
/* Here the tool should stop complaining apart from the below issues at EOF */

View File

@ -798,7 +798,7 @@ while (<>) { # loop over all lines of all input files
$local_offset = -INDENT_LEVEL;
} else {
if (m/^([\s@]*)(\w+):/) { # (leading) label, cannot be "default"
$local_offset = -INDENT_LEVEL + 1 ;
$local_offset = -INDENT_LEVEL;
$has_label = 1;
}
}