[liblog-log4perl-perl] 02/03: Workaround for Perl 5.24 no longer allowing syswrite and utf8 together
Salvatore Bonaccorso
carnil at debian.org
Fri Nov 24 12:03:07 UTC 2017
This is an automated email from the git hooks/post-receive script.
carnil pushed a commit to branch stretch
in repository liblog-log4perl-perl.
commit c0e307352e35c2b57a4a6489fa1245848ead4ea2
Author: Salvatore Bonaccorso <carnil at debian.org>
Date: Thu Nov 23 14:27:48 2017 +0100
Workaround for Perl 5.24 no longer allowing syswrite and utf8 together
Closes: #855894
---
...for-perl-5.24-no-longer-allowing-syswrite.patch | 99 ++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 100 insertions(+)
diff --git a/debian/patches/0005-Workaround-for-perl-5.24-no-longer-allowing-syswrite.patch b/debian/patches/0005-Workaround-for-perl-5.24-no-longer-allowing-syswrite.patch
new file mode 100644
index 0000000..27b1b90
--- /dev/null
+++ b/debian/patches/0005-Workaround-for-perl-5.24-no-longer-allowing-syswrite.patch
@@ -0,0 +1,99 @@
+From: mschilli <github at perlmeister.com>
+Date: Sun, 19 Feb 2017 13:22:59 -0800
+Subject: Workaround for perl-5.24 no longer allowing syswrite+utf8 (see
+ https://github.com/mschilli/log4perl/issues/78)
+Origin: https://github.com/mschilli/log4perl/commit/e8d8f6600312670a156399e220998dbd0832915f
+Bug: https://github.com/mschilli/log4perl/issues/78
+Bug-Debian: https://bugs.debian.org/855894
+
+---
+ lib/Log/Log4perl/Appender/File.pm | 39 ++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 34 insertions(+), 5 deletions(-)
+
+diff --git a/lib/Log/Log4perl/Appender/File.pm b/lib/Log/Log4perl/Appender/File.pm
+index 8b9dfd8..abdce69 100755
+--- a/lib/Log/Log4perl/Appender/File.pm
++++ b/lib/Log/Log4perl/Appender/File.pm
+@@ -11,6 +11,7 @@ use Fcntl;
+ use File::Path;
+ use File::Spec::Functions qw(splitpath);
+ use constant _INTERNAL_DEBUG => 0;
++use constant SYSWRITE_UTF8_OK => ( $] < 5.024 );
+
+ ##################################################
+ sub new {
+@@ -26,7 +27,7 @@ sub new {
+ syswrite => 0,
+ mode => "append",
+ binmode => undef,
+- utf8 => undef,
++ utf8 => 0,
+ recreate => 0,
+ recreate_check_interval => 30,
+ recreate_check_signal => undef,
+@@ -62,12 +63,30 @@ sub new {
+ close FILE;
+ }
+
++ $self->{syswrite_encoder} = $self->syswrite_encoder();
++
+ # This will die() if it fails
+ $self->file_open() unless $self->{create_at_logtime};
+
+ return $self;
+ }
+
++##################################################
++sub syswrite_encoder {
++##################################################
++ my($self) = @_;
++
++ if(!SYSWRITE_UTF8_OK and $self->{syswrite} and $self->{utf8}) {
++ if( eval { require Encode } ) {
++ return sub { Encode::encode_utf8($_[0]) };
++ } else {
++ die "syswrite and utf8 requires Encode.pm";
++ }
++ }
++
++ return undef;
++}
++
+ ##################################################
+ sub filename {
+ ##################################################
+@@ -163,8 +182,11 @@ sub file_open {
+ binmode $self->{fh}, $self->{binmode};
+ }
+
+- if (defined $self->{utf8}) {
+- binmode $self->{fh}, ":utf8";
++ if ($self->{utf8}) {
++ # older perls can handle syswrite+utf8 just fine
++ if(SYSWRITE_UTF8_OK or !$self->{syswrite}) {
++ binmode $self->{fh}, ":utf8";
++ }
+ }
+
+ if(defined $self->{header_text}) {
+@@ -269,8 +291,15 @@ sub log {
+ my $fh = $self->{fh};
+
+ if($self->{syswrite}) {
+- defined (syswrite $fh, $params{message}) or
+- die "Cannot syswrite to '$self->{filename}': $!";
++ my $rc =
++ syswrite( $fh,
++ $self->{ syswrite_encoder } ?
++ $self->{ syswrite_encoder }->($params{message}) :
++ $params{message} );
++
++ if(!$rc) {
++ die "Cannot syswrite to '$self->{filename}': $!";
++ }
+ } else {
+ print $fh $params{message} or
+ die "Cannot write to '$self->{filename}': $!";
+--
+2.15.0
+
diff --git a/debian/patches/series b/debian/patches/series
index b655371..b790172 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@
0002-topic-debian-Fix-Wrong-path-for-interpreter.patch
0003-More-spelling-fixes-in-the-POD.patch
0004-topic-man-fix-spelling-errors-in-man-pages.patch
+0005-Workaround-for-perl-5.24-no-longer-allowing-syswrite.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/liblog-log4perl-perl.git
More information about the Pkg-perl-cvs-commits
mailing list