summaryrefslogtreecommitdiff
path: root/ext/Digest/MD5/MD5.xs
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-05-01 23:11:54 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-05-01 23:11:54 +0000
commit5a0465204af83dac035ba461e6e2a04febe9287d (patch)
tree21044c505e34c9cf303b7f7111a0f0483c7e3a6d /ext/Digest/MD5/MD5.xs
parent90f50fa0ea7e0d7f77f2fd13046b061b3d4e7499 (diff)
downloadperl-5a0465204af83dac035ba461e6e2a04febe9287d.tar.gz
Upgrade to Digest::MD5 2.18. files.t doesn't
work yet with blead, my bad. p4raw-id: //depot/perl@16321
Diffstat (limited to 'ext/Digest/MD5/MD5.xs')
-rw-r--r--ext/Digest/MD5/MD5.xs55
1 files changed, 47 insertions, 8 deletions
diff --git a/ext/Digest/MD5/MD5.xs b/ext/Digest/MD5/MD5.xs
index 0852e526db..4a30550f5c 100644
--- a/ext/Digest/MD5/MD5.xs
+++ b/ext/Digest/MD5/MD5.xs
@@ -1,3 +1,5 @@
+/* $Id: MD5.xs,v 1.34 2002/05/01 23:30:28 gisle Exp $ */
+
/*
* This library is free software; you can redistribute it and/or
* modify it under the same terms as Perl itself.
@@ -42,7 +44,27 @@ extern "C" {
}
#endif
-#ifndef SvPVbyte
+#include "patchlevel.h"
+#if PATCHLEVEL <= 4 && !defined(PL_dowarn)
+ #define PL_dowarn dowarn
+#endif
+
+#ifdef SvPVbyte
+ #if PERL_REVISION == 5 && PERL_VERSION < 7
+ /* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */
+ #undef SvPVbyte
+ #define SvPVbyte(sv, lp) \
+ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
+ ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp))
+
+ static char *
+ my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
+ {
+ sv_utf8_downgrade(sv,0);
+ return SvPV(sv,*lp);
+ }
+ #endif
+#else
#define SvPVbyte SvPV
#endif
@@ -619,14 +641,31 @@ md5(...)
unsigned char digeststr[16];
PPCODE:
MD5Init(&ctx);
- if (PL_dowarn && items > 1) {
- data = (unsigned char *)SvPVbyte(ST(0), len);
- if (len == 11 && memEQ("Digest::MD5", data, 11)) {
- char *f = (ix == F_BIN) ? "md5" :
- (ix == F_HEX) ? "md5_hex" : "md5_base64";
- warn("&Digest::MD5::%s function probably called as method", f);
- }
+
+ if (PL_dowarn) {
+ char *msg = 0;
+ if (items == 1) {
+ if (SvROK(ST(0))) {
+ SV* sv = SvRV(ST(0));
+ if (SvOBJECT(sv) && strEQ(HvNAME(SvSTASH(sv)), "Digest::MD5"))
+ msg = "probably called as method";
+ else
+ msg = "called with reference argument";
+ }
+ }
+ else if (items > 1) {
+ data = (unsigned char *)SvPVbyte(ST(0), len);
+ if (len == 11 && memEQ("Digest::MD5", data, 11)) {
+ msg = "probably called as class method";
+ }
+ }
+ if (msg) {
+ char *f = (ix == F_BIN) ? "md5" :
+ (ix == F_HEX) ? "md5_hex" : "md5_base64";
+ warn("&Digest::MD5::%s function %s", f, msg);
+ }
}
+
for (i = 0; i < items; i++) {
data = (unsigned char *)(SvPVbyte(ST(i), len));
MD5Update(&ctx, data, len);