Subject: | croak instead of die- patch attached |
i'm updating Crypt::Skip32::XS to emit the same error messages
Subject: | croak.patch |
diff -rupN old/Crypt-Skip32-0.13/Changes new/Crypt-Skip32-0.13/Changes
--- old/Crypt-Skip32-0.13/Changes 2009-07-07 23:38:04.000000000 -0700
+++ new/Crypt-Skip32-0.13/Changes 2009-07-13 21:59:02.000000000 -0700
@@ -1,6 +1,9 @@
Revision history for Perl extension Crypt::Skip32.
-0.13 Tue Jul 7 23:37:20 PDT 2009
+0.14 Tue Jul 14 04:58:01 UTC 2009
+ - Croak instead of die. (gray <gray@cpan.org>)
+
+0.13 Tue Jul 7 23:37:20 PDT 2009
- Correct way of recommending Crypt::Skip32::XS
0.12 Tue Jul 7 18:14:32 PDT 2009
diff -rupN old/Crypt-Skip32-0.13/lib/Crypt/Skip32.pm new/Crypt-Skip32-0.13/lib/Crypt/Skip32.pm
--- old/Crypt-Skip32-0.13/lib/Crypt/Skip32.pm 2009-07-07 23:38:04.000000000 -0700
+++ new/Crypt-Skip32-0.13/lib/Crypt/Skip32.pm 2009-07-13 21:56:47.000000000 -0700
@@ -3,6 +3,7 @@ package Crypt::Skip32;
use 5.008000;
use strict;
use warnings;
+use Carp qw(croak);
if (not $ENV{CRYPT_SKIP32_PP} and eval 'use Crypt::Skip32::XS; 1') {
eval q(sub Crypt::Skip32 () { 'Crypt::Skip32::XS' });
@@ -27,7 +28,7 @@ sub new {
my ($class, $key) = @_;
my @key_bytes = unpack('C*', $key);
- die __PACKAGE__."::new key must be 10 bytes long"
+ croak "key must be 10 bytes long"
unless scalar @key_bytes == 10;
my $self = {
@@ -44,7 +45,7 @@ sub encrypt {
my ($self, $plaintext) = @_;
my @input_bytes = unpack('C*', $plaintext);
- die __PACKAGE__."::encrypt plaintext must be 4 bytes long"
+ croak "plaintext must be 4 bytes long"
unless scalar @input_bytes == 4;
my @output_bytes = _skip32($self->{key_bytes}, \@input_bytes, 1);
my $cipher_text = pack('C*', @output_bytes);
@@ -57,7 +58,7 @@ sub decrypt {
my ($self, $ciphertext) = @_;
my @input_bytes = unpack('C*', $ciphertext);
- die __PACKAGE__."::decrypt ciphertext must be 4 bytes long"
+ croak "ciphertext must be 4 bytes long"
unless scalar @input_bytes == 4;
my @output_bytes = _skip32($self->{key_bytes}, \@input_bytes, 0);
my $plain_text = pack('C*', @output_bytes);