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