[interchange] Prevent startup failures with environment variable MINIVEND_DISABLE_UTF8 set.
Stefan Hornburg
interchange-cvs at icdevgroup.org
Thu Apr 29 15:18:51 UTC 2010
commit 5cb2de19af7994a12438c73c18741c16585828ee
Author: Rok RužiÄ <rok.ruzic at informa.si>
Date: Thu Apr 29 17:17:11 2010 +0200
Prevent startup failures with environment variable MINIVEND_DISABLE_UTF8 set.
lib/Vend/File.pm | 9 ++++++---
lib/Vend/Table/GDBM.pm | 6 +++++-
2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/lib/Vend/File.pm b/lib/Vend/File.pm
index d9128d8..59a875c 100644
--- a/lib/Vend/File.pm
+++ b/lib/Vend/File.pm
@@ -49,9 +49,12 @@ use Config;
use Fcntl;
use Errno;
+my $PERLQQ = 0x0100; # from Encode(3perl)
+
unless( $ENV{MINIVEND_DISABLE_UTF8} ) {
require Encode;
import Encode qw( is_utf8 );
+ $PERLQQ = Encode::PERLQQ();
}
use Vend::Util;
@@ -69,7 +72,7 @@ sub writefile {
$encoding = $opt->{encoding} ||= 'utf-8';
undef $encoding if $encoding eq 'raw';
$fallback = $opt->{fallback};
- $fallback = Encode::PERLQQ() unless defined $fallback;
+ $fallback = $PERLQQ unless defined $fallback;
}
$file = ">>$file" unless $file =~ /^[|>]/;
@@ -200,7 +203,7 @@ sub readfile {
if ($::Variable->{MV_UTF8} || $Global::Variable->{MV_UTF8}) {
$encoding = $opt->{encoding} ||= 'utf-8';
$fallback = $opt->{fallback};
- $fallback = Encode::PERLQQ() unless defined $fallback;
+ $fallback = $PERLQQ unless defined $fallback;
undef $encoding if $encoding eq 'raw';
}
@@ -236,7 +239,7 @@ sub readfile {
binmode(READIN) if $Global::Windows;
if ($encoding) {
- local $PerlIO::encoding::fallback = Encode::PERLQQ();
+ local $PerlIO::encoding::fallback = $PERLQQ;
binmode(READIN, ":encoding($encoding)");
}
diff --git a/lib/Vend/Table/GDBM.pm b/lib/Vend/Table/GDBM.pm
index aa755c4..67a9fd2 100644
--- a/lib/Vend/Table/GDBM.pm
+++ b/lib/Vend/Table/GDBM.pm
@@ -29,7 +29,11 @@ use vars qw($VERSION @ISA);
use GDBM_File;
use Vend::Table::Common;
-unless( $ENV{MINIVEND_DISABLE_UTF8} ) {
+if ($ENV{MINIVEND_DISABLE_UTF8}) {
+ sub encode($$;$){}
+ sub decode($$;$){}
+}
+else {
require Encode;
import Encode qw( decode encode );
}
More information about the interchange-cvs
mailing list