Lines Matching +full:sub +full:- +full:spaces
5 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
40 sub help {
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
292 # This can be modified by sub possible. Since it can be empty, be careful
297 sub build_types {
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 '-') {
410 sub top_of_kernel_tree {
419 if (! -e $root . '/' . $check) {
426 sub expand_tabs {
446 sub copy_spacing {
451 sub line_stats {
466 sub sanitise_line_reset {
475 sub sanitise_line {
563 sub ctx_statement_block {
565 my $line = $linenr - 1;
568 my $coff = $off - 1;
582 @stack = (['', 0]) if ($#stack == -1);
590 next if ($lines[$line] =~ /^-/);
591 $remain--;
614 ($type, $level) = @{$stack[$#stack - 1]};
630 $coff = $off + length($1) - 1;
633 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
641 $level--;
655 $level--;
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);
686 sub statement_lines {
699 sub statement_rawlines {
707 sub statement_block_size {
729 sub ctx_statement_full {
740 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
750 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
758 sub ctx_block_get {
761 my $start = $linenr - 1;
770 next if ($rawlines[$line] =~ /^-/);
771 $remain--;
779 $level = $stack[$#stack - 1];
787 $off--;
792 $level--;
808 sub ctx_block_outer {
814 sub ctx_block {
820 sub ctx_statement {
826 sub ctx_block_level {
831 sub ctx_statement_level {
837 sub ctx_locate_comment {
841 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
849 my $line = $rawlines[$linenr - 1];
869 sub ctx_has_comment {
873 ##print "LINE: $rawlines[$end_line - 1 ]\n";
879 sub raw_line {
882 my $offset = $linenr - 1;
888 next if (defined($line) && $line =~ /^-/);
889 $cnt--;
895 sub cat_vet {
917 sub annotate_reset {
924 sub annotate_values {
1037 print "PAREN('$1') -> $type\n"
1093 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
1108 if ($1 ne '++' && $1 ne '--') {
1124 sub possible {
1172 sub report {
1197 sub report_dump {
1200 sub ERROR {
1206 sub WARN {
1213 # According to tests/qtest/bios-tables-test.c: do not
1215 sub checkfilename {
1224 } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
1230 "tests/qtest/bios-tables-test.c: both " .
1236 sub process {
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@"[^"]*(?:/\*|\*/)[^"]*"@) {
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)
1535 # check for spaces before a quoted newline
1557 $rawline =~ m@^\+.*/\*[*-]?+[ \t]*[^ \t]@) { # /* or /** or /*- non-blank
1613 (!defined $lines[$realline_next - 1] ||
1614 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
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");
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);
1880 # '*'s should not have spaces between.
1895 # '*'s should not have spaces between.
1898 # Modifiers should have spaces.
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);
1935 # check for spaces between functions and their parentheses.
1938 my $ctx_before = substr($line, 0, $-[1]);
1941 # Ignore those directives where spaces _are_ permitted.
1952 # cpp #define statements have non-optional spaces, ie
1972 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
1973 =>|->|<<|>>|<|>|=|!|~|
1974 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
2049 # No spaces for:
2050 # ->
2052 } elsif ($op eq '->' || $opv eq ':B') {
2054 ERROR("spaces prohibited around that '$op' $at\n" . $hereptr);
2065 # '*' as part of a type definition -- reported already.
2073 $opv eq '*U' || $opv eq '-U' ||
2078 } elsif ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2088 # unary ++ and unary -- are allowed no space on one side.
2089 } elsif ($op eq '++' or $op eq '--') {
2101 # A colon needs no spaces before when it is
2108 # All the others need spaces both sides.
2140 ERROR("spaces required around that '$op' $at\n" . $hereptr);
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*
2303 #no spaces allowed after \ in define
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";
2337 # rip off surrounding spaces, and trailing \'s.
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.
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*)$/) {
2492 ctx_statement_full($linenr, $realcnt, $-[0]);
2516 # Check the post-context.
2523 print "APW: ALLOWED: chunk-1 block<$block>\n"
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");