diff options
| author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 14:28:19 -0700 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 14:28:19 -0700 | 
| commit | efffbeee5bc4168059683714b300d307f5193d69 (patch) | |
| tree | 7fde51080f4534a86bfa27a430aaf7ef2bb8ef92 /scripts/cleanpatch | |
| parent | 40b42f1ebf653cd72c32eb1a1a0b9fea2dfbfd7d (diff) | |
| parent | b824325443bb010689d22262c6a4e0feb63bad56 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (33 commits)
  xtensa: use DATA_DATA in xtensa
  powerpc: add missing DATA_DATA to powerpc
  cris: use DATA_DATA in cris
  kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c
  kbuild: use -fno-optimize-sibling-calls unconditionally
  kconfig: reset generated values only if Kconfig and .config agree.
  kbuild: fix the warning when running make tags
  kconfig: strip 'CONFIG_' automatically in kernel configuration search
  kbuild: use POSIX BRE in headers install target
  Whitelist references from __dbe_table to .init
  modpost white list pattern adjustment
  kbuild: do section mismatch check on full vmlinux
  kbuild: whitelist references from variables named _timer to .init.text
  kbuild: remove hardcoded _logo names from modpost
  kbuild: remove hardcoded apic_es7000 from modpost
  kbuild: warn about references from .init.text to .exit.text
  kbuild: consolidate section checks
  kbuild: refactor code in modpost to improve maintainability
  kbuild: ignore section mismatch warnings originating from .note section
  kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it
  ...
Diffstat (limited to 'scripts/cleanpatch')
| -rwxr-xr-x | scripts/cleanpatch | 58 | 
1 files changed, 55 insertions, 3 deletions
diff --git a/scripts/cleanpatch b/scripts/cleanpatch index a53f987708f..9680d03ad2b 100755 --- a/scripts/cleanpatch +++ b/scripts/cleanpatch @@ -7,7 +7,9 @@  use bytes;  use File::Basename; -# +# Default options +$max_width = 79; +  # Clean up space-tab sequences, either by removing spaces or  # replacing them with tabs.  sub clean_space_tabs($) @@ -48,9 +50,49 @@ sub clean_space_tabs($)      return $lo;  } +# Compute the visual width of a string +sub strwidth($) { +    no bytes;			# Tab alignment depends on characters + +    my($li) = @_; +    my($c, $i); +    my $pos = 0; +    my $mlen = 0; + +    for ($i = 0; $i < length($li); $i++) { +	$c = substr($li,$i,1); +	if ($c eq "\t") { +	    $pos = ($pos+8) & ~7; +	} elsif ($c eq "\n") { +	    $mlen = $pos if ($pos > $mlen); +	    $pos = 0; +	} else { +	    $pos++; +	} +    } + +    $mlen = $pos if ($pos > $mlen); +    return $mlen; +} +  $name = basename($0); -foreach $f ( @ARGV ) { +@files = (); + +while (defined($a = shift(@ARGV))) { +    if ($a =~ /^-/) { +	if ($a eq '-width' || $a eq '-w') { +	    $max_width = shift(@ARGV)+0; +	} else { +	    print STDERR "Usage: $name [-width #] files...\n"; +	    exit 1; +	} +    } else { +	push(@files, $a); +    } +} + +foreach $f ( @files ) {      print STDERR "$name: $f\n";      if (! -f $f) { @@ -86,6 +128,7 @@ foreach $f ( @ARGV ) {      $in_bytes = 0;      $out_bytes = 0; +    $lineno = 0;      @lines  = (); @@ -93,10 +136,12 @@ foreach $f ( @ARGV ) {      $err = 0;      while ( defined($line = <FILE>) ) { +	$lineno++;  	$in_bytes += length($line);  	if (!$in_hunk) { -	    if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { +	    if ($line =~ +		/^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {  		$minus_lines = $2;  		$plus_lines = $4;  		if ($minus_lines || $plus_lines) { @@ -117,6 +162,13 @@ foreach $f ( @ARGV ) {  		$text =~ s/[ \t\r]*$//;		# Remove trailing spaces  		$text = clean_space_tabs($text); +		$l_width = strwidth($text); +		if ($max_width && $l_width > $max_width) { +		    print STDERR +			"$f:$lineno: adds line exceeds $max_width ", +			"characters ($l_width)\n"; +		} +  		push(@hunk_lines, '+'.$text);  	    } elsif ($line =~ /^\-/) {  		$minus_lines--;  | 
