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