diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-01-13 00:23:00 +0000 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-01-13 00:24:10 +0000 |
commit | 38054f44427e03da46a7c92750ce2f7268d3014c (patch) | |
tree | c8b2a25001206b29b6865e10506455f08f3e2f70 /cpan/Digest-MD5 | |
parent | 689fbe1862dc94d419ca1611964126fd6364e99b (diff) | |
download | perl-38054f44427e03da46a7c92750ce2f7268d3014c.tar.gz |
Update Digest-MD5 to CPAN version 2.54
[DELTA]
2015-01-12 Gisle Aas <gisle@ActiveState.com>
Release 2.54
David Mitchell: silence some compiler warnings
Jonathan Hall: Add ->context() feature
Steve Hay: Sync with blead
bulk88: const the vtable
zefram: 5.6 threads test fix
Diffstat (limited to 'cpan/Digest-MD5')
-rw-r--r-- | cpan/Digest-MD5/MD5.pm | 12 | ||||
-rw-r--r-- | cpan/Digest-MD5/MD5.xs | 79 | ||||
-rw-r--r-- | cpan/Digest-MD5/Makefile.PL | 2 | ||||
-rw-r--r-- | cpan/Digest-MD5/t/files.t | 4 | ||||
-rw-r--r-- | cpan/Digest-MD5/t/threads.t | 2 |
5 files changed, 79 insertions, 20 deletions
diff --git a/cpan/Digest-MD5/MD5.pm b/cpan/Digest-MD5/MD5.pm index 679036f8be..bb92ddb44a 100644 --- a/cpan/Digest-MD5/MD5.pm +++ b/cpan/Digest-MD5/MD5.pm @@ -3,7 +3,7 @@ package Digest::MD5; use strict; use vars qw($VERSION @ISA @EXPORT_OK); -$VERSION = '2.53'; +$VERSION = '2.54'; require Exporter; *import = \&Exporter::import; @@ -227,6 +227,16 @@ The base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the string "==" to the result. +=item @ctx = $md5->context + +=item $md5->context(@ctx) + +Saves or restores the internal state. When called with no arguments, +returns a 3-element list: number of blocks processed, a 16-byte +internal state buffer, then up to 63 bytes of unprocessed data. When +passed those same arguments, restores the state. This is only useful +for specialised operations. + =back diff --git a/cpan/Digest-MD5/MD5.xs b/cpan/Digest-MD5/MD5.xs index f3b58f7eee..acefc30711 100644 --- a/cpan/Digest-MD5/MD5.xs +++ b/cpan/Digest-MD5/MD5.xs @@ -155,26 +155,29 @@ STATIC int dup_md5_ctx(pTHX_ MAGIC *mg, CLONE_PARAMS *params) } #endif -STATIC MGVTBL vtbl_md5 = { +#if defined(MGf_DUP) && defined(USE_ITHREADS) +const STATIC MGVTBL vtbl_md5 = { NULL, /* get */ NULL, /* set */ NULL, /* len */ NULL, /* clear */ NULL, /* free */ -#ifdef MGf_COPY NULL, /* copy */ -#endif -#ifdef MGf_DUP -# ifdef USE_ITHREADS - dup_md5_ctx, -# else - NULL, /* dup */ -# endif -#endif -#ifdef MGf_LOCAL + dup_md5_ctx, /* dup */ NULL /* local */ -#endif }; +#else +/* declare as 5 member, not normal 8 to save image space*/ +const STATIC struct { + int (*svt_get)(SV* sv, MAGIC* mg); + int (*svt_set)(SV* sv, MAGIC* mg); + U32 (*svt_len)(SV* sv, MAGIC* mg); + int (*svt_clear)(SV* sv, MAGIC* mg); + int (*svt_free)(SV* sv, MAGIC* mg); +} vtbl_md5 = { + NULL, NULL, NULL, NULL, NULL +}; +#endif /* Padding is added at the end of the message in order to fill a @@ -503,7 +506,8 @@ static MD5_CTX* get_md5_ctx(pTHX_ SV* sv) croak("Not a reference to a Digest::MD5 object"); for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) { - if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_md5) { + if (mg->mg_type == PERL_MAGIC_ext + && mg->mg_virtual == (const MGVTBL * const)&vtbl_md5) { return (MD5_CTX *)mg->mg_ptr; } } @@ -525,7 +529,7 @@ static SV * new_md5_ctx(pTHX_ MD5_CTX *context, const char *klass) #ifdef USE_ITHREADS mg = #endif - sv_magicext(sv, NULL, PERL_MAGIC_ext, &vtbl_md5, (const char *)context, 0); + sv_magicext(sv, NULL, PERL_MAGIC_ext, (const MGVTBL * const)&vtbl_md5, (const char *)context, 0); #if defined(USE_ITHREADS) && defined(MGf_DUP) mg->mg_flags |= MGf_DUP; @@ -731,6 +735,45 @@ digest(context) XSRETURN(1); void +context(ctx, ...) + MD5_CTX* ctx + PREINIT: + char out[16]; + U32 w; + PPCODE: + if (items > 2) { + STRLEN len; + unsigned long blocks = SvUV(ST(1)); + unsigned char *buf = (unsigned char *)(SvPV(ST(2), len)); + ctx->A = buf[ 0] | (buf[ 1]<<8) | (buf[ 2]<<16) | (buf[ 3]<<24); + ctx->B = buf[ 4] | (buf[ 5]<<8) | (buf[ 6]<<16) | (buf[ 7]<<24); + ctx->C = buf[ 8] | (buf[ 9]<<8) | (buf[10]<<16) | (buf[11]<<24); + ctx->D = buf[12] | (buf[13]<<8) | (buf[14]<<16) | (buf[15]<<24); + ctx->bytes_low = blocks << 6; + ctx->bytes_high = blocks >> 26; + if (items == 4) { + buf = (unsigned char *)(SvPV(ST(3), len)); + MD5Update(ctx, buf, len); + } + XSRETURN(1); /* ctx */ + } else if (items != 1) { + XSRETURN(0); + } + + w=ctx->A; out[ 0]=w; out[ 1]=(w>>8); out[ 2]=(w>>16); out[ 3]=(w>>24); + w=ctx->B; out[ 4]=w; out[ 5]=(w>>8); out[ 6]=(w>>16); out[ 7]=(w>>24); + w=ctx->C; out[ 8]=w; out[ 9]=(w>>8); out[10]=(w>>16); out[11]=(w>>24); + w=ctx->D; out[12]=w; out[13]=(w>>8); out[14]=(w>>16); out[15]=(w>>24); + + EXTEND(SP, 3); + ST(0) = sv_2mortal(newSVuv(ctx->bytes_high << 26 | + ctx->bytes_low >> 6)); + ST(1) = sv_2mortal(newSVpv(out, 16)); + ST(2) = sv_2mortal(newSVpv((char *)ctx->buffer, + ctx->bytes_low & 0x3F)); + XSRETURN(3); + +void md5(...) ALIAS: Digest::MD5::md5 = F_BIN @@ -750,7 +793,9 @@ md5(...) if (items == 1) { if (SvROK(ST(0))) { SV* sv = SvRV(ST(0)); - if (SvOBJECT(sv) && strEQ(HvNAME(SvSTASH(sv)), "Digest::MD5")) + char *name; + if (SvOBJECT(sv) && (name = HvNAME(SvSTASH(sv))) + && strEQ(name, "Digest::MD5")) msg = "probably called as method"; else msg = "called with reference argument"; @@ -763,7 +808,9 @@ md5(...) } else if (SvROK(ST(0))) { SV* sv = SvRV(ST(0)); - if (SvOBJECT(sv) && strEQ(HvNAME(SvSTASH(sv)), "Digest::MD5")) + char *name; + if (SvOBJECT(sv) && (name = HvNAME(SvSTASH(sv))) + && strEQ(name, "Digest::MD5")) msg = "probably called as method"; } } diff --git a/cpan/Digest-MD5/Makefile.PL b/cpan/Digest-MD5/Makefile.PL index 1d9337b1a9..1015058bac 100644 --- a/cpan/Digest-MD5/Makefile.PL +++ b/cpan/Digest-MD5/Makefile.PL @@ -31,7 +31,7 @@ WriteMakefile( }, 'META_MERGE' => { resources => { - repository => 'http://github.com/gisle/digest-md5', + repository => 'https://github.com/gisle/digest-md5', } }, @extra, diff --git a/cpan/Digest-MD5/t/files.t b/cpan/Digest-MD5/t/files.t index 60d284756d..d6b4fcb2cd 100644 --- a/cpan/Digest-MD5/t/files.t +++ b/cpan/Digest-MD5/t/files.t @@ -14,14 +14,14 @@ my $EXPECT; if (ord "A" == 193) { # EBCDIC $EXPECT = <<EOT; 0956ffb4f6416082b27d6680b4cf73fc README -b349234bb1005785bb6e377990209dc7 MD5.xs +2a61dd5022b11faa35eed27d1c6c98c2 MD5.xs 276da0aa4e9a08b7fe09430c9c5690aa rfc1321.txt EOT } else { # This is the output of: 'md5sum README MD5.xs rfc1321.txt' $EXPECT = <<EOT; 2f93400875dbb56f36691d5f69f3eba5 README -f908acbcf6bd32042f282b0deed61264 MD5.xs +0a0cf2512d18d24c6881d7d755e2b609 MD5.xs 754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt EOT } diff --git a/cpan/Digest-MD5/t/threads.t b/cpan/Digest-MD5/t/threads.t index 968fd0c2f4..64c2529a71 100644 --- a/cpan/Digest-MD5/t/threads.t +++ b/cpan/Digest-MD5/t/threads.t @@ -6,6 +6,8 @@ use Config; BEGIN { plan skip_all => 'Perl compiled without ithreads' unless $Config{useithreads}; + plan skip_all => 'no threads.pm' + unless eval { require threads }; plan tests => 2; } |