| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 |
|
| 9 | use strict;
|
| 10 |
|
| 11 | $| = 1;
|
| 12 |
|
| 13 | my $debugging;
|
| 14 |
|
| 15 | foreach my $file (@ARGV) {
|
| 16 | next if $file =~ "include/linux/version\.h";
|
| 17 | |
| 18 | open( my $f, '<', $file )
|
| 19 | or die "Can't open $file: $!\n";
|
| 20 |
|
| 21 | |
| 22 | my ($fInComment, $fInString, $fUseVersion);
|
| 23 | my $iLinuxVersion = 0;
|
| 24 |
|
| 25 | while (<$f>) {
|
| 26 | |
| 27 | $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
|
| 28 | m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
|
| 29 |
|
| 30 | |
| 31 | if ( m/^\s*#/o ) {
|
| 32 | $iLinuxVersion = $. if m/^\s*#\s*include\s*"linux\/version\.h"/o;
|
| 33 | }
|
| 34 |
|
| 35 | |
| 36 | $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
|
| 37 | m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
|
| 38 |
|
| 39 | |
| 40 | if ( m/^\s*#/o ) {
|
| 41 | $iLinuxVersion = $. if m/^\s*#\s*include\s*<linux\/version\.h>/o;
|
| 42 | }
|
| 43 |
|
| 44 | |
| 45 | if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
|
| 46 | $fUseVersion = 1;
|
| 47 | last if $iLinuxVersion;
|
| 48 | }
|
| 49 | }
|
| 50 |
|
| 51 | |
| 52 | if ($fUseVersion && ! $iLinuxVersion) {
|
| 53 | print "$file: $.: need linux/version.h\n";
|
| 54 | }
|
| 55 |
|
| 56 | |
| 57 | if ($iLinuxVersion && ! $fUseVersion) {
|
| 58 | print "$file: $iLinuxVersion linux/version.h not needed.\n";
|
| 59 | }
|
| 60 |
|
| 61 | |
| 62 | if ($debugging) {
|
| 63 | if ($iLinuxVersion && $fUseVersion) {
|
| 64 | print "$file: version use is OK ($iLinuxVersion)\n";
|
| 65 | }
|
| 66 | if (! $iLinuxVersion && ! $fUseVersion) {
|
| 67 | print "$file: version use is OK (none)\n";
|
| 68 | }
|
| 69 | }
|
| 70 |
|
| 71 | close($f);
|
| 72 | }
|