summaryrefslogtreecommitdiffstats
path: root/perl-install/printerdrake.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-09-12 03:24:59 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-09-12 03:24:59 +0000
commit137dec7aa285845e1f7b37fdf62d8c1812df95a3 (patch)
tree55b0103d12ee366a2a3fb62c9e9261f3e62a8d40 /perl-install/printerdrake.pm
parentf1f8d45f08037952d9d2c90be221ecd86c8cb283 (diff)
downloaddrakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.gz
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.bz2
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.xz
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.zip
Made the association of model names obtained by auto-detection and of
the model names in the printer database much more reliable.
Diffstat (limited to 'perl-install/printerdrake.pm')
-rw-r--r--perl-install/printerdrake.pm34
1 files changed, 30 insertions, 4 deletions
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index e9dc78834..3fe92c9a6 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -1436,12 +1436,14 @@ sub setup_common {
foreach (@autodetected) {
$device eq $_->{port} or next;
if (($_->{val}{MANUFACTURER}) && ($_->{val}{MODEL})) {
- $descr = "$_->{val}{MANUFACTURER} $_->{val}{MODEL}";
+ $descr = "$_->{val}{MANUFACTURER}|$_->{val}{MODEL}";
} else {
$descr = $_->{val}{DESCRIPTION};
+ $descr =~ s/ /\|/;
}
# Clean up the description from noise which makes the best match
# difficult
+ $descr =~ s/Seiko\s+Epson/Epson/;
$descr =~ s/\s+Inc\.//;
$descr =~ s/\s+Corp\.//;
$descr =~ s/\s+SA\.//;
@@ -1452,10 +1454,34 @@ sub setup_common {
$descr =~ s/\s+[Ss]eries//;
$descr =~ s/\s+\(?[Pp]rinter\)?$//;
$printer->{DBENTRY} = "";
- for my $entry (keys(%printer::thedb)) {
- if ($entry =~ m!$descr!i) {
+ # Try to find an exact match, check both whether the detected
+ # make|model is in the make|model of the database entry and vice versa
+ # If there is more than one matching database entry, the longest match
+ # counts.
+ my $matchlength = 0;
+ for my $entry (keys %printer::thedb) {
+ my $dbmakemodel;
+ if ($::expert) {
+ $entry =~ m/^(.*)\|[^\|]*$/;
+ $dbmakemodel = $1;
+ } else {
+ $dbmakemodel = $entry;
+ }
+ next if !$dbmakemodel;
+ $dbmakemodel =~ s/\|/\\\|/;
+ my $searchterm = $descr;
+ $searchterm =~ s/\|/\\\|/;
+ my $lsearchterm = length($searchterm);
+ if (($lsearchterm > $matchlength) &&
+ ($entry =~ m!$searchterm!i)) {
+ $matchlength = $lsearchterm;
+ $printer->{DBENTRY} = $entry;
+ }
+ my $ldbmakemodel = length($dbmakemodel);
+ if (($ldbmakemodel > $matchlength) &&
+ ($descr =~ m!$dbmakemodel!i)) {
+ $matchlength = $ldbmakemodel;
$printer->{DBENTRY} = $entry;
- last;
}
}
if (!$printer->{DBENTRY}) {