aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-11-08 17:47:35 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-11-08 17:47:35 (GMT)
commitd3d94b467eeb5fac10f38041ad44fd843ffca6bf (patch)
tree6bbe5dc674627b3dcb267cad692a0a81d3189552
parentbf4e76013920e26d010d92196fec769152212be5 (diff)
gen_keytables.pl: use a function to create files
We want to move part of the logic from Makefile into gen_keytables.pl, in order to make it process a group of files. So, convert the main logic into a function. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rwxr-xr-xutils/keytable/gen_keytables.pl75
1 files changed, 41 insertions, 34 deletions
diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl
index d8cc664..06400bb 100755
--- a/utils/keytable/gen_keytables.pl
+++ b/utils/keytable/gen_keytables.pl
@@ -13,7 +13,7 @@ my $check_type = 0;
my $name;
my $warn;
-my $filename = shift or die "Need a file name to proceed.";
+my $file = shift or die "Need a file name to proceed.";
sub flush()
{
return if (!$keyname || !$out);
@@ -33,48 +33,55 @@ sub flush()
$name = "";
}
-open IN, "<$filename";
-while (<IN>) {
- if (m/struct\s+ir_scancode\s+(\w[\w\d_]+)/) {
- flush();
+sub parse_file($)
+{
+ my $filename = shift;
- $keyname = $1;
- $keyname =~ s/^ir_codes_//;
- $keyname =~ s/_table$//;
- $read = 1;
- next;
- }
- if (m/struct\s+rc_keymap.*=\s+{/) {
- $check_type = 1;
- next;
- }
- if (m/\.name\s*=\s*(RC_MAP_[^\s\,]+)/) {
- $name = $1;
- }
+ open IN, "<$filename";
+ while (<IN>) {
+ if (m/struct\s+ir_scancode\s+(\w[\w\d_]+)/) {
+ flush();
- if ($check_type) {
- if (m/^\s*}/) {
- $check_type = 0;
+ $keyname = $1;
+ $keyname =~ s/^ir_codes_//;
+ $keyname =~ s/_table$//;
+ $read = 1;
next;
}
- if (m/IR_TYPE_([\w\d_]+)/) {
- $type = $1;
+ if (m/struct\s+rc_keymap.*=\s+{/) {
+ $check_type = 1;
+ next;
+ }
+ if (m/\.name\s*=\s*(RC_MAP_[^\s\,]+)/) {
+ $name = $1;
}
- next;
- }
- if ($read) {
- if (m/(0x[\dA-Fa-f]+).*(KEY_[^\s\,\}]+)/) {
- $out .= "$1 $2\n";
+ if ($check_type) {
+ if (m/^\s*}/) {
+ $check_type = 0;
+ next;
+ }
+ if (m/IR_TYPE_([\w\d_]+)/) {
+ $type = $1;
+ }
next;
}
- if (m/\}/) {
- $read = 0;
+
+ if ($read) {
+ if (m/(0x[\dA-Fa-f]+).*(KEY_[^\s\,\}]+)/) {
+ $out .= "$1 $2\n";
+ next;
+ }
+ if (m/\}/) {
+ $read = 0;
+ }
}
}
-}
-close IN;
+ close IN;
-flush();
+ flush();
+
+ printf STDERR "WARNING: keyboard name not found on %d tables at file $filename\n", $warn if ($warn);
+}
-printf STDERR "WARNING: keyboard name not found on %d tables at file $filename\n", $warn if ($warn);
+parse_file $file;

Privacy Policy