X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCommon.pm;h=1331ac003cb8108a4b3f46b8564b334162f37e84;hb=f1fc9ededf793c53d996bf672294b29abcb84ec4;hp=915fa859a7f8bd290f6037d3c8b17ab3fa757cf7;hpb=6edbdb47edfa0db4c2cd290a7f6cf8b2c9b2b121;p=debbugs.git diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 915fa85..1331ac0 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -55,7 +55,7 @@ BEGIN{ lock => [qw(filelock unfilelock lockpid)], ); @EXPORT_OK = (); - Exporter::export_ok_tags(qw(lock quit date util misc)); + Exporter::export_ok_tags(keys %EXPORT_TAGS); $EXPORT_TAGS{all} = [@EXPORT_OK]; } @@ -70,6 +70,7 @@ use IO::Scalar; use Debbugs::MIME qw(decode_rfc1522); use Mail::Address; use Cwd qw(cwd); +use Storable qw(dclone); use Params::Validate qw(validate_with :types); @@ -429,6 +430,7 @@ sub __add_to_hash { $type //= 'address'; my $fh = IO::File->new($fn,'r') or die "Unable to open $fn for reading: $!"; + binmode($fh,':encoding(UTF-8)'); while (<$fh>) { chomp; next unless m/^(\S+)\s+(\S.*\S)\s*$/; @@ -823,7 +825,8 @@ sub globify_scalar { if (defined ref($scalar)) { if (ref($scalar) eq 'SCALAR' and not UNIVERSAL::isa($scalar,'GLOB')) { - return IO::Scalar->new($scalar); + open $handle, '>:scalar:encoding(UTF-8)', $scalar; + return $handle; } else { return $scalar; @@ -836,7 +839,7 @@ sub globify_scalar { carp "Given a non-scalar reference, non-glob to globify_scalar; returning /dev/null handle"; } } - return IO::File->new('/dev/null','w'); + return IO::File->new('/dev/null','>:encoding(UTF-8)'); } =head2 cleanup_eval_fail() @@ -869,6 +872,8 @@ sub cleanup_eval_fail { } # ditch the "at foo/bar/baz.pm line 5" $error =~ s/\sat\s\S+\sline\s\d+//; + # ditch croak messages + $error =~ s/^\t+.+\n?//g; # ditch trailing multiple periods in case there was a cascade of # die messages. $error =~ s/\.+$/\./; @@ -892,6 +897,7 @@ sub hash_slice(\%@) { return map {exists $hashref->{$_}?($_,$hashref->{$_}):()} @keys; } + 1; __END__