From 55971b9830f5e0f0442d12dc382a4525a19bbd11 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Sun, 2 Mar 2003 22:15:54 +0000 Subject: Fixed auto-configuration for printers in the GIMP to work with Foomatic 3.0. --- perl-install/printer/gimp.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'perl-install/printer') diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm index db7d50470..61a3db1e2 100644 --- a/perl-install/printer/gimp.pm +++ b/perl-install/printer/gimp.pm @@ -180,7 +180,7 @@ sub makeprinterentry { # GhostScript + Foomatic driver $gimpprintqueue = 1; $ppd =~ - /'idx'\s*=>\s*'ev\/gimp-print-((escp2|pcl|bjc|lexmark)\-\S*)'/im; + /\-sModel=((escp2|pcl|bjc|lexmark)\-[^\s\"\']*)/im; $gimpprintdriver = $1; } if ($gimpprintqueue) { @@ -260,6 +260,7 @@ sub addentry { my $sectionfound = 0; my $entryinserted = 0; my @lines = split("\n", $filecontent); + while ($lines[-1] !~ /\S/) { pop @lines; } foreach (@lines) { if (!$sectionfound) { $sectionfound = 1 if /^\s*Printer\s*:\s*($section)\s*$/; @@ -272,23 +273,25 @@ sub addentry { } } push(@lines, $entry) if $sectionfound && !$entryinserted; - return join("\n", @lines); + return join("\n", @lines) . "\n"; } sub addprinter { my ($section, $filecontent) = @_; my @lines = split("\n", $filecontent); + while ($lines[-1] !~ /\S/) { pop @lines; } foreach (@lines) { # section already there, nothing to be done return $filecontent if /^\s*Printer\s*:\s*($section)\s*$/; } - return $filecontent . "\nPrinter: $section"; + return $filecontent . "\nPrinter: $section\n"; } sub removeentry { my ($section, $entry, $filecontent) = @_; my $sectionfound; - my @lines = split("\n", $filecontent); + my @lines = split(/^/, $filecontent); + while ($lines[-1] !~ /\S/) { pop @lines; } foreach (@lines) { if (!$sectionfound) { $sectionfound = /^\s*Printer\s*:\s*($section)\s*$/; @@ -300,13 +303,14 @@ sub removeentry { } } } - return join "\n", @lines; + return join "", @lines; } sub removeprinter { my ($section, $filecontent) = @_; my $sectionfound; - my @lines = split("\n", $filecontent); + my @lines = split(/^/, $filecontent); + while ($lines[-1] !~ /\S/) { pop @lines; } foreach (@lines) { if (!$sectionfound) { if (/^\s*Printer\s*:\s*($section)\s*$/) { @@ -318,7 +322,7 @@ sub removeprinter { $_ = ""; } } - return join "\n", @lines; + return join "", @lines; } sub isprinterconfigured { -- cgit v1.2.1