Skip to content

Commit

Permalink
Storable implicitly needs >= v5.6.1, so remove code for earlier versi…
Browse files Browse the repository at this point in the history
…ons.

The perl code has 3-arg open and our, meaning at least v5.6.0, but the XS
code needs bytes_from_utf8 which is only in v5.6.1 and not in ppport.h
  • Loading branch information
nwc10 committed Aug 30, 2021
1 parent 2adefdb commit c4651bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
2 changes: 1 addition & 1 deletion dist/Storable/Storable.pm
Expand Up @@ -28,7 +28,7 @@ our @EXPORT_OK = qw(
our ($canonical, $forgive_me);

BEGIN {
our $VERSION = '3.24';
our $VERSION = '3.24_50';
}

our $recursion_limit;
Expand Down
41 changes: 2 additions & 39 deletions dist/Storable/Storable.xs
Expand Up @@ -519,14 +519,9 @@ static MAGIC *THX_sv_magicext(pTHX_

#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || defined(PERL_CAPI)

#if PERL_VERSION_LT(5,4,68)
#define dSTCXT_SV \
SV *perinterp_sv = get_sv(MY_VERSION, 0)
#else /* >= perl5.004_68 */
#define dSTCXT_SV \
SV *perinterp_sv = *hv_fetch(PL_modglobal, \
MY_VERSION, sizeof(MY_VERSION)-1, TRUE)
#endif /* < perl5.004_68 */

#define dSTCXT_PTR(T,name) \
T name = ((perinterp_sv \
Expand Down Expand Up @@ -1010,9 +1005,7 @@ static const char byteorderstr_56[] = {BYTEORDER_BYTES_56, 0};
#define STORABLE_BIN_MAJOR 2 /* Binary major "version" */
#define STORABLE_BIN_MINOR 11 /* Binary minor "version" */

#if PERL_VERSION_LT(5,6,0)
#define STORABLE_BIN_WRITE_MINOR 4
#elif !defined (SvVOK)
#if !defined (SvVOK)
/*
* Perl 5.6.0-5.8.0 can do weak references, but not vstring magic.
*/
Expand All @@ -1023,7 +1016,7 @@ static const char byteorderstr_56[] = {BYTEORDER_BYTES_56, 0};
#define STORABLE_BIN_WRITE_MINOR 11
#else
#define STORABLE_BIN_WRITE_MINOR 9
#endif /* PERL_VERSION_LT(5,6,0) */
#endif

#if PERL_VERSION_LT(5,8,1)
#define PL_sv_placeholder PL_sv_undef
Expand Down Expand Up @@ -1648,11 +1641,9 @@ static void init_store_context(pTHX_
*
* It is reported fixed in 5.005, hence the #if.
*/
#if PERL_VERSION_GE(5,5,0)
#define HBUCKETS 4096 /* Buckets for %hseen */
#ifndef USE_PTR_TABLE
HvMAX(cxt->hseen) = HBUCKETS - 1; /* keys %hseen = $HBUCKETS; */
#endif
#endif

/*
Expand All @@ -1665,9 +1656,7 @@ static void init_store_context(pTHX_

cxt->hclass = newHV(); /* Where seen classnames are stored */

#if PERL_VERSION_GE(5,5,0)
HvMAX(cxt->hclass) = HBUCKETS - 1; /* keys %hclass = $HBUCKETS; */
#endif

/*
* The 'hook' hash table is used to keep track of the references on
Expand Down Expand Up @@ -3309,12 +3298,6 @@ static int store_lhash(pTHX_ stcxt_t *cxt, HV *hv, unsigned char hash_flags)
*/
static int store_code(pTHX_ stcxt_t *cxt, CV *cv)
{
#if PERL_VERSION_LT(5,6,0)
/*
* retrieve_code does not work with perl 5.005 or less
*/
return store_other(aTHX_ cxt, (SV*)cv);
#else
dSP;
STRLEN len;
STRLEN count, reallen;
Expand Down Expand Up @@ -3405,7 +3388,6 @@ static int store_code(pTHX_ stcxt_t *cxt, CV *cv)
TRACEME(("ok (code)"));

return 0;
#endif
}

#if PERL_VERSION_LT(5,8,0)
Expand Down Expand Up @@ -6687,9 +6669,6 @@ static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, const char *cname)
*/
static SV *retrieve_code(pTHX_ stcxt_t *cxt, const char *cname)
{
#if PERL_VERSION_LT(5,6,0)
CROAK(("retrieve_code does not work with perl 5.005 or less\n"));
#else
dSP;
I32 type, count;
IV tagnum;
Expand Down Expand Up @@ -6811,7 +6790,6 @@ static SV *retrieve_code(pTHX_ stcxt_t *cxt, const char *cname)
av_store(cxt->aseen, tagnum, SvREFCNT_inc(sv));

return sv;
#endif
}

static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) {
Expand Down Expand Up @@ -7580,22 +7558,7 @@ static SV *do_retrieve(

if (!sv) {
TRACEMED(("retrieve ERROR"));
#if PERL_VERSION_LT(5,5,0)
/* perl 5.00405 seems to screw up at this point with an
'attempt to modify a read only value' error reported in the
eval { $self = pretrieve(*FILE) } in _retrieve.
I can't see what the cause of this error is, but I suspect a
bug in 5.004, as it seems to be capable of issuing spurious
errors or core dumping with matches on $@. I'm not going to
spend time on what could be a fruitless search for the cause,
so here's a bodge. If you're running 5.004 and don't like
this inefficiency, either upgrade to a newer perl, or you are
welcome to find the problem and send in a patch.
*/
return newSV(0);
#else
return &PL_sv_undef; /* Something went wrong, return undef */
#endif
}

TRACEMED(("retrieve got %s(0x%" UVxf ")",
Expand Down

0 comments on commit c4651bb

Please sign in to comment.