From 7274f9c8e8c61b00ff7a4e2bad6accec85015a73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 15 Sep 2011 14:49:54 +0200 Subject: [PATCH] Alle 2-arg open in 3-arg open verwandelt. --- SL/AM.pm | 2 +- SL/DATEV.pm | 8 ++++---- SL/DN.pm | 4 ++-- SL/Form.pm | 24 ++++++++++++------------ SL/LXDebug.pm | 2 +- SL/Template/OpenDocument.pm | 2 +- SL/User.pm | 2 +- bin/mozilla/admin.pl | 6 +++--- t/Support/Systemexec.pm | 5 ++++- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index 33f8e66cc..ba15e7f84 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1009,7 +1009,7 @@ sub save_template { my $error = ""; - if (open(TEMPLATE, ">$filename")) { + if (open(TEMPLATE, ">", $filename)) { $content = Encode::encode('utf-8-strict', $content) if $::locale->is_utf8; $content =~ s/\r\n/\n/g; print(TEMPLATE $content); diff --git a/SL/DATEV.pm b/SL/DATEV.pm index e3cecef11..6c6f1c744 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -868,7 +868,7 @@ sub kne_buchungsexport { $kne_file->add_block($mandantenendsumme); $kne_file->flush(); - open(ED, "> $ed_filename") or die "can't open outputfile: $!\n"; + open(ED, ">", $ed_filename) or die "can't open outputfile: $!\n"; print(ED $kne_file->get_data()); close(ED); @@ -880,7 +880,7 @@ sub kne_buchungsexport { my $ev_header = &make_ev_header($form, $fileno); my $ev_filename = $export_path . $evfile; push(@filenames, $evfile); - open(EV, "> $ev_filename") or die "can't open outputfile: EV01\n"; + open(EV, ">", $ev_filename) or die "can't open outputfile: EV01\n"; print(EV $ev_header); foreach my $file (@ed_versionset) { @@ -922,7 +922,7 @@ sub kne_stammdatenexport { $filename++; my $ed_filename = $export_path . $filename; push(@filenames, $filename); - open(ED, "> $ed_filename") or die "can't open outputfile: $!\n"; + open(ED, ">", $ed_filename) or die "can't open outputfile: $!\n"; my $header = &make_kne_data_header($myconfig, $form, ""); $remaining_bytes -= length($header); @@ -994,7 +994,7 @@ sub kne_stammdatenexport { my $ev_header = &make_ev_header($form, $fileno); my $ev_filename = $export_path . $evfile; push(@filenames, $evfile); - open(EV, "> $ev_filename") or die "can't open outputfile: EV01\n"; + open(EV, ">", $ev_filename) or die "can't open outputfile: EV01\n"; print(EV $ev_header); foreach my $file (@ed_versionset) { diff --git a/SL/DN.pm b/SL/DN.pm index cef36383d..b00a83b44 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -794,7 +794,7 @@ sub print_dunning { my $filename = "dunning_${dunning_id}_" . Common::unique_id() . ".pdf"; my $spool = $::lx_office_conf{paths}->{spool}; - $form->{OUT} = ">${spool}/$filename"; + $form->{OUT} = "${spool}/$filename"; $form->{keep_tmpfile} = 1; delete $form->{tmpfile}; @@ -888,7 +888,7 @@ sub print_invoice_for_fees { my $filename = Common::unique_id() . "dunning_invoice_${dunning_id}.pdf"; my $spool = $::lx_office_conf{paths}->{spool}; - $form->{OUT} = ">$spool/$filename"; + $form->{OUT} = "$spool/$filename"; $form->{keep_tmpfile} = 1; delete $form->{tmpfile}; diff --git a/SL/Form.pm b/SL/Form.pm index 409bcd63b..e44f3977d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1315,26 +1315,25 @@ sub parse_template { if ($template->uses_temp_file() || $self->{media} eq 'email') { $out = $self->{OUT}; - $self->{OUT} = ">$self->{tmpfile}"; + $self->{OUT} = "$self->{tmpfile}"; } my $result; if ($self->{OUT}) { - open OUT, "$self->{OUT}" or $self->error("$self->{OUT} : $!"); - $result = $template->parse(*OUT); - close OUT; - + open(OUT, ">", $self->{OUT}) or $self->error("$self->{OUT} : $!"); } else { + open(OUT, ">&", \*STDOUT) or $self->error("STDOUT : $!"); $self->header; - $result = $template->parse(*STDOUT); } - if (!$result) { + if (!$template->parse(*OUT)) { $self->cleanup(); $self->error("$self->{IN} : " . $template->get_error()); } + close OUT; + if ($self->{media} eq 'file') { copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file; $self->cleanup; @@ -1368,7 +1367,7 @@ sub parse_template { $myconfig->{signature} =~ s/\n/
\n/g; $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
"; - open(IN, $self->{tmpfile}) + open(IN, "<", $self->{tmpfile}) or $self->error($self->cleanup . "$self->{tmpfile} : $!"); while () { $mail->{message} .= $_; @@ -1398,7 +1397,7 @@ sub parse_template { $self->{OUT} = $out; my $numbytes = (-s $self->{tmpfile}); - open(IN, $self->{tmpfile}) + open(IN, "<", $self->{tmpfile}) or $self->error($self->cleanup . "$self->{tmpfile} : $!"); binmode IN; @@ -1409,9 +1408,8 @@ sub parse_template { #print(STDERR "OUT $self->{OUT}\n"); for my $i (1 .. $self->{copies}) { if ($self->{OUT}) { - open OUT, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); + open OUT, '>', $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); print OUT while ; - close OUT; seek IN, 0, 0; } else { @@ -1426,8 +1424,10 @@ Content-Length: $numbytes |; - $::locale->with_raw_io(\*STDOUT, sub { print while }); + open(OUT, ">&", \*STDOUT) or $self->error($self->cleanup . "$!: STDOUT"); + $::locale->with_raw_io(*OUT, sub { print while }); } + close OUT; } close(IN); diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index 36812c529..d01caa1a9 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -262,7 +262,7 @@ sub _write { chomp($message); if ((FILE_TARGET == $self->{"target"}) - && open(FILE, ">>" . $self->{"file"})) { + && open(FILE, ">>", $self->{"file"})) { print(FILE "${date}${message}\n"); close(FILE); diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index 88b4cffbf..12a7bc8c5 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -389,7 +389,7 @@ sub spawn_xvfb { local *OUT; my $dfname = $self->{"userspath"} . "/xvfb_display"; - if (!open(OUT, ">$dfname")) { + if (!open(OUT, ">", $dfname)) { $self->{"error"} = "Conversion to PDF failed because OpenOffice could not be started ($dfname: $!)"; unlink($xauthority); kill($pid); diff --git a/SL/User.pm b/SL/User.pm index 75e7a38d0..888d042c4 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -150,7 +150,7 @@ sub login { } # update the tables - if (!open(FH, ">" . $::lx_office_conf{paths}->{userspath} . "/nologin")) { + if (!open(FH, ">", $::lx_office_conf{paths}->{userspath} . "/nologin")) { $form->show_generic_error($main::locale->text('A temporary file could not be created. ' . 'Please verify that the directory "#1" is writeable by the webserver.', $::lx_office_conf{paths}->{userspath}), diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index 08b97c439..e78842751 100755 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -549,11 +549,11 @@ sub save_user { closedir TEMPLATEDIR; foreach my $file (@templates) { - open(TEMP, $::lx_office_conf{paths}->{templates} . "/$file") + open(TEMP, "<", $::lx_office_conf{paths}->{templates} . "/$file") or $form->error($::lx_office_conf{paths}->{templates} . "/$file : $ERRNO"); $file =~ s/\Q$form->{mastertemplates}\E-//; - open(NEW, ">$form->{templates}/$file") + open(NEW, ">", "$form->{templates}/$file") or $form->error("$form->{templates}/$file : $ERRNO"); while (my $line = ) { @@ -1137,7 +1137,7 @@ sub lock_system { my $form = $main::form; my $locale = $main::locale; - open(FH, ">" . _nologin_file_name()) + open(FH, ">", _nologin_file_name()) or $form->error($locale->text('Cannot create Lock!')); close(FH); diff --git a/t/Support/Systemexec.pm b/t/Support/Systemexec.pm index 676ee02a4..eefc52c71 100644 --- a/t/Support/Systemexec.pm +++ b/t/Support/Systemexec.pm @@ -3,7 +3,7 @@ package Support::Systemexec; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(system exec); +@EXPORT = qw(system exec open); @EXPORT_OK = qw(); sub system($$@) { 1; @@ -11,4 +11,7 @@ sub system($$@) { sub exec($$@) { 1; } +sub open(*$$@) { + 1; +} 1; -- 2.20.1