Lines Matching +full:sub +full:- +full:spaces
5 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
42 sub help {
49 $P [OPTION]... [GIT-REV-LIST]
54 -q, --quiet quiet
55 --no-tree run without a qemu tree
56 --no-signoff do not check for 'Signed-off-by' line
57 --patch treat FILE as patchfile
58 --branch treat args as GIT revision list
59 --emacs emacs compile window format
60 --terse one line per report
61 -f, --file treat FILE as regular source file
62 --strict fail if only warnings are found
63 --root=PATH PATH to the qemu tree root
64 --no-summary suppress the per-file summary
65 --mailback only produce a report in case of warnings/errors
66 --summary-file include the filename in summary
67 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
70 --test-only=WORD report only warnings/errors containing WORD
72 --codespell Use the codespell dictionary for spelling/typos
74 --codespellfile Use this codespell dictionary
75 --color[=WHEN] Use colors 'always', 'never', or only when output
77 -h, --help, --version display this help and exit
79 When FILE is - read standard input.
86 # Prevent --color by itself from consuming other arguments
88 if ($_ eq "--color" || $_ eq "-color") {
89 $_ = "--color=$color";
106 'summary-file!' => \$summary_file,
108 'test-only=s' => \$tst_only,
112 'no-color' => sub { $color = 'never'; },
120 } elsif (!(-f $codespellfile)) {
133 my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`;
134 $codespellfile = $codespell_dict if (-f $codespell_dict);
183 die "Only one of --file, --branch, --patch is permitted\n";
186 die "One of --file, --branch, --patch is required\n";
194 $color = (-t STDOUT);
222 die "$P: $root: --root does not point at a valid tree\n";
234 print "Must be run from the top-level dir. of a qemu tree\n";
242 [A-Za-z_][A-Za-z\d_]*
243 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
262 our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
265 our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*};
266 our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
270 =>|->|<<|>>|<|>|!|~|
271 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
279 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
280 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
281 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
282 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
283 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
284 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
285 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
289 [\x09\x0A\x0D\x20-\x7E] # ASCII
293 # some readers default to ISO-8859-1 when showing email source. detect
294 # when UTF-8 is incorrectly interpreted as ISO-8859-1 and reencoded back.
297 \xC3[\x82-\x9F] \xC2[\x80-\xBF] # c2-df 80-bf
298 | \xC3\xA0 \xC2[\xA0-\xBF] \xC2[\x80-\xBF] # e0 a0-bf 80-bf
299 | \xC3[\xA1-\xAC\xAE\xAF] (?: \xC2[\x80-\xBF]){2} # e1-ec/ee/ef 80-bf 80-bf
300 | \xC3\xAD \xC2[\x80-\x9F] \xC2[\x80-\xBF] # ed 80-9f 80-bf
301 | \xC3\xB0 \xC2[\x90-\xBF] (?: \xC2[\x80-\xBF]){2} # f0 90-bf 80-bf 80-bf
302 | \xC3[\xB1-\xB3] (?: \xC2[\x80-\xBF]){3} # f1-f3 80-bf 80-bf 80-bf
303 | \xC3\xB4 \xC2[\x80-\x8F] (?: \xC2[\x80-\xBF]){2} # f4 80-b8 80-bf 80-bf
310 [A-Z][A-Z\d_]*[a-z][A-Za-z\d_]* # camelcase
311 | [A-Z][A-Z\d_]*AIOCB # all uppercase
312 | [A-Z][A-Z\d_]*CPU # all uppercase
386 my ($suspect, $fix) = split(/->/, $line);
392 warn "No codespell typos will be found - file '$codespellfile': $!\n";
398 # This can be modified by sub possible. Since it can be empty, be careful
403 sub build_types {
438 …open($HASH, "-|", "git", "log", "--reverse", "--no-merges", "--no-mailmap", "--format=%H %s", $ARG…
439 die "$P: git log --reverse --no-merges --no-mailmap --format='%H %s' $ARGV[0] failed - $!\n";
442 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
459 open($FILE, '-|', "git",
460 "-c", "diff.renamelimit=0",
461 "-c", "diff.renames=True",
462 "-c", "diff.algorithm=histogram",
463 "show", "--no-mailmap",
464 "--patch-with-stat", $hash) ||
465 die "$P: git show $hash - $!\n";
492 open($FILE, '-|', "diff -u /dev/null $filename") ||
493 die "$P: $filename: diff failed - $!\n";
494 } elsif ($filename eq '-') {
498 die "$P: $filename: open failed - $!\n";
500 if ($filename eq '-') {
521 sub top_of_kernel_tree {
527 "linux-user", "system"
531 if (! -e $root . '/' . $check) {
538 sub which {
542 if (-e "$path/$bin") {
550 sub expand_tabs {
570 sub copy_spacing {
575 sub line_stats {
590 sub sanitise_line_reset {
599 sub sanitise_line {
687 sub ctx_statement_block {
689 my $line = $linenr - 1;
692 my $coff = $off - 1;
706 @stack = (['', 0]) if ($#stack == -1);
714 next if ($lines[$line] =~ /^-/);
715 $remain--;
738 ($type, $level) = @{$stack[$#stack - 1]};
754 $coff = $off + length($1) - 1;
757 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
765 $level--;
779 $level--;
795 $remain--;
798 my $statement = substr($blk, $soff, $off - $soff + 1);
799 my $condition = substr($blk, $soff, $coff - $soff + 1);
807 $line, $remain + 1, $off - $loff + 1, $level);
810 sub statement_lines {
823 sub statement_rawlines {
831 sub statement_block_size {
853 sub ctx_statement_full {
864 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
874 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
882 sub ctx_block_get {
885 my $start = $linenr - 1;
894 next if ($rawlines[$line] =~ /^-/);
895 $remain--;
903 $level = $stack[$#stack - 1];
911 $off--;
916 $level--;
932 sub ctx_block_outer {
938 sub ctx_block {
944 sub ctx_statement {
950 sub ctx_block_level {
955 sub ctx_statement_level {
961 sub ctx_locate_comment {
965 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
973 my $line = $rawlines[$linenr - 1];
993 sub ctx_has_comment {
997 ##print "LINE: $rawlines[$end_line - 1 ]\n";
1003 sub raw_line {
1006 my $offset = $linenr - 1;
1012 next if (defined($line) && $line =~ /^-/);
1013 $cnt--;
1019 sub cat_vet {
1041 sub annotate_reset {
1048 sub annotate_values {
1161 print "PAREN('$1') -> $type\n"
1217 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
1232 if ($1 ne '++' && $1 ne '--') {
1248 sub possible {
1296 sub report {
1317 sub report_dump {
1320 sub ERROR {
1326 sub WARN {
1333 # According to tests/qtest/bios-tables-test.c: do not
1335 sub checkfilename {
1344 } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
1350 "tests/qtest/bios-tables-test.c: both " .
1356 sub checkspdx {
1361 if ($file =~ m,include/standard-headers, ||
1362 $file =~ m,linux-headers,) {
1368 # Flatten sub-expressions
1373 $expr =~ s/\s+WITH\s+/-WITH-/g;
1381 my $prefer = "GPL-2.0-or-later";
1383 LGPL-2.0-or-later
1384 LGPL-2.1-or-later
1385 GPL-2.0-only
1386 LGPL-2.0-only
1387 LGPL-2.0-only
1388 BSD-2-Clause
1389 BSD-3-Clause
1417 sub process {
1471 # Pre-scan the patch sanitizing the lines.
1479 if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
1480 $realline=$1-1;
1495 next if (defined $rawlines[$ln - 1] &&
1496 $rawlines[$ln - 1] =~ /^-/);
1497 $cnt--;
1498 #print "RAW<$rawlines[$ln - 1]>\n";
1499 last if (!defined $rawlines[$ln - 1]);
1500 if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
1501 $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
1524 # simplify matching -- only bother with positive lines.
1530 $realcnt-- if ($line =~ /^(?:\+| |$)/);
1536 #print "-->$line\n";
1546 my $rawline = $rawlines[$linenr - 1];
1549 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
1552 $realline=$1-1;
1571 $realcnt-- if ($realcnt != 0);
1584 $realcnt--;
1597 if ($line =~ /^diff --git.*?(\S+)$/) {
1608 -e "$root/$p1_prefix") {
1609 WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
1638 if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) {
1642 if ($line =~ /^(Author|From): .* via .*<qemu-\w+\@nongnu\.org>/) {
1647 if ($line =~ /^\s*signed-off-by:/i) {
1652 if (!($line =~ /^\s*Signed-off-by:/)) {
1653 ERROR("The correct form is \"Signed-off-by\"\n" .
1656 if ($line =~ /^\s*signed-off-by:\S/i) {
1657 ERROR("space required after Signed-off-by:\n" .
1671 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
1672 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
1681 # All new files should have a SPDX-License-Identifier tag
1686 ERROR("expected 'SPDX-License-Identifer' in new file $expect_spdx_file");
1689 WARNING("Does new file $expect_spdx_file need 'SPDX-License-Identifer'?");
1699 if ($rawline =~ /SPDX-License-Identifier/) {
1705 # Check SPDX-License-Identifier references a permitted license
1706 if ($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) {
1710 if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
1713 SPDX-License-Identifier
1723 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
1728 # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
1737 ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
1741 ERROR("Doubly-encoded UTF-8\n" . $herecurr);
1747 $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
1752 # Check if there is UTF-8 in a commit log when a mail header has explicitly
1755 $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
1756 $1 !~ /utf-8/i) {
1762 WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);
1768 while ($rawline =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
1771 my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
1774 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
1775 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
1776 WARN("'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $hereptr);
1780 # ignore non-hunk lines and lines being removed
1781 next if (!$hunk_line || $line =~ /^-/);
1784 if ($realfile =~ /^(linux-headers|include\/standard-headers)\//) {
1788 "scripts/update-linux-headers.sh?\n" .
1798 ERROR("headers imported from Linux should be self-" .
1805 next if ($realfile =~ /^(linux-headers|include\/standard-headers)\//);
1816 # (surrounding text is 4-column aligned)
1828 # checks for trace-events files
1829 if ($realfile =~ /trace-events$/ && $line =~ /^\+/) {
1830 if ($rawline =~ /%[-+ 0]*#/) {
1832 "trace-events, use '0x' prefix instead\n" . $herecurr);
1835 qr/%[-+ *.0-9]*([hljztL]|ll|hh)?(x|X|"\s*PRI[xX][^"]*"?)/;
1864 # check for spaces before a quoted newline
1900 if ($commentline =~ m@^\+.*/\*\*?+[ \t]*[^ \t]@) { # /* or /** non-blank
1956 (!defined $lines[$realline_next - 1] ||
1957 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
2040 my $ctx_cnt = $realcnt - $#ctx - 1;
2047 defined $lines[$ctx_ln - 1] &&
2048 $lines[$ctx_ln - 1] =~ /^-/)) {
2050 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
2055 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
2062 defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/ &&
2063 defined($lines[$ctx_ln - 2]) && length($lines[$ctx_ln - 2]) < 80) {
2065 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
2069 defined $lines[$ctx_ln - 1])
2071 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
2074 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
2096 # none on the first line, and are going to re-add them
2128 my $cond_ptr = -1;
2186 $prev_values = substr($curr_values, -1);
2231 $rawline !~ m{// SPDX-License-Identifier: }) {
2258 # '*'s should not have spaces between.
2273 # '*'s should not have spaces between.
2276 # Modifiers should have spaces.
2304 # 1. with a type on the left -- int [] a;
2305 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
2306 # 3. inside a curly brace -- = { [0...10] = 5 }
2307 # 4. after a comma -- [1] = 5, [2] = 6
2308 # 5. in a macro definition -- #define abc(x) [x] = y
2310 my ($where, $prefix) = ($-[1], $1);
2319 # check for spaces between functions and their parentheses.
2322 my $ctx_before = substr($line, 0, $-[1]);
2325 # Ignore those directives where spaces _are_ permitted.
2336 # cpp #define statements have non-optional spaces, ie
2356 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
2357 =>|->|<<|>>|<|>|=|!|~|
2358 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
2433 # No spaces for:
2434 # ->
2436 } elsif ($op eq '->' || $opv eq ':B') {
2438 ERROR("spaces prohibited around that '$op' $at\n" . $hereptr);
2449 # '*' as part of a type definition -- reported already.
2457 $opv eq '*U' || $opv eq '-U' ||
2462 } elsif ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2472 # unary ++ and unary -- are allowed no space on one side.
2473 } elsif ($op eq '++' or $op eq '--') {
2485 # A colon needs no spaces before when it is
2492 # All the others need spaces both sides.
2524 ERROR("spaces required around that '$op' $at\n" . $hereptr);
2571 $value !~ /(?:$Ident|-?$Constant)\s*
2573 (?:$Ident|-?$Constant)/x &&
2577 if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/ &&
2585 # Return of what appears to be an errno should normally be -'ve
2586 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
2589 ERROR("return of an errno should typically be -ve (return -$1)\n" . $herecurr);
2603 # Check for illegal assignment in if conditional -- and check for trailing
2615 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
2617 statement_rawlines($whitespace) - 1;
2658 \s*0[xX][0-9]+\s*
2662 \s*0[xX][0-9]+\s*
2714 # if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) {
2720 #no spaces allowed after \ in define
2725 # multi-statement macros should be enclosed in a do while loop, grab the
2739 while ($cnt > 0 && defined $lines[$ln - 1] &&
2740 $lines[$ln - 1] =~ /^(?:-|..*\\$)/)
2742 $ctx .= $rawlines[$ln - 1] . "\n";
2743 $cnt-- if ($lines[$ln - 1] !~ /^-/);
2746 $ctx .= $rawlines[$ln - 1];
2749 ctx_statement_block($linenr, $ln - $linenr + 1, 0);
2751 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
2754 # rip off surrounding spaces, and trailing \'s.
2757 #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n";
2758 if ($off != 0 || $lines[$ln - 1] !~ /^-/) {
2759 $rest .= substr($lines[$ln - 1], $off) . "\n";
2760 $cnt--;
2804 …ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n…
2809 $dstat !~ /^(?:$Ident|-?$Constant)$/ &&
2824 # Check the pre-context.
2844 my $ln = $linenr - 1;
2849 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
2850 my $offset = statement_rawlines($whitespace) - 1;
2858 $ln += statement_rawlines($block) - 1;
2890 if (!defined $suppress_ifbraces{$linenr - 1} &&
2896 # Check the pre-context.
2897 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
2908 ctx_statement_full($linenr, $realcnt, $-[0]);
2932 # Check the post-context.
2939 print "APW: ALLOWED: chunk-1 block<$block>\n"
3089 # check for module_init(), use category-specific init macros explicitly please
3108 Spice[A-Z][a-zA-Z0-9]*Interface|
3110 USBDesc[A-Z][a-zA-Z0-9]*|
3123 $string = substr($rawline, $-[1], $+[1] - $-[1]);
3127 ERROR("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
3129 # check for %# or %0# in printf-style format strings
3176 my $i = $linenr - 2;
3179 $i--;
3187 # check for non-portable libc calls that have portable alternatives in QEMU
3240 ERROR("Missing Signed-off-by: line(s)\n");
3245 if ($#rawlines == -1) {
3255 # This is not a patch, and we are are in 'no-patch' mode so
3261 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
3262 ERROR("Does not appear to be a unified-diff format patch\n");