Lines Matching +full:eq +full:- +full:level
5 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
47 $P [OPTION]... [GIT-REV-LIST]
52 -q, --quiet quiet
53 --patch treat FILE as patchfile
54 --branch treat args as GIT revision list
55 --emacs emacs compile window format
56 --terse one line per report
57 -f, --file treat FILE as regular source file
58 --strict fail if only warnings are found
59 --no-summary suppress the per-file summary
60 --mailback only produce a report in case of warnings/errors
61 --summary-file include the filename in summary
62 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
65 --test-only=WORD report only warnings/errors containing WORD
67 --color[=WHEN] Use colors 'always', 'never', or only when output
69 -h, --help, --version display this help and exit
71 When FILE is - read standard input.
81 # Prevent --color by itself from consuming other arguments
83 if ($_ eq "--color" || $_ eq "-color") {
84 $_ = "--color=$color";
102 'summary-file!' => \$summary_file,
105 'test-only=s' => \$tst_only,
107 'no-color' => sub { $color = 'never'; },
157 die "Only one of --file, --branch, --patch is permitted\n";
160 die "One of --file, --branch, --patch is required\n";
168 $color = (-t STDOUT);
194 [A-Za-z_][A-Za-z\d_]*
195 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
215 our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
218 our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*};
219 our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
223 =>|->|<<|>>|<|>|!|~|
224 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
232 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
233 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
234 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
235 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
236 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
237 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
238 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
242 [\x09\x0A\x0D\x20-\x7E] # ASCII
246 # some readers default to ISO-8859-1 when showing email source. detect
247 # when UTF-8 is incorrectly interpreted as ISO-8859-1 and reencoded back.
250 \xC3[\x82-\x9F] \xC2[\x80-\xBF] # c2-df 80-bf
251 | \xC3\xA0 \xC2[\xA0-\xBF] \xC2[\x80-\xBF] # e0 a0-bf 80-bf
252 | \xC3[\xA1-\xAC\xAE\xAF] (?: \xC2[\x80-\xBF]){2} # e1-ec/ee/ef 80-bf 80-bf
253 | \xC3\xAD \xC2[\x80-\x9F] \xC2[\x80-\xBF] # ed 80-9f 80-bf
254 | \xC3\xB0 \xC2[\x90-\xBF] (?: \xC2[\x80-\xBF]){2} # f0 90-bf 80-bf 80-bf
255 | \xC3[\xB1-\xB3] (?: \xC2[\x80-\xBF]){3} # f1-f3 80-bf 80-bf 80-bf
256 | \xC3\xB4 \xC2[\x80-\x8F] (?: \xC2[\x80-\xBF]){2} # f4 80-b8 80-bf 80-bf
263 [A-Z][A-Z\d_]*[a-z][A-Za-z\d_]* # camelcase
264 | [A-Z][A-Z\d_]*AIOCB # all uppercase
265 | [A-Z][A-Z\d_]*CPU # all uppercase
332 open($HASH, "-|", "git", "log", "--reverse", "--no-merges", "--format=%H %s", $ARGV[0]) ||
333 die "$P: git log --reverse --no-merges --format='%H %s' $ARGV[0] failed - $!\n";
336 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
353 open($FILE, '-|', "git", "show", "--patch-with-stat", $hash) ||
354 die "$P: git show $hash - $!\n";
381 open($FILE, '-|', "diff -u /dev/null $filename") ||
382 die "$P: $filename: diff failed - $!\n";
383 } elsif ($filename eq '-') {
387 die "$P: $filename: open failed - $!\n";
389 if ($filename eq '-') {
419 if (! -e $root . '/' . $check) {
432 if ($c eq "\t") {
493 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
500 if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
506 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
515 if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
516 $c eq "\\") {
522 if ($c eq "'" || $c eq '"') {
523 if ($sanitise_quote eq '') {
528 } elsif ($sanitise_quote eq $c) {
534 if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
536 } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
545 if ($sanitise_quote eq '//') {
565 my $line = $linenr - 1;
568 my $coff = $off - 1;
574 my $level = 0;
582 @stack = (['', 0]) if ($#stack == -1);
590 next if ($lines[$line] =~ /^-/);
591 $remain--;
608 #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n";
612 push(@stack, [ $type, $level ]);
614 ($type, $level) = @{$stack[$#stack - 1]};
616 ($type, $level) = @{pop(@stack)};
620 # outermost level.
621 if ($level == 0 && $c eq ';') {
626 if ($level == 0 && $coff_set == 0 &&
630 $coff = $off + length($1) - 1;
633 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
636 if (($type eq '' || $type eq '(') && $c eq '(') {
637 $level++;
640 if ($type eq '(' && $c eq ')') {
641 $level--;
642 $type = ($level != 0)? '(' : '';
644 if ($level == 0 && $coff < $soff) {
650 if (($type eq '' || $type eq '{') && $c eq '{') {
651 $level++;
654 if ($type eq '{' && $c eq '}') {
655 $level--;
656 $type = ($level != 0)? '{' : '';
658 if ($level == 0) {
659 if (substr($blk, $off + 1, 1) eq ';') {
671 $remain--;
674 my $statement = substr($blk, $soff, $off - $soff + 1);
675 my $condition = substr($blk, $soff, $coff - $soff + 1);
683 $line, $remain + 1, $off - $loff + 1, $level);
731 my ($statement, $condition, $level);
736 ($statement, $condition, $linenr, $remain, $off, $level) =
740 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
741 return ($level, $linenr, @chunks);
747 ($statement, $condition, $linenr, $remain, $off, $level) =
750 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
755 return ($level, $linenr, @chunks);
761 my $start = $linenr - 1;
767 my $level = 0;
768 my @stack = ($level);
770 next if ($rawlines[$line] =~ /^-/);
771 $remain--;
777 push(@stack, $level);
779 $level = $stack[$#stack - 1];
781 $level = pop(@stack);
785 ##print "C<$c>L<$level><$open$close>O<$off>\n";
787 $off--;
791 if ($c eq $close && $level > 0) {
792 $level--;
793 last if ($level == 0);
794 } elsif ($c eq $open) {
795 $level++;
799 if (!$outer || $level <= 1) {
803 last if ($level == 0);
806 return ($level, @res);
811 my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0);
817 my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0);
823 my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off);
841 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
849 my $line = $rawlines[$linenr - 1];
873 ##print "LINE: $rawlines[$end_line - 1 ]\n";
882 my $offset = $linenr - 1;
888 next if (defined($line) && $line =~ /^-/);
889 $cnt--;
944 } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
1037 print "PAREN('$1') -> $type\n"
1049 if (defined $2 && $type eq 'C' || $type eq 'T') {
1051 } elsif ($type eq 'E') {
1082 if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') {
1093 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
1097 if ($type eq 'V') {
1108 if ($1 ne '++' && $1 ne '--') {
1173 my ($level, $msg) = @_;
1181 $output .= "::error " if $github && $level eq 'ERROR';
1182 $output .= "::warning " if $github && $level eq 'WARNING';
1184 $output .= RED if $do_color && $level eq 'ERROR';
1185 $output .= MAGENTA if $do_color && $level eq 'WARNING';
1186 $output .= $level . ':' if !$github;
1213 # According to tests/qtest/bios-tables-test.c: do not
1224 } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
1230 "tests/qtest/bios-tables-test.c: both " .
1284 # Pre-scan the patch sanitizing the lines.
1292 if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
1293 $realline=$1-1;
1308 next if (defined $rawlines[$ln - 1] &&
1309 $rawlines[$ln - 1] =~ /^-/);
1310 $cnt--;
1311 #print "RAW<$rawlines[$ln - 1]>\n";
1312 last if (!defined $rawlines[$ln - 1]);
1313 if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
1314 $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
1319 if (defined $edge && $edge eq '*/') {
1337 # simplify matching -- only bother with positive lines.
1343 $realcnt-- if ($line =~ /^(?:\+| |$)/);
1349 #print "-->$line\n";
1359 my $rawline = $rawlines[$linenr - 1];
1362 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
1365 $realline=$1-1;
1384 $realcnt-- if ($realcnt != 0);
1397 $realcnt--;
1412 if ($line =~ /^diff --git.*?(\S+)$/) {
1423 -e "$root/$p1_prefix") {
1424 WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
1447 if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) {
1452 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
1457 # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
1466 ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
1470 ERROR("Doubly-encoded UTF-8\n" . $herecurr);
1476 $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
1481 # Check if there is UTF-8 in a commit log when a mail header has explicitly
1484 $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
1485 $1 !~ /utf-8/i) {
1491 WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);
1494 # ignore non-hunk lines and lines being removed
1495 next if (!$hunk_line || $line =~ /^-/);
1506 # (surrounding text is 4-column aligned)
1557 $rawline =~ m@^\+.*/\*[*-]?+[ \t]*[^ \t]@) { # /* or /** or /*- non-blank
1613 (!defined $lines[$realline_next - 1] ||
1614 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
1630 …} elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Id…
1648 …if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$I…
1696 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
1697 my $ctx_cnt = $realcnt - $#ctx - 1;
1704 defined $lines[$ctx_ln - 1] &&
1705 $lines[$ctx_ln - 1] =~ /^-/)) {
1707 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
1712 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
1719 defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/ &&
1720 defined($lines[$ctx_ln - 2]) && length($lines[$ctx_ln - 2]) < 80) {
1722 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
1724 if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
1726 defined $lines[$ctx_ln - 1])
1728 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
1731 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
1753 # none on the first line, and are going to re-add them
1785 my $cond_ptr = -1;
1843 $prev_values = substr($curr_values, -1);
1920 # 1. with a type on the left -- int [] a;
1921 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
1922 # 3. inside a curly brace -- = { [0...10] = 5 }
1923 # 4. after a comma -- [1] = 5, [2] = 6
1924 # 5. in a macro definition -- #define abc(x) [x] = y
1926 my ($where, $prefix) = ($-[1], $1);
1938 my $ctx_before = substr($line, 0, $-[1]);
1952 # cpp #define statements have non-optional spaces, ie
1972 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
1973 =>|->|<<|>>|<|>|=|!|~|
1974 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
1998 $a = 'O' if ($elements[$n] eq '');
2009 $c = 'O' if ($elements[$n + 2] eq '');
2036 } elsif ($op eq ';') {
2043 } elsif ($op eq '//') {
2046 } elsif ($opv eq ':B' && $ctx =~ /Wx[WE]/ &&
2050 # ->
2052 } elsif ($op eq '->' || $opv eq ':B') {
2059 } elsif ($op eq ',') {
2065 # '*' as part of a type definition -- reported already.
2066 } elsif ($opv eq '*_') {
2072 } elsif ($op eq '!' || $op eq '~' ||
2073 $opv eq '*U' || $opv eq '-U' ||
2074 $opv eq '&U' || $opv eq '&&U') {
2075 if ($op eq '~' && $ca =~ /::$/ && $realfile =~ /\.(cpp|h|hpp|cc|hh)$/) {
2078 } elsif ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2081 if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
2088 # unary ++ and unary -- are allowed no space on one side.
2089 } elsif ($op eq '++' or $op eq '--') {
2103 } elsif ($opv eq ':C' || $opv eq ':L') {
2114 if (($op eq '<' || $op eq '>') && $line =~ /<.*>/) {
2119 if ($op eq '::') {
2125 if (($op eq '<' &&
2127 ($op eq '>' &&
2134 if (($opv eq ':O' && $ca =~ /\?$/) ||
2135 ($op eq '?' && $cc =~ /^:/)) {
2193 # Check for illegal assignment in if conditional -- and check for trailing
2205 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
2207 statement_rawlines($whitespace) - 1;
2248 \s*0[xX][0-9]+\s*
2252 \s*0[xX][0-9]+\s*
2283 # indent level to be relevant to each other.
2308 # multi-statement macros should be enclosed in a do while loop, grab the
2322 while ($cnt > 0 && defined $lines[$ln - 1] &&
2323 $lines[$ln - 1] =~ /^(?:-|..*\\$)/)
2325 $ctx .= $rawlines[$ln - 1] . "\n";
2326 $cnt-- if ($lines[$ln - 1] !~ /^-/);
2329 $ctx .= $rawlines[$ln - 1];
2332 ctx_statement_block($linenr, $ln - $linenr + 1, 0);
2334 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
2340 #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n";
2341 if ($off != 0 || $lines[$ln - 1] !~ /^-/) {
2342 $rest .= substr($lines[$ln - 1], $off) . "\n";
2343 $cnt--;
2387 …ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n…
2392 $dstat !~ /^(?:$Ident|-?$Constant)$/ &&
2407 # Check the pre-context.
2417 my ($level, $endln, @chunks) =
2420 … print "APW: chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n";
2424 if ($#chunks >= 0 && $level == 0) {
2427 my $ln = $linenr - 1;
2432 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
2433 my $offset = statement_rawlines($whitespace) - 1;
2441 $ln += statement_rawlines($block) - 1;
2474 if (!defined $suppress_ifbraces{$linenr - 1} &&
2480 # Check the pre-context.
2481 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
2491 my ($level, $endln, @chunks) =
2492 ctx_statement_full($linenr, $realcnt, $-[0]);
2516 # Check the post-context.
2523 print "APW: ALLOWED: chunk-1 block<$block>\n"
2528 print "DCS: level=$level block<$block> allowed=$allowed\n"
2530 if ($level == 0 && $block !~ /^\s*\{/ && !$allowed) {
2605 $string = substr($rawline, $-[1], $+[1] - $-[1]);
2609 ERROR("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
2624 my $i = $linenr - 2;
2627 $i--;
2635 if ($#rawlines == -1) {
2645 # This is not a patch, and we are are in 'no-patch' mode so
2651 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
2652 ERROR("Does not appear to be a unified-diff format patch\n");