diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 18:40:16 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 18:40:16 -0200 |
commit | 3a5f8501c311744e929d5ad1ba989e2a5b42fe42 (patch) | |
tree | ec18ed76d8f8900a6ca9b2d6231b92e7546e3a17 | |
parent | a10fafffd600af5d428876815d7da534e3a4c824 (diff) | |
download | mediapointer-dvb-s2-3a5f8501c311744e929d5ad1ba989e2a5b42fe42.tar.gz mediapointer-dvb-s2-3a5f8501c311744e929d5ad1ba989e2a5b42fe42.tar.bz2 |
Updated gentree.pl
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Relaxed some regular expressions to better handle whitespaces at the
middle of cpp macros;
Added #elif processing capability to the script.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rwxr-xr-x | v4l/scripts/gentree.pl | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/v4l/scripts/gentree.pl b/v4l/scripts/gentree.pl index bd1ee94e2..1b4e44f26 100755 --- a/v4l/scripts/gentree.pl +++ b/v4l/scripts/gentree.pl @@ -87,7 +87,7 @@ sub filter_source ($$) { $level++; next; } - if ($line =~ m|^\s*\#if\s+0\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) { + if ($line =~ m|^\s*\#\s*if\s+0\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) { if ($1 eq ";") { print OUT "#if 0\n"; } else { @@ -132,7 +132,7 @@ sub filter_source ($$) { $level++; next; } - if ($line =~ m|^\s*\#if\s+1\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) { + if ($line =~ m|^\s*\#\s*if\s+1\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) { print OUT "#if 1$1\n"; $state{$level} = "ifother"; $if{$level} = 1; @@ -180,7 +180,7 @@ sub filter_source ($$) { $level++; next; } - if ($line =~ /^\s*#\s*ifndef.\s*I2C_PEC/) { + if ($line =~ /^\s*#\s*ifndef\s+I2C_PEC/) { chomp($line); $state{$level} = "if"; $if{$level} = 0; @@ -188,7 +188,7 @@ sub filter_source ($$) { $level++; next; } - if ($line =~ /^\s*#\s*ifdef.\s*I2C_PEC/) { + if ($line =~ /^\s*#\s*ifdef\s+I2C_PEC/) { chomp($line); $state{$level} = "if"; $if{$level} = 1; @@ -219,8 +219,36 @@ sub filter_source ($$) { if ($line =~ /^\s*#\s*if.*LINUX_VERSION_CODE/) { chomp($line); $line =~ s@^#if\s*@@; - $line =~ s@LINUX_VERSION_CODE@\$CODE@; -print STDERR "/* BP orig: ($line) */\n" if $DEBUG; + $line =~ s@LINUX_VERSION_CODE@\$CODE@g; + print STDERR "/* BP orig: ($line) */\n" if $DEBUG; + + $line =~ s@KERNEL_VERSION\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)@ + sprintf("%d",$1*65536 + $2*256 + $3) @eg; + $if{$level} = eval $line; + $state{$level} = "if"; + print STDERR "/* BP #if LINUX_VERSION_CODE state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG; + $level++; + next; + } + if ($line =~ /^\s*#\s*elif.*LINUX_VERSION_CODE/) { + chomp($line); + if ( !$level ) { + die "elif without if"; + } + $level--; + if ( $if{$level} ) { + # Else is 0 + $if{$level} = 0; + $state{$level} = "elif"; + print STDERR "/* BP #if LINUX_VERSION_CODE state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG; + + $level++; + next; + } + + $line =~ s@^#if\s*@@; + $line =~ s@LINUX_VERSION_CODE@\$CODE@g; + print STDERR "/* BP orig: ($line) */\n" if $DEBUG; $line =~ s@KERNEL_VERSION\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)@ sprintf("%d",$1*65536 + $2*256 + $3) @eg; |