Lines Matching +full:1 +full:- +full:9 +full:a +full:- +full:f
2 # SPDX-License-Identifier: GPL-2.0
4 # Clean a patch file -- or directory of patch files -- of stealth whitespace.
5 # WARNING: this can be a highly destructive operation. Use with caution.
15 # Clean up space-tab sequences, either by removing spaces or
28 $c = substr($li, $i, 1);
31 my $ntab = ($npos >> 3) - ($pos >> 3);
55 # Compute the visual width of a string
65 $c = substr($li,$i,1);
84 while (defined($a = shift(@ARGV))) {
85 if ($a =~ /^-/) {
86 if ($a eq '-width' || $a eq '-w') {
89 print STDERR "Usage: $name [-width #] files...\n";
90 exit 1;
93 push(@files, $a);
97 foreach $f ( @files ) {
98 print STDERR "$name: $f\n";
100 if (! -f $f) {
101 print STDERR "$f: not a file\n";
105 if (!open(FILE, '+<', $f)) {
106 print STDERR "$name: Cannot open file: $f: $!\n";
112 # First, verify that it is not a binary file; consider any file
113 # with a zero byte to be a binary file. Is there any better, or
119 $is_binary = 1;
125 print STDERR "$name: $f: binary file\n";
146 /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
150 $in_hunk = 1;
158 # We're in a hunk
161 $plus_lines--;
163 $text = substr($line, 1);
170 "$f:$lineno: adds line exceeds $max_width ",
175 } elsif ($line =~ /^\-/) {
176 $minus_lines--;
179 $plus_lines--;
180 $minus_lines--;
183 print STDERR "$name: $f: malformed patch\n";
184 $err = 1;
189 print STDERR "$name: $f: malformed patch\n";
190 $err = 1;
193 # End of a hunk. Process this hunk.
200 for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) {
205 $done = 1;
217 ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/);
218 my $mstart = $1;
224 $l = sprintf("@@ -%d,%d +%d,%d @@%s\n",
225 $mstart, $mlin, $pstart, $plin-$adj,
242 print STDERR "$name: $f: malformed patch\n";
243 $err = 1;
254 die "$name: Failed to truncate modified file: $f: $!\n";