version-0.9918/0000755000175000017500000000000013076366721013444 5ustar jpeacockjpeacockversion-0.9918/vutil/0000755000175000017500000000000013076366721014607 5ustar jpeacockjpeacockversion-0.9918/vutil/vutil.c0000644000175000017500000006176213076366721016132 0ustar jpeacockjpeacock/* This file is part of the "version" CPAN distribution. Please avoid editing it in the perl core. */ #ifdef PERL_CORE # include "vutil.h" #endif #define VERSION_MAX 0x7FFFFFFF /* =for apidoc prescan_version Validate that a given string can be parsed as a version object, but doesn't actually perform the parsing. Can use either strict or lax validation rules. Can optionally set a number of hint variables to save the parsing code some time when tokenizing. =cut */ const char * #ifdef VUTIL_REPLACE_CORE Perl_prescan_version2(pTHX_ const char *s, bool strict, #else Perl_prescan_version(pTHX_ const char *s, bool strict, #endif const char **errstr, bool *sqv, int *ssaw_decimal, int *swidth, bool *salpha) { bool qv = (sqv ? *sqv : FALSE); int width = 3; int saw_decimal = 0; bool alpha = FALSE; const char *d = s; PERL_ARGS_ASSERT_PRESCAN_VERSION; PERL_UNUSED_CONTEXT; if (qv && isDIGIT(*d)) goto dotted_decimal_version; if (*d == 'v') { /* explicit v-string */ d++; if (isDIGIT(*d)) { qv = TRUE; } else { /* degenerate v-string */ /* requires v1.2.3 */ BADVERSION(s,errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } dotted_decimal_version: if (strict && d[0] == '0' && isDIGIT(d[1])) { /* no leading zeros allowed */ BADVERSION(s,errstr,"Invalid version format (no leading zeros)"); } while (isDIGIT(*d)) /* integer part */ d++; if (*d == '.') { saw_decimal++; d++; /* decimal point */ } else { if (strict) { /* require v1.2.3 */ BADVERSION(s,errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } else { goto version_prescan_finish; } } { int i = 0; int j = 0; while (isDIGIT(*d)) { /* just keep reading */ i++; while (isDIGIT(*d)) { d++; j++; /* maximum 3 digits between decimal */ if (strict && j > 3) { BADVERSION(s,errstr,"Invalid version format (maximum 3 digits between decimals)"); } } if (*d == '_') { if (strict) { BADVERSION(s,errstr,"Invalid version format (no underscores)"); } if ( alpha ) { BADVERSION(s,errstr,"Invalid version format (multiple underscores)"); } d++; alpha = TRUE; } else if (*d == '.') { if (alpha) { BADVERSION(s,errstr,"Invalid version format (underscores before decimal)"); } saw_decimal++; d++; } else if (!isDIGIT(*d)) { break; } j = 0; } if (strict && i < 2) { /* requires v1.2.3 */ BADVERSION(s,errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } } } /* end if dotted-decimal */ else { /* decimal versions */ int j = 0; /* may need this later */ /* special strict case for leading '.' or '0' */ if (strict) { if (*d == '.') { BADVERSION(s,errstr,"Invalid version format (0 before decimal required)"); } if (*d == '0' && isDIGIT(d[1])) { BADVERSION(s,errstr,"Invalid version format (no leading zeros)"); } } /* and we never support negative versions */ if ( *d == '-') { BADVERSION(s,errstr,"Invalid version format (negative version number)"); } /* consume all of the integer part */ while (isDIGIT(*d)) d++; /* look for a fractional part */ if (*d == '.') { /* we found it, so consume it */ saw_decimal++; d++; } else if (!*d || *d == ';' || isSPACE(*d) || *d == '{' || *d == '}') { if ( d == s ) { /* found nothing */ BADVERSION(s,errstr,"Invalid version format (version required)"); } /* found just an integer */ goto version_prescan_finish; } else if ( d == s ) { /* didn't find either integer or period */ BADVERSION(s,errstr,"Invalid version format (non-numeric data)"); } else if (*d == '_') { /* underscore can't come after integer part */ if (strict) { BADVERSION(s,errstr,"Invalid version format (no underscores)"); } else if (isDIGIT(d[1])) { BADVERSION(s,errstr,"Invalid version format (alpha without decimal)"); } else { BADVERSION(s,errstr,"Invalid version format (misplaced underscore)"); } } else { /* anything else after integer part is just invalid data */ BADVERSION(s,errstr,"Invalid version format (non-numeric data)"); } /* scan the fractional part after the decimal point*/ if (!isDIGIT(*d) && (strict || ! (!*d || *d == ';' || isSPACE(*d) || *d == '{' || *d == '}') )) { /* strict or lax-but-not-the-end */ BADVERSION(s,errstr,"Invalid version format (fractional part required)"); } while (isDIGIT(*d)) { d++; j++; if (*d == '.' && isDIGIT(d[-1])) { if (alpha) { BADVERSION(s,errstr,"Invalid version format (underscores before decimal)"); } if (strict) { BADVERSION(s,errstr,"Invalid version format (dotted-decimal versions must begin with 'v')"); } d = (char *)s; /* start all over again */ qv = TRUE; goto dotted_decimal_version; } if (*d == '_') { if (strict) { BADVERSION(s,errstr,"Invalid version format (no underscores)"); } if ( alpha ) { BADVERSION(s,errstr,"Invalid version format (multiple underscores)"); } if ( ! isDIGIT(d[1]) ) { BADVERSION(s,errstr,"Invalid version format (misplaced underscore)"); } width = j; d++; alpha = TRUE; } } } version_prescan_finish: while (isSPACE(*d)) d++; if (!isDIGIT(*d) && (! (!*d || *d == ';' || *d == '{' || *d == '}') )) { /* trailing non-numeric data */ BADVERSION(s,errstr,"Invalid version format (non-numeric data)"); } if (saw_decimal > 1 && d[-1] == '.') { /* no trailing period allowed */ BADVERSION(s,errstr,"Invalid version format (trailing decimal)"); } if (sqv) *sqv = qv; if (swidth) *swidth = width; if (ssaw_decimal) *ssaw_decimal = saw_decimal; if (salpha) *salpha = alpha; return d; } /* =for apidoc scan_version Returns a pointer to the next character after the parsed version string, as well as upgrading the passed in SV to an RV. Function must be called with an already existing SV like sv = newSV(0); s = scan_version(s, SV *sv, bool qv); Performs some preprocessing to the string to ensure that it has the correct characteristics of a version. Flags the object if it contains an underscore (which denotes this is an alpha version). The boolean qv denotes that the version should be interpreted as if it had multiple decimals, even if it doesn't. =cut */ const char * #ifdef VUTIL_REPLACE_CORE Perl_scan_version2(pTHX_ const char *s, SV *rv, bool qv) #else Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv) #endif { const char *start = s; const char *pos; const char *last; const char *errstr = NULL; int saw_decimal = 0; int width = 3; bool alpha = FALSE; bool vinf = FALSE; AV * av; SV * hv; PERL_ARGS_ASSERT_SCAN_VERSION; while (isSPACE(*s)) /* leading whitespace is OK */ s++; last = PRESCAN_VERSION(s, FALSE, &errstr, &qv, &saw_decimal, &width, &alpha); if (errstr) { /* "undef" is a special case and not an error */ if ( ! ( *s == 'u' && strEQ(s+1,"ndef")) ) { Perl_croak(aTHX_ "%s", errstr); } } start = s; if (*s == 'v') s++; pos = s; /* Now that we are through the prescan, start creating the object */ av = newAV(); hv = newSVrv(rv, "version"); /* create an SV and upgrade the RV */ (void)sv_upgrade(hv, SVt_PVHV); /* needs to be an HV type */ #ifndef NODEFAULT_SHAREKEYS HvSHAREKEYS_on(hv); /* key-sharing on by default */ #endif if ( qv ) (void)hv_stores(MUTABLE_HV(hv), "qv", newSViv(qv)); if ( alpha ) (void)hv_stores(MUTABLE_HV(hv), "alpha", newSViv(alpha)); if ( !qv && width < 3 ) (void)hv_stores(MUTABLE_HV(hv), "width", newSViv(width)); while (isDIGIT(*pos) || *pos == '_') pos++; if (!isALPHA(*pos)) { I32 rev; for (;;) { rev = 0; { /* this is atoi() that delimits on underscores */ const char *end = pos; I32 mult = 1; I32 orev; /* the following if() will only be true after the decimal * point of a version originally created with a bare * floating point number, i.e. not quoted in any way */ if ( !qv && s > start && saw_decimal == 1 ) { mult *= 100; while ( s < end ) { if (*s == '_') continue; orev = rev; rev += (*s - '0') * mult; mult /= 10; if ( (PERL_ABS(orev) > PERL_ABS(rev)) || (PERL_ABS(rev) > VERSION_MAX )) { Perl_ck_warner(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in version %d",VERSION_MAX); s = end - 1; rev = VERSION_MAX; vinf = 1; } s++; if ( *s == '_' ) s++; } } else { while (--end >= s) { int i; if (*end == '_') continue; i = (*end - '0'); if ( (mult == VERSION_MAX) || (i > VERSION_MAX / mult) || (i * mult > VERSION_MAX - rev)) { Perl_ck_warner(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in version"); end = s - 1; rev = VERSION_MAX; vinf = 1; } else rev += i * mult; if (mult > VERSION_MAX / 10) mult = VERSION_MAX; else mult *= 10; } } } /* Append revision */ av_push(av, newSViv(rev)); if ( vinf ) { s = last; break; } else if ( *pos == '.' ) { pos++; if (qv) { while (*pos == '0') ++pos; } s = pos; } else if ( *pos == '_' && isDIGIT(pos[1]) ) s = ++pos; else if ( *pos == ',' && isDIGIT(pos[1]) ) s = ++pos; else if ( isDIGIT(*pos) ) s = pos; else { s = pos; break; } if ( qv ) { while ( isDIGIT(*pos) || *pos == '_') pos++; } else { int digits = 0; while ( ( isDIGIT(*pos) || *pos == '_' ) && digits < 3 ) { if ( *pos != '_' ) digits++; pos++; } } } } if ( qv ) { /* quoted versions always get at least three terms*/ SSize_t len = AvFILLp(av); /* This for loop appears to trigger a compiler bug on OS X, as it loops infinitely. Yes, len is negative. No, it makes no sense. Compiler in question is: gcc version 3.3 20030304 (Apple Computer, Inc. build 1640) for ( len = 2 - len; len > 0; len-- ) av_push(MUTABLE_AV(sv), newSViv(0)); */ len = 2 - len; while (len-- > 0) av_push(av, newSViv(0)); } /* need to save off the current version string for later */ if ( vinf ) { SV * orig = newSVpvn("v.Inf", sizeof("v.Inf")-1); (void)hv_stores(MUTABLE_HV(hv), "original", orig); (void)hv_stores(MUTABLE_HV(hv), "vinf", newSViv(1)); } else if ( s > start ) { SV * orig = newSVpvn(start,s-start); if ( qv && saw_decimal == 1 && *start != 'v' ) { /* need to insert a v to be consistent */ sv_insert(orig, 0, 0, "v", 1); } (void)hv_stores(MUTABLE_HV(hv), "original", orig); } else { (void)hv_stores(MUTABLE_HV(hv), "original", newSVpvs("0")); av_push(av, newSViv(0)); } /* And finally, store the AV in the hash */ (void)hv_stores(MUTABLE_HV(hv), "version", newRV_noinc(MUTABLE_SV(av))); /* fix RT#19517 - special case 'undef' as string */ if ( *s == 'u' && strEQ(s+1,"ndef") ) { s += 5; } return s; } /* =for apidoc new_version Returns a new version object based on the passed in SV: SV *sv = new_version(SV *ver); Does not alter the passed in ver SV. See "upg_version" if you want to upgrade the SV. =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_new_version2(pTHX_ SV *ver) #else Perl_new_version(pTHX_ SV *ver) #endif { SV * const rv = newSV(0); PERL_ARGS_ASSERT_NEW_VERSION; if ( ISA_VERSION_OBJ(ver) ) /* can just copy directly */ { SSize_t key; AV * const av = newAV(); AV *sav; /* This will get reblessed later if a derived class*/ SV * const hv = newSVrv(rv, "version"); (void)sv_upgrade(hv, SVt_PVHV); /* needs to be an HV type */ #ifndef NODEFAULT_SHAREKEYS HvSHAREKEYS_on(hv); /* key-sharing on by default */ #endif if ( SvROK(ver) ) ver = SvRV(ver); /* Begin copying all of the elements */ if ( hv_exists(MUTABLE_HV(ver), "qv", 2) ) (void)hv_stores(MUTABLE_HV(hv), "qv", newSViv(1)); if ( hv_exists(MUTABLE_HV(ver), "alpha", 5) ) (void)hv_stores(MUTABLE_HV(hv), "alpha", newSViv(1)); { SV ** svp = hv_fetchs(MUTABLE_HV(ver), "width", FALSE); if(svp) { const I32 width = SvIV(*svp); (void)hv_stores(MUTABLE_HV(hv), "width", newSViv(width)); } } { SV ** svp = hv_fetchs(MUTABLE_HV(ver), "original", FALSE); if(svp) (void)hv_stores(MUTABLE_HV(hv), "original", newSVsv(*svp)); } sav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(ver), "version", FALSE))); /* This will get reblessed later if a derived class*/ for ( key = 0; key <= av_len(sav); key++ ) { SV * const sv = *av_fetch(sav, key, FALSE); const I32 rev = SvIV(sv); av_push(av, newSViv(rev)); } (void)hv_stores(MUTABLE_HV(hv), "version", newRV_noinc(MUTABLE_SV(av))); return rv; } #ifdef SvVOK { const MAGIC* const mg = SvVSTRING_mg(ver); if ( mg ) { /* already a v-string */ const STRLEN len = mg->mg_len; const char * const version = (const char*)mg->mg_ptr; char *raw, *under; static const char underscore[] = "_"; sv_setpvn(rv,version,len); raw = SvPV_nolen(rv); under = ninstr(raw, raw+len, underscore, underscore + 1); if (under) { Move(under + 1, under, raw + len - under - 1, char); SvCUR(rv)--; *SvEND(rv) = '\0'; } /* this is for consistency with the pure Perl class */ if ( isDIGIT(*version) ) sv_insert(rv, 0, 0, "v", 1); } else { #endif SvSetSV_nosteal(rv, ver); /* make a duplicate */ #ifdef SvVOK } } #endif sv_2mortal(rv); /* in case upg_version croaks before it returns */ return SvREFCNT_inc_NN(UPG_VERSION(rv, FALSE)); } /* =for apidoc upg_version In-place upgrade of the supplied SV to a version object. SV *sv = upg_version(SV *sv, bool qv); Returns a pointer to the upgraded SV. Set the boolean qv if you want to force this SV to be interpreted as an "extended" version. =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_upg_version2(pTHX_ SV *ver, bool qv) #else Perl_upg_version(pTHX_ SV *ver, bool qv) #endif { const char *version, *s; #ifdef SvVOK const MAGIC *mg; #endif #if PERL_VERSION_LT(5,19,8) && defined(USE_ITHREADS) ENTER; #endif PERL_ARGS_ASSERT_UPG_VERSION; if ( (SvUOK(ver) && SvUVX(ver) > VERSION_MAX) || (SvIOK(ver) && SvIVX(ver) > VERSION_MAX) ) { /* out of bounds [unsigned] integer */ STRLEN len; char tbuf[64]; len = my_snprintf(tbuf, sizeof(tbuf), "%d", VERSION_MAX); version = savepvn(tbuf, len); SAVEFREEPV(version); Perl_ck_warner(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in version %d",VERSION_MAX); } else if ( SvUOK(ver) || SvIOK(ver)) #if PERL_VERSION_LT(5,17,2) VER_IV: #endif { version = savesvpv(ver); SAVEFREEPV(version); } else if (SvNOK(ver) && !( SvPOK(ver) && SvCUR(ver) == 3 ) ) #if PERL_VERSION_LT(5,17,2) VER_NV: #endif { STRLEN len; /* may get too much accuracy */ char tbuf[64]; SV *sv = SvNVX(ver) > 10e50 ? newSV(64) : 0; char *buf; #if PERL_VERSION_GE(5,19,0) if (SvPOK(ver)) { /* dualvar? */ goto VER_PV; } #endif #ifdef USE_LOCALE_NUMERIC { const char * const cur_numeric = setlocale(LC_NUMERIC, NULL); assert(cur_numeric); /* XS code can set the locale without us knowing. To protect the * version number parsing, which requires the radix character to be a * dot, update our records as to what the locale is, so that our * existing macro mechanism can correctly change it to a dot and back * if necessary. This code is extremely unlikely to be in a loop, so * the extra work will have a negligible performance impact. See [perl * #121930]. * * If the current locale is a standard one, but we are expecting it to * be a different, underlying locale, update our records to make the * underlying locale this (standard) one. If the current locale is not * a standard one, we should be expecting a non-standard one, the same * one that we have recorded as the underlying locale. If not, update * our records. */ if (strEQ(cur_numeric, "C") || strEQ(cur_numeric, "POSIX")) { if (! PL_numeric_standard) { new_numeric(cur_numeric); } } else if (PL_numeric_standard || ! PL_numeric_name || strNE(PL_numeric_name, cur_numeric)) { new_numeric(cur_numeric); } } #endif { /* Braces needed because macro just below declares a variable */ STORE_NUMERIC_LOCAL_SET_STANDARD(); LOCK_NUMERIC_STANDARD(); if (sv) { Perl_sv_catpvf(aTHX_ sv, "%.9"NVff, SvNVX(ver)); len = SvCUR(sv); buf = SvPVX(sv); } else { len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver)); buf = tbuf; } UNLOCK_NUMERIC_STANDARD(); RESTORE_NUMERIC_LOCAL(); } while (buf[len-1] == '0' && len > 0) len--; if ( buf[len-1] == '.' ) len--; /* eat the trailing decimal */ version = savepvn(buf, len); SAVEFREEPV(version); SvREFCNT_dec(sv); } #ifdef SvVOK else if ( (mg = SvVSTRING_mg(ver)) ) { /* already a v-string */ version = savepvn( (const char*)mg->mg_ptr,mg->mg_len ); SAVEFREEPV(version); qv = TRUE; } #endif else if ( SvPOK(ver))/* must be a string or something like a string */ VER_PV: { STRLEN len; version = savepvn(SvPV(ver,len), SvCUR(ver)); SAVEFREEPV(version); #ifndef SvVOK # if PERL_VERSION > 5 /* This will only be executed for 5.6.0 - 5.8.0 inclusive */ if ( len >= 3 && !instr(version,".") && !instr(version,"_")) { /* may be a v-string */ char *testv = (char *)version; STRLEN tlen = len; for (tlen=0; tlen < len; tlen++, testv++) { /* if one of the characters is non-text assume v-string */ if (testv[0] < ' ') { SV * const nsv = sv_newmortal(); const char *nver; const char *pos; int saw_decimal = 0; sv_setpvf(nsv,"v%vd",ver); pos = nver = savepv(SvPV_nolen(nsv)); SAVEFREEPV(pos); /* scan the resulting formatted string */ pos++; /* skip the leading 'v' */ while ( *pos == '.' || isDIGIT(*pos) ) { if ( *pos == '.' ) saw_decimal++ ; pos++; } /* is definitely a v-string */ if ( saw_decimal >= 2 ) { version = nver; } break; } } } # endif #endif } #if PERL_VERSION_LT(5,17,2) else if (SvIOKp(ver)) { goto VER_IV; } else if (SvNOKp(ver)) { goto VER_NV; } else if (SvPOKp(ver)) { goto VER_PV; } #endif else { /* no idea what this is */ Perl_croak(aTHX_ "Invalid version format (non-numeric data)"); } s = SCAN_VERSION(version, ver, qv); if ( *s != '\0' ) Perl_ck_warner(aTHX_ packWARN(WARN_MISC), "Version string '%s' contains invalid data; " "ignoring: '%s'", version, s); #if PERL_VERSION_LT(5,19,8) && defined(USE_ITHREADS) LEAVE; #endif return ver; } /* =for apidoc vverify Validates that the SV contains valid internal structure for a version object. It may be passed either the version object (RV) or the hash itself (HV). If the structure is valid, it returns the HV. If the structure is invalid, it returns NULL. SV *hv = vverify(sv); Note that it only confirms the bare minimum structure (so as not to get confused by derived classes which may contain additional hash entries): =over 4 =item * The SV is an HV or a reference to an HV =item * The hash contains a "version" key =item * The "version" key has a reference to an AV as its value =back =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_vverify2(pTHX_ SV *vs) #else Perl_vverify(pTHX_ SV *vs) #endif { SV *sv; SV **svp; PERL_ARGS_ASSERT_VVERIFY; if ( SvROK(vs) ) vs = SvRV(vs); /* see if the appropriate elements exist */ if ( SvTYPE(vs) == SVt_PVHV && (svp = hv_fetchs(MUTABLE_HV(vs), "version", FALSE)) && (sv = SvRV(*svp)) && SvTYPE(sv) == SVt_PVAV ) return vs; else return NULL; } /* =for apidoc vnumify Accepts a version object and returns the normalized floating point representation. Call like: sv = vnumify(rv); NOTE: you can pass either the object directly or the SV contained within the RV. The SV returned has a refcount of 1. =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_vnumify2(pTHX_ SV *vs) #else Perl_vnumify(pTHX_ SV *vs) #endif { SSize_t i, len; I32 digit; bool alpha = FALSE; SV *sv; AV *av; PERL_ARGS_ASSERT_VNUMIFY; /* extract the HV from the object */ vs = VVERIFY(vs); if ( ! vs ) Perl_croak(aTHX_ "Invalid version object"); /* see if various flags exist */ if ( hv_exists(MUTABLE_HV(vs), "alpha", 5 ) ) alpha = TRUE; if (alpha) { Perl_ck_warner(aTHX_ packWARN(WARN_NUMERIC), "alpha->numify() is lossy"); } /* attempt to retrieve the version array */ if ( !(av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE))) ) ) { return newSVpvs("0"); } len = av_len(av); if ( len == -1 ) { return newSVpvs("0"); } { SV * tsv = *av_fetch(av, 0, 0); digit = SvIV(tsv); } sv = Perl_newSVpvf(aTHX_ "%d.", (int)PERL_ABS(digit)); for ( i = 1 ; i <= len ; i++ ) { SV * tsv = *av_fetch(av, i, 0); digit = SvIV(tsv); Perl_sv_catpvf(aTHX_ sv, "%03d", (int)digit); } if ( len == 0 ) { sv_catpvs(sv, "000"); } return sv; } /* =for apidoc vnormal Accepts a version object and returns the normalized string representation. Call like: sv = vnormal(rv); NOTE: you can pass either the object directly or the SV contained within the RV. The SV returned has a refcount of 1. =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_vnormal2(pTHX_ SV *vs) #else Perl_vnormal(pTHX_ SV *vs) #endif { I32 i, len, digit; SV *sv; AV *av; PERL_ARGS_ASSERT_VNORMAL; /* extract the HV from the object */ vs = VVERIFY(vs); if ( ! vs ) Perl_croak(aTHX_ "Invalid version object"); av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE))); len = av_len(av); if ( len == -1 ) { return newSVpvs(""); } { SV * tsv = *av_fetch(av, 0, 0); digit = SvIV(tsv); } sv = Perl_newSVpvf(aTHX_ "v%"IVdf, (IV)digit); for ( i = 1 ; i <= len ; i++ ) { SV * tsv = *av_fetch(av, i, 0); digit = SvIV(tsv); Perl_sv_catpvf(aTHX_ sv, ".%"IVdf, (IV)digit); } if ( len <= 2 ) { /* short version, must be at least three */ for ( len = 2 - len; len != 0; len-- ) sv_catpvs(sv,".0"); } return sv; } /* =for apidoc vstringify In order to maintain maximum compatibility with earlier versions of Perl, this function will return either the floating point notation or the multiple dotted notation, depending on whether the original version contained 1 or more dots, respectively. The SV returned has a refcount of 1. =cut */ SV * #ifdef VUTIL_REPLACE_CORE Perl_vstringify2(pTHX_ SV *vs) #else Perl_vstringify(pTHX_ SV *vs) #endif { SV ** svp; PERL_ARGS_ASSERT_VSTRINGIFY; /* extract the HV from the object */ vs = VVERIFY(vs); if ( ! vs ) Perl_croak(aTHX_ "Invalid version object"); svp = hv_fetchs(MUTABLE_HV(vs), "original", FALSE); if (svp) { SV *pv; pv = *svp; if ( SvPOK(pv) #if PERL_VERSION_LT(5,17,2) || SvPOKp(pv) #endif ) return newSVsv(pv); else return &PL_sv_undef; } else { if ( hv_exists(MUTABLE_HV(vs), "qv", 2) ) return VNORMAL(vs); else return VNUMIFY(vs); } } /* =for apidoc vcmp Version object aware cmp. Both operands must already have been converted into version objects. =cut */ int #ifdef VUTIL_REPLACE_CORE Perl_vcmp2(pTHX_ SV *lhv, SV *rhv) #else Perl_vcmp(pTHX_ SV *lhv, SV *rhv) #endif { SSize_t i,l,m,r; I32 retval; I32 left = 0; I32 right = 0; AV *lav, *rav; PERL_ARGS_ASSERT_VCMP; /* extract the HVs from the objects */ lhv = VVERIFY(lhv); rhv = VVERIFY(rhv); if ( ! ( lhv && rhv ) ) Perl_croak(aTHX_ "Invalid version object"); /* get the left hand term */ lav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(lhv), "version", FALSE))); /* and the right hand term */ rav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(rhv), "version", FALSE))); l = av_len(lav); r = av_len(rav); m = l < r ? l : r; retval = 0; i = 0; while ( i <= m && retval == 0 ) { SV * const lsv = *av_fetch(lav,i,0); SV * rsv; left = SvIV(lsv); rsv = *av_fetch(rav,i,0); right = SvIV(rsv); if ( left < right ) retval = -1; if ( left > right ) retval = +1; i++; } if ( l != r && retval == 0 ) /* possible match except for trailing 0's */ { if ( l < r ) { while ( i <= r && retval == 0 ) { SV * const rsv = *av_fetch(rav,i,0); if ( SvIV(rsv) != 0 ) retval = -1; /* not a match after all */ i++; } } else { while ( i <= l && retval == 0 ) { SV * const lsv = *av_fetch(lav,i,0); if ( SvIV(lsv) != 0 ) retval = +1; /* not a match after all */ i++; } } } return retval; } /* ex: set ro: */ version-0.9918/vutil/lib/0000755000175000017500000000000013076366721015355 5ustar jpeacockjpeacockversion-0.9918/vutil/lib/version/0000755000175000017500000000000013076366721017042 5ustar jpeacockjpeacockversion-0.9918/vutil/lib/version/vxs.pm0000644000175000017500000000076613076366721020231 0ustar jpeacockjpeacock#!perl -w package version::vxs; use v5.10; use strict; use vars qw(@ISA $VERSION $CLASS ); $VERSION = 0.9918; $CLASS = 'version::vxs'; eval { require XSLoader; local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION XSLoader::load('version::vxs', $VERSION); 1; } or do { require DynaLoader; push @ISA, 'DynaLoader'; local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION bootstrap version::vxs $VERSION; }; # Preloaded methods go here. 1; version-0.9918/vutil/vxs.inc0000644000175000017500000002566013076366721016133 0ustar jpeacockjpeacock/* This file is part of the "version" CPAN distribution. Please avoid editing it in the perl core. */ #ifdef PERL_CORE # define VXS_CLASS "version" # define VXSp(name) XS_##name /* VXSXSDP = XSUB Details Proto */ # define VXSXSDP(x) x #else # define VXS_CLASS "version::vxs" # define VXSp(name) VXS_##name /* proto member is unused in version, it is used in CORE by non version xsubs */ # define VXSXSDP(x) #endif #ifndef XS_INTERNAL # define XS_INTERNAL(name) static XSPROTO(name) #endif #define VXS(name) XS_INTERNAL(VXSp(name)); XS_INTERNAL(VXSp(name)) /* uses PUSHs, so SP must be at start, PUSHs sv on Perl stack, then returns from xsub; this is a little more machine code/tailcall friendly than mPUSHs(foo); PUTBACK; return; */ #define VXS_RETURN_M_SV(sv) \ STMT_START { \ SV * sv_vtc = sv; \ PUSHs(sv_vtc); \ PUTBACK; \ sv_2mortal(sv_vtc); \ return; \ } STMT_END #ifdef VXS_XSUB_DETAILS # ifdef PERL_CORE {"UNIVERSAL::VERSION", VXSp(universal_version), VXSXSDP(NULL)}, # endif {VXS_CLASS "::_VERSION", VXSp(universal_version), VXSXSDP(NULL)}, {VXS_CLASS "::()", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::new", VXSp(version_new), VXSXSDP(NULL)}, {VXS_CLASS "::parse", VXSp(version_new), VXSXSDP(NULL)}, {VXS_CLASS "::(\"\"", VXSp(version_stringify), VXSXSDP(NULL)}, {VXS_CLASS "::stringify", VXSp(version_stringify), VXSXSDP(NULL)}, {VXS_CLASS "::(0+", VXSp(version_numify), VXSXSDP(NULL)}, {VXS_CLASS "::numify", VXSp(version_numify), VXSXSDP(NULL)}, {VXS_CLASS "::normal", VXSp(version_normal), VXSXSDP(NULL)}, {VXS_CLASS "::(cmp", VXSp(version_vcmp), VXSXSDP(NULL)}, {VXS_CLASS "::(<=>", VXSp(version_vcmp), VXSXSDP(NULL)}, # ifdef PERL_CORE {VXS_CLASS "::vcmp", XS_version_vcmp, VXSXSDP(NULL)}, # else {VXS_CLASS "::VCMP", VXS_version_vcmp, VXSXSDP(NULL)}, # endif {VXS_CLASS "::(bool", VXSp(version_boolean), VXSXSDP(NULL)}, {VXS_CLASS "::boolean", VXSp(version_boolean), VXSXSDP(NULL)}, {VXS_CLASS "::(+", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(-", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(*", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(/", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(+=", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(-=", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(*=", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(/=", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(abs", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::(nomethod", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::noop", VXSp(version_noop), VXSXSDP(NULL)}, {VXS_CLASS "::is_alpha", VXSp(version_is_alpha), VXSXSDP(NULL)}, {VXS_CLASS "::qv", VXSp(version_qv), VXSXSDP(NULL)}, {VXS_CLASS "::declare", VXSp(version_qv), VXSXSDP(NULL)}, {VXS_CLASS "::is_qv", VXSp(version_is_qv), VXSXSDP(NULL)}, #else #ifndef dVAR # define dVAR #endif #ifdef HvNAME_HEK typedef HEK HVNAME; # ifndef HEKf # define HEKfARG(arg) ((void*)(sv_2mortal(newSVhek(arg)))) # define HEKf SVf # endif #else typedef char HVNAME; # define HvNAME_HEK HvNAME_get # define HEKfARG(arg) arg # define HEKf "s" #endif VXS(universal_version) { dXSARGS; HV *pkg; GV **gvp; GV *gv; SV *sv; const char *undef; PERL_UNUSED_ARG(cv); if (items < 1) Perl_croak(aTHX_ "Usage: UNIVERSAL::VERSION(sv, ...)"); sv = ST(0); if (SvROK(sv)) { sv = (SV*)SvRV(sv); if (!SvOBJECT(sv)) Perl_croak(aTHX_ "Cannot find version of an unblessed reference"); pkg = SvSTASH(sv); } else { pkg = gv_stashsv(sv, FALSE); } gvp = pkg ? (GV**)hv_fetchs(pkg,"VERSION",FALSE) : (GV**)NULL; if (gvp && isGV(gv = *gvp) && (sv = GvSV(gv)) && SvOK(sv)) { sv = sv_mortalcopy(sv); if ( ! ISA_VERSION_OBJ(sv) ) UPG_VERSION(sv, FALSE); undef = NULL; } else { sv = &PL_sv_undef; undef = "(undef)"; } if (items > 1) { SV *req = ST(1); if (undef) { if (pkg) { const HVNAME* const name = HvNAME_HEK(pkg); #if PERL_VERSION == 5 Perl_croak(aTHX_ "%s version %s required--this is only version ", name, SvPVx_nolen_const(req)); #else Perl_croak(aTHX_ "%" HEKf " does not define $%"HEKf "::VERSION--version check failed", HEKfARG(name), HEKfARG(name)); #endif } else { #if PERL_VERSION >= 8 Perl_croak(aTHX_ "%" SVf " defines neither package nor VERSION--" "version check failed", (void*)(ST(0)) ); #else Perl_croak(aTHX_ "%s does not define $%s::VERSION--version check failed", SvPVx_nolen_const(ST(0)), SvPVx_nolen_const(ST(0)) ); #endif } } if ( ! ISA_VERSION_OBJ(req) ) { /* req may very well be R/O, so create a new object */ req = sv_2mortal( NEW_VERSION(req) ); } if ( VCMP( req, sv ) > 0 ) { if ( hv_exists(MUTABLE_HV(SvRV(req)), "qv", 2 ) ) { req = VNORMAL(req); sv = VNORMAL(sv); } else { req = VSTRINGIFY(req); sv = VSTRINGIFY(sv); } Perl_croak(aTHX_ "%" HEKf " version %" SVf " required--" "this is only version %" SVf, HEKfARG(HvNAME_HEK(pkg)), SVfARG(sv_2mortal(req)), SVfARG(sv_2mortal(sv))); } } /* if the package's $VERSION is not undef, it is upgraded to be a version object */ if (ISA_VERSION_OBJ(sv)) { ST(0) = sv_2mortal(VSTRINGIFY(sv)); } else { ST(0) = sv; } XSRETURN(1); } VXS(version_new) { dXSARGS; SV *vs; SV *rv; const char * classname = ""; STRLEN len; U32 flags = 0; SV * svarg0 = NULL; PERL_UNUSED_VAR(cv); SP -= items; switch((U32)items) { case 3: { SV * svarg2; vs = sv_newmortal(); svarg2 = ST(2); #if PERL_VERSION == 5 sv_setpvf(vs,"v%s",SvPV_nolen_const(svarg2)); #else Perl_sv_setpvf(aTHX_ vs,"v%s",SvPV_nolen_const(svarg2)); #endif break; } case 2: vs = ST(1); /* Just in case this is something like a tied hash */ SvGETMAGIC(vs); if(SvOK(vs)) break; /* drop through */ case 1: /* no param or explicit undef */ /* create empty object */ vs = sv_newmortal(); sv_setpvs(vs,"undef"); break; default: case 0: Perl_croak_nocontext("Usage: version::new(class, version)"); } svarg0 = ST(0); if ( sv_isobject(svarg0) ) { /* get the class if called as an object method */ const HV * stash = SvSTASH(SvRV(svarg0)); classname = HvNAME_get(stash); len = HvNAMELEN_get(stash); #ifdef HvNAMEUTF8 flags = HvNAMEUTF8(stash) ? SVf_UTF8 : 0; #endif } else { classname = SvPV_nomg(svarg0, len); flags = SvUTF8(svarg0); } rv = NEW_VERSION(vs); if ( len != sizeof(VXS_CLASS)-1 || strcmp(classname,VXS_CLASS) != 0 ) /* inherited new() */ #if PERL_VERSION == 5 sv_bless(rv, gv_stashpv((char *)classname, GV_ADD)); #else sv_bless(rv, gv_stashpvn(classname, len, GV_ADD | flags)); #endif VXS_RETURN_M_SV(rv); } #define VTYPECHECK(var, val, varname) \ STMT_START { \ SV * sv_vtc = val; \ if (ISA_VERSION_OBJ(sv_vtc)) { \ (var) = SvRV(sv_vtc); \ } \ else \ Perl_croak_nocontext(varname " is not of type version"); \ } STMT_END VXS(version_stringify) { dXSARGS; if (items < 1) croak_xs_usage(cv, "lobj, ..."); SP -= items; { SV * lobj; VTYPECHECK(lobj, ST(0), "lobj"); VXS_RETURN_M_SV(VSTRINGIFY(lobj)); } } VXS(version_numify) { dXSARGS; if (items < 1) croak_xs_usage(cv, "lobj, ..."); SP -= items; { SV * lobj; VTYPECHECK(lobj, ST(0), "lobj"); VXS_RETURN_M_SV(VNUMIFY(lobj)); } } VXS(version_normal) { dXSARGS; if (items != 1) croak_xs_usage(cv, "ver"); SP -= items; { SV * ver; VTYPECHECK(ver, ST(0), "ver"); VXS_RETURN_M_SV(VNORMAL(ver)); } } VXS(version_vcmp) { dXSARGS; if (items < 1) croak_xs_usage(cv, "lobj, ..."); SP -= items; { SV * lobj; VTYPECHECK(lobj, ST(0), "lobj"); { SV *rs; SV *rvs; SV * robj = ST(1); const IV swap = (IV)SvIV(ST(2)); if ( !ISA_VERSION_OBJ(robj) ) { robj = sv_2mortal(NEW_VERSION(SvOK(robj) ? robj : newSVpvs_flags("0", SVs_TEMP))); } rvs = SvRV(robj); if ( swap ) { rs = newSViv(VCMP(rvs,lobj)); } else { rs = newSViv(VCMP(lobj,rvs)); } VXS_RETURN_M_SV(rs); } } } VXS(version_boolean) { dXSARGS; SV *lobj; if (items < 1) croak_xs_usage(cv, "lobj, ..."); SP -= items; VTYPECHECK(lobj, ST(0), "lobj"); { SV * const rs = newSViv( VCMP(lobj, sv_2mortal(NEW_VERSION( sv_2mortal(newSVpvs("0")) )) ) ); VXS_RETURN_M_SV(rs); } } VXS(version_noop) { dXSARGS; if (items < 1) croak_xs_usage(cv, "lobj, ..."); if (ISA_VERSION_OBJ(ST(0))) Perl_croak(aTHX_ "operation not supported with version object"); else Perl_croak(aTHX_ "lobj is not of type version"); XSRETURN_EMPTY; } static void S_version_check_key(pTHX_ CV * cv, const char * key, int keylen) { dXSARGS; if (items != 1) croak_xs_usage(cv, "lobj"); { SV *lobj = POPs; SV *ret; VTYPECHECK(lobj, lobj, "lobj"); if ( hv_exists(MUTABLE_HV(lobj), key, keylen ) ) ret = &PL_sv_yes; else ret = &PL_sv_no; PUSHs(ret); PUTBACK; return; } } VXS(version_is_alpha) { S_version_check_key(aTHX_ cv, "alpha", 5); } VXS(version_qv) { dXSARGS; PERL_UNUSED_ARG(cv); SP -= items; { SV * ver = ST(0); SV * sv0 = ver; SV * rv; STRLEN len = 0; const char * classname = ""; U32 flags = 0; if ( items == 2 ) { SV * sv1 = ST(1); SvGETMAGIC(sv1); if (SvOK(sv1)) { ver = sv1; } else { Perl_croak(aTHX_ "Invalid version format (version required)"); } if ( sv_isobject(sv0) ) { /* class called as an object method */ const HV * stash = SvSTASH(SvRV(sv0)); classname = HvNAME_get(stash); len = HvNAMELEN_get(stash); #ifdef HvNAMEUTF8 flags = HvNAMEUTF8(stash) ? SVf_UTF8 : 0; #endif } else { classname = SvPV(sv0, len); flags = SvUTF8(sv0); } } if ( !SvVOK(ver) ) { /* not already a v-string */ rv = sv_newmortal(); SvSetSV_nosteal(rv,ver); /* make a duplicate */ UPG_VERSION(rv, TRUE); } else { rv = sv_2mortal(NEW_VERSION(ver)); } if ( items == 2 && (len != 7 || strcmp(classname,"version")) ) { /* inherited new() */ #if PERL_VERSION == 5 sv_bless(rv, gv_stashpv((char *)classname, GV_ADD)); #else sv_bless(rv, gv_stashpvn(classname, len, GV_ADD | flags)); #endif } PUSHs(rv); } PUTBACK; return; } VXS(version_is_qv) { S_version_check_key(aTHX_ cv, "qv", 2); } #endif version-0.9918/vutil/Makefile.PL0000644000175000017500000000043212750333532016550 0ustar jpeacockjpeacock#!/usr/bin/perl -w use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'version::vxs', AUTHOR => 'John Peacock ', VERSION_FROM => 'lib/version/vxs.pm', depend => { qw< vxs.c vxs.inc > }, ); version-0.9918/vutil/vutil.h0000644000175000017500000001645513076366721016136 0ustar jpeacockjpeacock/* This file is part of the "version" CPAN distribution. Please avoid editing it in the perl core. */ #ifndef PERL_CORE # include "ppport.h" #endif /* The MUTABLE_*() macros cast pointers to the types shown, in such a way * (compiler permitting) that casting away const-ness will give a warning; * e.g.: * * const SV *sv = ...; * AV *av1 = (AV*)sv; <== BAD: the const has been silently cast away * AV *av2 = MUTABLE_AV(sv); <== GOOD: it may warn */ #ifndef MUTABLE_PTR # if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) # else # define MUTABLE_PTR(p) ((void *) (p)) # endif # define MUTABLE_AV(p) ((AV *)MUTABLE_PTR(p)) # define MUTABLE_CV(p) ((CV *)MUTABLE_PTR(p)) # define MUTABLE_GV(p) ((GV *)MUTABLE_PTR(p)) # define MUTABLE_HV(p) ((HV *)MUTABLE_PTR(p)) # define MUTABLE_IO(p) ((IO *)MUTABLE_PTR(p)) # define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) #endif #ifndef SvPVx_nolen_const # if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define SvPVx_nolen_const(sv) ({SV *_sv = (sv); SvPV_nolen_const(_sv); }) # else # define SvPVx_nolen_const(sv) (SvPV_nolen_const(sv)) # endif #endif #ifndef PERL_ARGS_ASSERT_CK_WARNER static void Perl_ck_warner(pTHX_ U32 err, const char* pat, ...); # ifdef vwarner static void Perl_ck_warner(pTHX_ U32 err, const char* pat, ...) { va_list args; PERL_UNUSED_ARG(err); if (ckWARN(err)) { va_list args; va_start(args, pat); vwarner(err, pat, &args); va_end(args); } } # else /* yes this replicates my_warner */ static void Perl_ck_warner(pTHX_ U32 err, const char* pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } # endif #endif #define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) #define PERL_DECIMAL_VERSION \ PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) #define PERL_VERSION_LT(r,v,s) \ (PERL_DECIMAL_VERSION < PERL_VERSION_DECIMAL(r,v,s)) #define PERL_VERSION_GE(r,v,s) \ (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) #if PERL_VERSION_LT(5,15,4) # define ISA_VERSION_OBJ(v) (sv_isobject(v) && sv_derived_from(v,"version")) #else # define ISA_VERSION_OBJ(v) (sv_isobject(v) && sv_derived_from_pvn(v,"version",7,0)) #endif #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) /* prototype to pass -Wmissing-prototypes */ STATIC void S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params); STATIC void S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params) { const GV *const gv = CvGV(cv); PERL_ARGS_ASSERT_CROAK_XS_USAGE; if (gv) { const char *const gvname = GvNAME(gv); const HV *const stash = GvSTASH(gv); const char *const hvname = stash ? HvNAME(stash) : NULL; if (hvname) Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params); else Perl_croak_nocontext("Usage: %s(%s)", gvname, params); } else { /* Pants. I don't think that it should be possible to get here. */ Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); } } #ifdef PERL_IMPLICIT_CONTEXT #define croak_xs_usage(a,b) S_croak_xs_usage(aTHX_ a,b) #else #define croak_xs_usage S_croak_xs_usage #endif #endif #if PERL_VERSION_GE(5,9,0) && !defined(PERL_CORE) # define VUTIL_REPLACE_CORE 1 static const char * Perl_scan_version2(pTHX_ const char *s, SV *rv, bool qv); static SV * Perl_new_version2(pTHX_ SV *ver); static SV * Perl_upg_version2(pTHX_ SV *sv, bool qv); static SV * Perl_vstringify2(pTHX_ SV *vs); static SV * Perl_vverify2(pTHX_ SV *vs); static SV * Perl_vnumify2(pTHX_ SV *vs); static SV * Perl_vnormal2(pTHX_ SV *vs); static SV * Perl_vstringify2(pTHX_ SV *vs); static int Perl_vcmp2(pTHX_ SV *lsv, SV *rsv); static const char * Perl_prescan_version2(pTHX_ const char *s, bool strict, const char** errstr, bool *sqv, int *ssaw_decimal, int *swidth, bool *salpha); # define SCAN_VERSION(a,b,c) Perl_scan_version2(aTHX_ a,b,c) # define NEW_VERSION(a) Perl_new_version2(aTHX_ a) # define UPG_VERSION(a,b) Perl_upg_version2(aTHX_ a, b) # define VSTRINGIFY(a) Perl_vstringify2(aTHX_ a) # define VVERIFY(a) Perl_vverify2(aTHX_ a) # define VNUMIFY(a) Perl_vnumify2(aTHX_ a) # define VNORMAL(a) Perl_vnormal2(aTHX_ a) # define VCMP(a,b) Perl_vcmp2(aTHX_ a,b) # define PRESCAN_VERSION(a,b,c,d,e,f,g) Perl_prescan_version2(aTHX_ a,b,c,d,e,f,g) # undef is_LAX_VERSION # define is_LAX_VERSION(a,b) \ (a != Perl_prescan_version2(aTHX_ a, FALSE, b, NULL, NULL, NULL, NULL)) # undef is_STRICT_VERSION # define is_STRICT_VERSION(a,b) \ (a != Perl_prescan_version2(aTHX_ a, TRUE, b, NULL, NULL, NULL, NULL)) #else const char * Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv); SV * Perl_new_version(pTHX_ SV *ver); SV * Perl_upg_version(pTHX_ SV *sv, bool qv); SV * Perl_vverify(pTHX_ SV *vs); SV * Perl_vnumify(pTHX_ SV *vs); SV * Perl_vnormal(pTHX_ SV *vs); SV * Perl_vstringify(pTHX_ SV *vs); int Perl_vcmp(pTHX_ SV *lsv, SV *rsv); const char * Perl_prescan_version(pTHX_ const char *s, bool strict, const char** errstr, bool *sqv, int *ssaw_decimal, int *swidth, bool *salpha); # define SCAN_VERSION(a,b,c) Perl_scan_version(aTHX_ a,b,c) # define NEW_VERSION(a) Perl_new_version(aTHX_ a) # define UPG_VERSION(a,b) Perl_upg_version(aTHX_ a, b) # define VSTRINGIFY(a) Perl_vstringify(aTHX_ a) # define VVERIFY(a) Perl_vverify(aTHX_ a) # define VNUMIFY(a) Perl_vnumify(aTHX_ a) # define VNORMAL(a) Perl_vnormal(aTHX_ a) # define VCMP(a,b) Perl_vcmp(aTHX_ a,b) # define PRESCAN_VERSION(a,b,c,d,e,f,g) Perl_prescan_version(aTHX_ a,b,c,d,e,f,g) # ifndef is_LAX_VERSION # define is_LAX_VERSION(a,b) \ (a != Perl_prescan_version(aTHX_ a, FALSE, b, NULL, NULL, NULL, NULL)) # endif # ifndef is_STRICT_VERSION # define is_STRICT_VERSION(a,b) \ (a != Perl_prescan_version(aTHX_ a, TRUE, b, NULL, NULL, NULL, NULL)) # endif #endif #if PERL_VERSION_LT(5,11,4) # define BADVERSION(a,b,c) \ if (b) { \ *b = c; \ } \ return a; # define PERL_ARGS_ASSERT_PRESCAN_VERSION \ assert(s); assert(sqv); assert(ssaw_decimal);\ assert(swidth); assert(salpha); # define PERL_ARGS_ASSERT_SCAN_VERSION \ assert(s); assert(rv) # define PERL_ARGS_ASSERT_NEW_VERSION \ assert(ver) # define PERL_ARGS_ASSERT_UPG_VERSION \ assert(ver) # define PERL_ARGS_ASSERT_VVERIFY \ assert(vs) # define PERL_ARGS_ASSERT_VNUMIFY \ assert(vs) # define PERL_ARGS_ASSERT_VNORMAL \ assert(vs) # define PERL_ARGS_ASSERT_VSTRINGIFY \ assert(vs) # define PERL_ARGS_ASSERT_VCMP \ assert(lhv); assert(rhv) # define PERL_ARGS_ASSERT_CK_WARNER \ assert(pat) #endif #if PERL_VERSION_LT(5,19,0) # undef STORE_NUMERIC_LOCAL_SET_STANDARD # undef RESTORE_NUMERIC_LOCAL # ifdef USE_LOCALE # define STORE_NUMERIC_LOCAL_SET_STANDARD()\ char *loc = savepv(setlocale(LC_NUMERIC, NULL)); \ SAVEFREEPV(loc); \ setlocale(LC_NUMERIC, "C"); # define RESTORE_NUMERIC_LOCAL()\ setlocale(LC_NUMERIC, loc); # else # define STORE_NUMERIC_LOCAL_SET_STANDARD() # define RESTORE_NUMERIC_LOCAL() # endif #endif #ifndef LOCK_NUMERIC_STANDARD #define LOCK_NUMERIC_STANDARD() #endif #ifndef UNLOCK_NUMERIC_STANDARD #define UNLOCK_NUMERIC_STANDARD() #endif /* ex: set ro: */ version-0.9918/vutil/vxs.xs0000644000175000017500000000237612750333532016003 0ustar jpeacockjpeacock#define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define NEED_sv_2pv_nolen_GLOBAL /* for vutil.c */ #define NEED_my_snprintf #define NEED_newRV_noinc #define NEED_vnewSVpvf #define NEED_newSVpvn_flags_GLOBAL #define NEED_warner /* end vutil.c */ #include "ppport.h" #include "vutil.h" #include "vutil.c" /* -------------------------------------------------- * $Revision: 2.5 $ * --------------------------------------------------*/ typedef SV *version_vxs; #include "vxs.inc" struct xsub_details { const char *name; XSUBADDR_t xsub; #ifdef PERL_CORE const char *proto; /* ignored */ #endif }; static const struct xsub_details details[] = { #define VXS_XSUB_DETAILS #include "vxs.inc" #undef VXS_XSUB_DETAILS }; MODULE = version::vxs PACKAGE = version::vxs PROTOTYPES: DISABLE VERSIONCHECK: DISABLE BOOT: { #if (PERL_REVISION == 5 && PERL_VERSION < 9) char* file = __FILE__; #else const char* file = __FILE__; #endif const struct xsub_details *xsub = details; const struct xsub_details *end = details + sizeof(details) / sizeof(details[0]); /* register the overloading (type 'A') magic */ PL_amagic_generation++; do { newXS(xsub->name, xsub->xsub, file); } while (++xsub < end); } version-0.9918/vutil/ppport.h0000644000175000017500000053137112610623754016311 0ustar jpeacockjpeacock#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.19_02 Automatically created by Devel::PPPort running under perl 5.012000. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.19_02 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.11.5. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2010, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.19_02; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.010001||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||5.011000| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.010001| HeVAL||5.004000| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LVRET||| MARK||| MULTICALL||5.011005| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.011004||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.011004||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.011004||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.011005| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.011004||p PL_bufptr|5.011004||p PL_compiling|5.004050||p PL_copline|5.011004||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.011004||p PL_expect|5.011004||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.011004||p PL_in_my|5.011004||p PL_keyword_plugin||5.011002| PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.011004||p PL_lex_stuff|5.011004||p PL_linestr|5.011004||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_opfreehook||5.011000|n PL_parser|5.009005|5.009005|p PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rsfp_filters|5.004050||p PL_rsfp|5.004050||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.011004||p POP_MULTICALL||5.011005| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.011005| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.011004||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _pMY_CXT|5.007003||p aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.011004||p aTHXR|5.011004||p aTHX_|5.006000||p aTHX|5.006000||p add_data|||n add_utf16_textfilter||| addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_i_ncmp||| amagic_ncmp||| anonymise_cv||| any_dup||| ao||| append_elem||| append_list||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_anoncode||| ck_bitop||| ck_concat||| ck_defined||| ck_delete||| ck_die||| ck_each||| ck_eof||| ck_eval||| ck_exec||| ck_exists||| ck_exit||| ck_ftst||| ck_fun||| ck_glob||| ck_grep||| ck_index||| ck_join||| ck_lfun||| ck_listiob||| ck_match||| ck_method||| ck_null||| ck_open||| ck_readline||| ck_repeat||| ck_require||| ck_return||| ck_rfun||| ck_rvconst||| ck_sassign||| ck_select||| ck_shift||| ck_sort||| ck_spair||| ck_split||| ck_subr||| ck_substr||| ck_svconst||| ck_trunc||| ck_unpack||| ck_warner_d||5.011001|v ck_warner||5.011001|v ckwarn_common||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init_zero|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| closest_cop||| convert||| cop_free||| cr_textfilter||| create_eval_scope||| croak_nocontext|||vn croak_xs_usage||5.010001| croak|||v csighandler||5.009003|n curmad||| custom_op_desc||5.007003| custom_op_name||5.007003| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_undef||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.011004||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000|n deprecate_commaless_var_list||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_where||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_chop||| do_close||| do_delete_local||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_kv||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all_perl||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs_perl||| dump_packsubs||5.006000| dump_sub_perl||| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_script||| find_uninit_var||| first_symbol|||n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_strict_version||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_arena||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags|5.009005||p get_cvs|5.011000||p get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_isa_hash||| get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_add_by_type||5.011000| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv|5.009002||p gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| gv_try_downgrade||5.011002| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef||| ibcmp_locale||5.004000|n ibcmp_utf8||5.007003| ibcmp|||n incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr|||n intro_my||| intuit_method||| intuit_more||| invert||| io_close||| isALNUMC|5.006000||p isALNUM||| isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isXDIGIT|5.006000||p is_an_int||| is_ascii_string||5.011000|n is_gv_magical_sv||| is_handle_constructor|||n is_inplace_av||| is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_X_LVT||| is_utf8_X_LV_LVT_V||| is_utf8_X_LV||| is_utf8_X_L||| is_utf8_X_T||| is_utf8_X_V||| is_utf8_X_begin||| is_utf8_X_extend||| is_utf8_X_non_hangul||| is_utf8_X_prepend||| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000|n is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_perl_space||5.011001| is_utf8_perl_word||5.011001| is_utf8_posix_digit||5.011001| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003|n is_utf8_string_loc||5.008001|n is_utf8_string||5.006001|n is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword_plugin_standard||| keyword||| leave_scope||| lex_bufutf8||5.011002| lex_discard_to||5.011002| lex_end||| lex_grow_linestr||5.011002| lex_next_chunk||5.011002| lex_peek_unichar||5.011002| lex_read_space||5.011002| lex_read_to||5.011002| lex_read_unichar||5.011002| lex_start||| lex_stuff_pvn||5.011002| lex_stuff_sv||5.011002| lex_unstuff||5.011002| linklist||| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.010001||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.010001||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhints||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall||| magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQs|5.009005||p memEQ|5.004000||p memNEs|5.009005||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find||| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_get_from_name||5.010001| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.010001| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_register||5.010001| mro_set_mro||5.010001| mro_set_private_data||5.010001| mul128||| mulexp10|||n my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat||| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat||| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.010001||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.010001||p newSVpvn|5.004050||p newSVpvs_flags|5.010001||p newSVpvs_share|5.009003||p newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.009003| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr|||n no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n offer_nice_chunk||| oopsAV||| oopsHV||| op_clear||| op_const_sv||| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_null||5.007002| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_xmldump||| open_script||| opt_scalarhv||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package_version||| package||| packlist||5.008001| pad_add_anon||| pad_add_name_sv||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||5.011002| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||| pad_swipe||| pad_tidy||| pad_undef||| parse_body||| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmflag||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_elem||| prepend_madprops||| prescan_version||5.011004| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch||| refcounted_he_free||| refcounted_he_new_common||| refcounted_he_new||| refcounted_he_value||| refkids||| refto||| ref||5.011005| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy|||n report_evil_fh||| report_uninit||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr|||n rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem_flags||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hdelete||5.011000| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||| save_padsv_and_mortalize||5.010001| save_pptr||| save_pushi32ptr||| save_pushptri32ptr||| save_pushptrptr||| save_pushptr||5.010001| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpv||5.007003| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| scope||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.011005| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv||| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_mg|5.004050||p sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_inc_multiple||| sv_dup||| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc||| sv_insert_flags||5.010001| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.011005|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_flags||5.011005| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_textfilter||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vdie_common||| vdie_croak_common||| vdie||| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| write_no_mem||| write_to_stderr||| xmldump_all_perl||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs_perl||| xmldump_packsubs||| xmldump_sub_perl||| xmldump_sub||| xmldump_vindent||| yyerror||| yylex||| yyparse||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ version-0.9918/CHANGES0000644000175000017500000003073313076366721014445 0ustar jpeacockjpeacockMajor changes for Perl module version This is not a complete list of changes. See repository for full details: https://bitbucket.org/jpeacock/version (primary) 0.9918 - 2017-04-15 * Fix compiling under C++11 https://rt.cpan.org/Ticket/Display.html?id=118846 * Make version::regex variables public for better reuse https://rt.cpan.org/Ticket/Display.html?id=119669 * Use rel2abs for require in tests to support 5.26.0 @INC https://rt.cpan.org/Ticket/Display.html?id=121148 * Move change list to standard CHANGES out of README https://rt.cpan.org/Ticket/Display.html?id=119123 * Better taint handling for Perl < 5.17.2 with tests https://rt.cpan.org/Ticket/Display.html?id=118087 0.9917 - 2016-05-29 * Fix version::regex captures, resolves: https://rt.cpan.org/Ticket/Display.html?id=114712 0.9916 - 2016-03-18 * Incorporate changes from bleadperl (destined to be 5.24.0) 0.9915 - 2016-03-05 * Clarify details of Lyon Compromise: https://gist.github.com/dagolden/9559280 - version comparision should be done irrespective of the presence of underscores in the string used to initialize the version object - underscore should no longer be used as a tuple separator in vstrings or vstring-like strings; vstrings are converted to tuples by splitting into *characters* (not bytes) and converting to codepoints; any elements after the first must be in the range 0-999 - numify/normal should produce a standarized string representation without underscores - stringify should produce the best possible representation of the value used to initialize the version object; it should include underscores only if the initializing value was a non-vstring string. - floating point numbers used as initializers are converted to a decimal string form at the precision limit of the architecture; people will be warned about this in the documentation 0.9914 - 2016-02-18 * Release non-alpha version to CPAN 0.9913_01 - 2016-02-17 * Apply one additional changeset from leont to handle magic v-strings 0.9913 - 2016-02-16 * Release non-alpha version to CPAN 0.9912_03 - 2016-01-21 * Apply two pull requests from bitbucket: https://bitbucket.org/jpeacock/version/pull-requests/1/fix-test-failures-due-to-hard-coded/diff https://bitbucket.org/jpeacock/version/pull-requests/2/static-all-symbols/diff 0.9912_02 - 2016-01-03 * Fix stupid mistake in locale tests, resolves: https://rt.cpan.org/Ticket/Display.html?id=110852 0.9912_01 - 2015-12-31 * Apply patch to implement Lyon Consensus: https://gist.github.com/dagolden/9559280 * Also resolve the following tickets: https://rt.cpan.org/Ticket/Display.html?id=101647 https://rt.cpan.org/Ticket/Display.html?id=101841 https://rt.cpan.org/Ticket/Display.html?id=105315 https://rt.cpan.org/Ticket/Display.html?id=106782 https://rt.cpan.org/Ticket/Display.html?id=107113 https://rt.cpan.org/Ticket/Display.html?id=107114 https://rt.cpan.org/Ticket/Display.html?id=98744 https://rt.cpan.org/Ticket/Display.html?id=102272 0.9912 - 2015-01-20 * Complete reverting the ill-conceived alpha->normal() code, resolves: https://rt.cpan.org/Ticket/Display.html?id=101632 * Skip leading zeros when parsing dotted-decimal versions after the first element, resolves: https://rt.cpan.org/Ticket/Display.html?id=101628 * Minor change to report the correct rt.cpan.org URL, resolves: https://rt.cpan.org/Public/Bug/Display.html?id=101600 0.9911 - 2015-01-17 * Backout change to normal() and numify() because it breaks Module::Build 0.9910 - 2015-01-17 * Ensure that calling either normal() or numify() on an alpha version is explicitly a lossy operation, and add a warning to that effect. Forbid trailing bare decimal for dotted-decimal versions. Change heuristic in vpp to better resolve v-string versions. Various cleanups. Resolves: https://rt.cpan.org/Ticket/Display.html?id=93603 https://rt.cpan.org/Ticket/Display.html?id=93715 https://rt.cpan.org/Ticket/Display.html?id=93721 https://rt.cpan.org/Ticket/Display.html?id=95896 https://rt.cpan.org/Ticket/Display.html?id=96100 https://rt.cpan.org/Ticket/Display.html?id=96620 https://rt.cpan.org/Ticket/Display.html?id=96699 * Patch from Dave Mitchell to rewrite the parser and avoid warnings from clang. Resolves https://rt.cpan.org/Ticket/Display.html?id=101501 0.9909 - 2014-08-15 * Compatibility release for Perl 5.20.1. Apply two patches from bleadperl (one which shipped with 5.20.0 and one from bleadperl) so that a clean release can be applied prior to 5.20.1 being shipped. Holding back a few other improvements, so expect 0.9910 shortly. 0.9908 - 2014-02-02 * More optimizations courtesy of Daniel Dragan (bulk88@hotmail.com). Also resolves: https://rt.cpan.org/Ticket/Display.html?id=92438 https://rt.cpan.org/Ticket/Display.html?id=92540 https://rt.cpan.org/Ticket/Display.html?id=92642 0.9907 - 2014-01-12 * Lots of optimizations of XS and C code courtesy of Daniel Dragan (bulk88@hotmail.com). Lots of minor tweaks as well. Resolves: https://rt.cpan.org/Ticket/Display.html?id=91892 https://rt.cpan.org/Ticket/Display.html?id=91867 https://rt.cpan.org/Ticket/Display.html?id=91987 https://rt.cpan.org/Ticket/Display.html?id=92051 0.9906 - 2014-01-04 * Applied C89 compatibility fix from Karl Williamson to vxs.inc. Added back support for $version::LAX and $version::STRICT to resolve: https://rt.cpan.org/Ticket/Display.html?id=88458 https://rt.cpan.org/Ticket/Display.html?id=91858 https://rt.cpan.org/Ticket/Display.html?id=91868 0.9905 - 2014-01-04 * Major rewrite of XS code to permit easier inclusion in core Perl (mostly written by Father Chrysostomos ). XS code is no longer supported for any Perl < v5.10, although the pure Perl code still works going back to 5.005_04. In addition, the version::vpp class is now completely independent and can be use'd exactly like the base version class. It is still better to use the base class for compatibility purposes. 0.9904 - 2013-08-20 * Final upstream changes from bleadperl. Resolves RT tickets: https://rt.cpan.org/Ticket/Display.html?id=87513 https://rt.cpan.org/Ticket/Display.html?id=87983 0.9903 - 2013-08-18 * Upstream test changes from bleadperl. Include version::vpp even when installing XS version. Subtle locale test changes. 0.9902 - 2013-03-05 * Upstream test changess from bleadperl. Support env PERL_ONLY=1 as well as --perl-only. version::new with no arguments reads past the end of the stack. 0.9901 - 2012-04-26 * Fix problem with short floating point alpha versions (e.g. 0.52_0). 0.99 - 2012-04-26 * Apply missing patch from core Perl to prevent overflow with ludicrous versions. 0.98 - 2012-04-25 * Apply patch from core Perl to prevent overflow with ludicrous versions. 0.97 - 2012-02-28 * Minor tweak to locale test to skip if no locales are installed at all. 0.96 - 2012-02-06 * Merge in upstream changes from bleadperl. Improved locale tests. 0.95 - 2011-11-12 * Restore compatibility in replacement UNIVERSAL::VERSION with the behavior of Perl 5.14.x, essentially by reverting the changes in https://rt.perl.org/rt3/Ticket/Display.html?id=95544 * Fix segfault error with strings that begin with 'v', especially the string 'version'. Resolves: https://rt.cpan.org/Ticket/Display.html?id=72365 * Forbid all math operations on version objects in base class (this was already the case for XS code but the pure Perl was lacking). Resolves: https://rt.cpan.org/Public/Bug/Display.html?id=70950 0.94 - 2011-08-21 * Clarify documentation on advisability of using leading 'v' (it isn't mandatory, but it is much more likely to DTRT). Resolves: https://rt.cpan.org/Public/Bug/Display.html?id=70120 * Use a localized DIE handler when attempting to load the XS code, in case the caller has its own DIE handler. Resolves: https://rt.cpan.org/Public/Bug/Display.html?id=70260 0.93 - 2011-07-27 * Fix problem with UNIVERSAL::VERSION noted by Father Chrysostomos. 0.92 - 2011-07-26 * Forbid negative versions. Make replacement UNIVERSAL::VERSION return the original $VERSION scalar if called without a requested version. Resolves https://rt.perl.org/rt3/Ticket/Display.html?id=95544 Rewrite code so that we just override all subs for Perl >= 5.9.0 (when version.pm was added to the core). 0.91 - 2011-06-05 * Fix compilation/linking on Strawberry Perl, resolves https://rt.cpan.org/Ticket/Display.html?id=68611 0.90 - 2011-06-01 * Make all tests pass even with older Test::More releases. Resolves https://rt.cpan.org/Ticket/Display.html?id=68588 0.89 - 2011-05-31 * Change behavior of pure Perl qv/declare to match the core/XS behavior; do not use parent's new() class for derived classes. This breaks encapsulation but I can justify it because qv/declare is a very specific thing that shouldn't be casually overridden (unless you do it directly in the subclass). 0.88 - 2010-12-19 * Fix Makefile.PL to make Strawberry Perl happy. Resolves: https://rt.cpan.org/Public/Bug/Display.html?id=63991 0.87 - 2010-12-09 * Remove Build.PL since there are modules in the Module::Build tool chain that require version.pm, leading to circular dependencies. This also allows Module::Build itself to depend on version.pm. 0.86 - 2010-11-26 * is_strict/is_lax were not exported correctly (which no one noticed). Also pull in strict/lax tests from core. 0.85 - 2010-10-25 * Don't include MYMETA.yml file in distro 0.84 - 2010-10-24 * Restore public API vcmp() broken in 0.83 0.83 - 2010-10-17 * Changed vverify API (David Golden). Improved heuristic for non-magical v-strings (Perl 5.6.0-5.8.0). Install in proper patch post-@INC reordering. 0.82 - 2010-04-13 * Still more changes to sync with Perl 5.12.0-as-released. Rewritten POD thanks to many hands, but mostly David Golden. Vastly improved Regex definitions from Zephram. 0.81 - 2010-02-01 * Merge in changes from bleadperl that will be part of Perl 5.12.0. Completely rewrite pure Perl code to operate exactly like the XS code, through the creation of a character-array class called charstar. Now the pure Perl code and XS code can be more easily be synchronized. 0.80 - 2010-01-21 * No outwardly visible changes. This release is to fix an assertion error with certain picky/older compilers. NOTE: this is not the version object code that will be part of Perl 5.12.0, which will be released shortly as 0.81. 0.79 - 2010-01-03 * No outwardly visible changes. This release is to match the code that will part of Perl 5.12.0, but which doesn't affect the external API of the CPAN release. 0.78 - 2009-10-12 * More changes to improve the non-magic v-string heuristics, this time affecting both the pure Perl and XS backends. NOTE: these fixes only matter if you are running Perl 5.6.x to 5.8.0 (inclusive). Beginning with Perl 5.8.1, v-strings are now magical and version.pm no longer has to guess. Resolves: https://rt.cpan.org/Ticket/Display.html?id=50347 * Also resolve the issue where attempting to install CPAN releases on top of core releases (e.g. 5.10.0 and 5.10.1) would not DTRT. Resolves: https://rt.cpan.org/Ticket/Display.html?id=49667 0.7702 - 2009-09-07 * Add additional contraints to the code which tries to guess whether something is a v-string or not for Perl 5.6.0 through 5.8.0 (inclusive). Resolves: https://rt.cpan.org/Ticket/Display.html?id=49348 0.7701 - 2009-07-28 * Special RHEL4.x/Fedora4.x Are Too Stupid to Live Release. Those distros have never updated beyond Perl 5.8.5/5.8.6 respectively. Consequently, they contain a complete broken Test::More::use_ok which doesn't load the package into the correct namespace: https://rt.cpan.org/Ticket/Display.html?id=48268 thus causing mysterious test failures. No version.pm code was changed at all. :( 0.77 - 2009-07-26 * Complete POD rewrite to document common usage in version.pod and put all of the implementation details into version::Internals. * Resolve a number of RT tickets: RT#48135 - Compilation failure using MS VC++ 7.0. RT#47980 - Remove need for runtime class loading in pure Perl code RT#46921 - locale and eval action at a distance. RT#45241 - mistaken regex to convert large exponential numbers to non-exponential form before scanning. version-0.9918/README0000644000175000017500000000341313076366721014325 0ustar jpeacockjpeacockversion 0.9918 ================================== Object oriented versions for all Perl releases from 5.6.2 onward. Replaces the core version code for all Perl releases from 5.10.0 onwards. Although this code has been fully integrated into the latest Perl release itself (e.g. bleadperl), the CPAN release is considered upstream. The source code itself is available from two mirrors: https://bitbucket.org/jpeacock/version (primary) https://github.com/JohnPeacock/version.git (secondary) and a bug queue here: https://rt.cpan.org/Dist/Display.html?Queue=version Patches welcomed. IMPORTANT NOTE - 0.9906 is the last release that fully supports Perl releases prior to 5.6.2. It is just too much trouble to continue to fight to maintain full backward compatibility. YOU SHOULD INSTALL THIS RELEASE WHEN USING VERSION OBJECTS IN PERL 5.10.0. There was a bug caused by objects serialized by YAML that will cause Perl 5.10.0 to segfault. As long as some module calls 'use version', then the replacement code will take effect and Perl will not crash. Please read the POD documentation for usage/details. See the CHANGES file for full details of all changes to the module behavior. INSTALLATION To install this module type the following: $ perl Makefile.PL $ make $ make test # make install This release includes an optional pure Perl implementation (in case you don't have a C-compiler or if some reason you want your code to be much slower). You can test it by replacing the first line above with: $ perl Makefile.PL --perl_only and it will install the Perl only version. DEPENDENCIES The same C compiler used to build Perl (or not). COPYRIGHT AND LICENCE This module can be distributed under the same terms as Perl. Copyright (C) 2004-2017 John Peacock version-0.9918/MANIFEST.SKIP0000644000175000017500000000023413076366721015341 0ustar jpeacockjpeacock\.lwpcookies \.releaserc .+\.diff .+\.bak .+~ .+\.orig .hg .shipit tags Makefile$ MYMETA.* version-.+\.tar\.gz vutil/Makefile\.PL vutil/MYMETA.* t/test-all version-0.9918/lib/0000755000175000017500000000000013076366721014212 5ustar jpeacockjpeacockversion-0.9918/lib/version.pm0000644000175000017500000000677013076366721016247 0ustar jpeacockjpeacock#!perl -w package version; use 5.006002; use strict; use warnings::register; if ($] >= 5.015) { warnings::register_categories(qw/version/); } use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv); $VERSION = 0.9918; $CLASS = 'version'; # !!!!Delete this next block completely when adding to Perl core!!!! { local $SIG{'__DIE__'}; eval "use version::vxs $VERSION"; if ( $@ ) { # don't have the XS version installed eval "use version::vpp $VERSION"; # don't tempt fate die "$@" if ( $@ ); push @ISA, "version::vpp"; local $^W; *version::qv = \&version::vpp::qv; *version::declare = \&version::vpp::declare; *version::_VERSION = \&version::vpp::_VERSION; *version::vcmp = \&version::vpp::vcmp; *version::new = \&version::vpp::new; *version::numify = \&version::vpp::numify; *version::normal = \&version::vpp::normal; if ($] >= 5.009000) { no strict 'refs'; *version::stringify = \&version::vpp::stringify; *{'version::(""'} = \&version::vpp::stringify; *{'version::(<=>'} = \&version::vpp::vcmp; *{'version::(cmp'} = \&version::vpp::vcmp; *version::parse = \&version::vpp::parse; } } else { # use XS module push @ISA, "version::vxs"; local $^W; *version::declare = \&version::vxs::declare; *version::qv = \&version::vxs::qv; *version::_VERSION = \&version::vxs::_VERSION; *version::vcmp = \&version::vxs::VCMP; *version::new = \&version::vxs::new; *version::numify = \&version::vxs::numify; *version::normal = \&version::vxs::normal; if ($] >= 5.009000) { no strict 'refs'; *version::stringify = \&version::vxs::stringify; *{'version::(""'} = \&version::vxs::stringify; *{'version::(<=>'} = \&version::vxs::VCMP; *{'version::(cmp'} = \&version::vxs::VCMP; *version::parse = \&version::vxs::parse; } } } # avoid using Exporter require version::regex; *version::is_lax = \&version::regex::is_lax; *version::is_strict = \&version::regex::is_strict; *LAX = \$version::regex::LAX; *LAX_DECIMAL_VERSION = \$version::regex::LAX_DECIMAL_VERSION; *LAX_DOTTED_DECIMAL_VERSION = \$version::regex::LAX_DOTTED_DECIMAL_VERSION; *STRICT = \$version::regex::STRICT; *STRICT_DECIMAL_VERSION = \$version::regex::STRICT_DECIMAL_VERSION; *STRICT_DOTTED_DECIMAL_VERSION = \$version::regex::STRICT_DOTTED_DECIMAL_VERSION; sub import { no strict 'refs'; my ($class) = shift; # Set up any derived class unless ($class eq $CLASS) { local $^W; *{$class.'::declare'} = \&{$CLASS.'::declare'}; *{$class.'::qv'} = \&{$CLASS.'::qv'}; } my %args; if (@_) { # any remaining terms are arguments map { $args{$_} = 1 } @_ } else { # no parameters at all on use line %args = ( qv => 1, 'UNIVERSAL::VERSION' => 1, ); } my $callpkg = caller(); if (exists($args{declare})) { *{$callpkg.'::declare'} = sub {return $class->declare(shift) } unless defined(&{$callpkg.'::declare'}); } if (exists($args{qv})) { *{$callpkg.'::qv'} = sub {return $class->qv(shift) } unless defined(&{$callpkg.'::qv'}); } if (exists($args{'UNIVERSAL::VERSION'})) { local $^W; *UNIVERSAL::VERSION = \&{$CLASS.'::_VERSION'}; } if (exists($args{'VERSION'})) { *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'}; } if (exists($args{'is_strict'})) { *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'} unless defined(&{$callpkg.'::is_strict'}); } if (exists($args{'is_lax'})) { *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'} unless defined(&{$callpkg.'::is_lax'}); } } 1; version-0.9918/lib/version/0000755000175000017500000000000013076366721015677 5ustar jpeacockjpeacockversion-0.9918/lib/version/Internals.pod0000644000175000017500000006070212750333532020337 0ustar jpeacockjpeacock=head1 NAME version::Internals - Perl extension for Version Objects =head1 DESCRIPTION Overloaded version objects for all modern versions of Perl. This documents the internal data representation and underlying code for version.pm. See F for daily usage. This document is only useful for users interested in the gory details. =head1 WHAT IS A VERSION? For the purposes of this module, a version "number" is a sequence of positive integer values separated by one or more decimal points and optionally a single underscore. This corresponds to what Perl itself uses for a version, as well as extending the "version as number" that is discussed in the various editions of the Camel book. There are actually two distinct kinds of version objects: =over 4 =item Decimal versions Any version which "looks like a number", see L. This also includes versions with a single decimal point and a single embedded underscore, see L, even though these must be quoted to preserve the underscore formatting. =item Dotted-Decimal versions Also referred to as "Dotted-Integer", these contains more than one decimal point and may have an optional embedded underscore, see L. This is what is commonly used in most open source software as the "external" version (the one used as part of the tag or tarfile name). A leading 'v' character is now required and will warn if it missing. =back Both of these methods will produce similar version objects, in that the default stringification will yield the version L only if required: $v = version->new(1.002); # 1.002, but compares like 1.2.0 $v = version->new(1.002003); # 1.002003 $v2 = version->new("v1.2.3"); # v1.2.3 In specific, version numbers initialized as L will stringify as they were originally created (i.e. the same string that was passed to C. Version numbers initialized as L will be stringified as L. =head2 Decimal Versions These correspond to historical versions of Perl itself prior to 5.6.0, as well as all other modules which follow the Camel rules for the $VERSION scalar. A Decimal version is initialized with what looks like a floating point number. Leading zeros B significant and trailing zeros are implied so that a minimum of three places is maintained between subversions. What this means is that any subversion (digits to the right of the decimal place) that contains less than three digits will have trailing zeros added to make up the difference, but only for purposes of comparison with other version objects. For example: # Prints Equivalent to $v = version->new( 1.2); # 1.2 v1.200.0 $v = version->new( 1.02); # 1.02 v1.20.0 $v = version->new( 1.002); # 1.002 v1.2.0 $v = version->new( 1.0023); # 1.0023 v1.2.300 $v = version->new( 1.00203); # 1.00203 v1.2.30 $v = version->new( 1.002003); # 1.002003 v1.2.3 All of the preceding examples are true whether or not the input value is quoted. The important feature is that the input value contains only a single decimal. See also L. IMPORTANT NOTE: As shown above, if your Decimal version contains more than 3 significant digits after the decimal place, it will be split on each multiple of 3, so 1.0003 is equivalent to v1.0.300, due to the need to remain compatible with Perl's own 5.005_03 == 5.5.30 interpretation. Any trailing zeros are ignored for mathematical comparison purposes. =head2 Dotted-Decimal Versions These are the newest form of versions, and correspond to Perl's own version style beginning with 5.6.0. Starting with Perl 5.10.0, and most likely Perl 6, this is likely to be the preferred form. This method normally requires that the input parameter be quoted, although Perl's after 5.8.1 can use v-strings as a special form of quoting, but this is highly discouraged. Unlike L, Dotted-Decimal Versions have more than a single decimal point, e.g.: # Prints $v = version->new( "v1.200"); # v1.200.0 $v = version->new("v1.20.0"); # v1.20.0 $v = qv("v1.2.3"); # v1.2.3 $v = qv("1.2.3"); # v1.2.3 $v = qv("1.20"); # v1.20.0 In general, Dotted-Decimal Versions permit the greatest amount of freedom to specify a version, whereas Decimal Versions enforce a certain uniformity. Just like L, Dotted-Decimal Versions can be used as L. =head2 Alpha Versions For module authors using CPAN, the convention has been to note unstable releases with an underscore in the version string. (See L.) version.pm follows this convention and alpha releases will test as being newer than the more recent stable release, and less than the next stable release. Only the last element may be separated by an underscore: # Declaring use version 0.77; our $VERSION = version->declare("v1.2_3"); # Parsing $v1 = version->parse("v1.2_3"); $v1 = version->parse("1.002_003"); Note that you B quote the version when writing an alpha Decimal version. The stringified form of Decimal versions will always be the same string that was used to initialize the version object. =head2 Regular Expressions for Version Parsing A formalized definition of the legal forms for version strings is included in the C class. Primitives are included for common elements, although they are scoped to the file so they are useful for reference purposes only. There are two publicly accessible scalars that can be used in other code (not exported): =over 4 =item C<$version::LAX> This regexp covers all of the legal forms allowed under the current version string parser. This is not to say that all of these forms are recommended, and some of them can only be used when quoted. For dotted decimals: v1.2 1.2345.6 v1.23_4 The leading 'v' is optional if two or more decimals appear. If only a single decimal is included, then the leading 'v' is required to trigger the dotted-decimal parsing. A leading zero is permitted, though not recommended except when quoted, because of the risk that Perl will treat the number as octal. A trailing underscore plus one or more digits denotes an alpha or development release (and must be quoted to be parsed properly). For decimal versions: 1 1.2345 1.2345_01 an integer portion, an optional decimal point, and optionally one or more digits to the right of the decimal are all required. A trailing underscore is permitted and a leading zero is permitted. Just like the lax dotted-decimal version, quoting the values is required for alpha/development forms to be parsed correctly. =item C<$version::STRICT> This regexp covers a much more limited set of formats and constitutes the best practices for initializing version objects. Whether you choose to employ decimal or dotted-decimal for is a personal preference however. =over 4 =item v1.234.5 For dotted-decimal versions, a leading 'v' is required, with three or more sub-versions of no more than three digits. A leading 0 (zero) before the first sub-version (in the above example, '1') is also prohibited. =item 2.3456 For decimal versions, an integer portion (no leading 0), a decimal point, and one or more digits to the right of the decimal are all required. =back =back Both of the provided scalars are already compiled as regular expressions and do not contain either anchors or implicit groupings, so they can be included in your own regular expressions freely. For example, consider the following code: ($pkg, $ver) =~ / ^[ \t]* use [ \t]+($PKGNAME) (?:[ \t]+($version::STRICT))? [ \t]*; /x; This would match a line of the form: use Foo::Bar::Baz v1.2.3; # legal only in Perl 5.8.1+ where C<$PKGNAME> is another regular expression that defines the legal forms for package names. =head1 IMPLEMENTATION DETAILS =head2 Equivalence between Decimal and Dotted-Decimal Versions When Perl 5.6.0 was released, the decision was made to provide a transformation between the old-style decimal versions and new-style dotted-decimal versions: 5.6.0 == 5.006000 5.005_04 == 5.5.40 The floating point number is taken and split first on the single decimal place, then each group of three digits to the right of the decimal makes up the next digit, and so on until the number of significant digits is exhausted, B enough trailing zeros to reach the next multiple of three. This was the method that version.pm adopted as well. Some examples may be helpful: equivalent decimal zero-padded dotted-decimal ------- ----------- -------------- 1.2 1.200 v1.200.0 1.02 1.020 v1.20.0 1.002 1.002 v1.2.0 1.0023 1.002300 v1.2.300 1.00203 1.002030 v1.2.30 1.002003 1.002003 v1.2.3 =head2 Quoting Rules Because of the nature of the Perl parsing and tokenizing routines, certain initialization values B be quoted in order to correctly parse as the intended version, especially when using the C or L methods. While you do not have to quote decimal numbers when creating version objects, it is always safe to quote B initial values when using version.pm methods, as this will ensure that what you type is what is used. Additionally, if you quote your initializer, then the quoted value that goes B will be exactly what comes B when your $VERSION is printed (stringified). If you do not quote your value, Perl's normal numeric handling comes into play and you may not get back what you were expecting. If you use a mathematic formula that resolves to a floating point number, you are dependent on Perl's conversion routines to yield the version you expect. You are pretty safe by dividing by a power of 10, for example, but other operations are not likely to be what you intend. For example: $VERSION = version->new((qw$Revision: 1.4)[1]/10); print $VERSION; # yields 0.14 $V2 = version->new(100/9); # Integer overflow in decimal number print $V2; # yields something like 11.111.111.100 Perl 5.8.1 and beyond are able to automatically quote v-strings but that is not possible in earlier versions of Perl. In other words: $version = version->new("v2.5.4"); # legal in all versions of Perl $newvers = version->new(v2.5.4); # legal only in Perl >= 5.8.1 =head2 What about v-strings? There are two ways to enter v-strings: a bare number with two or more decimal points, or a bare number with one or more decimal points and a leading 'v' character (also bare). For example: $vs1 = 1.2.3; # encoded as \1\2\3 $vs2 = v1.2; # encoded as \1\2 However, the use of bare v-strings to initialize version objects is B discouraged in all circumstances. Also, bare v-strings are not completely supported in any version of Perl prior to 5.8.1. If you insist on using bare v-strings with Perl > 5.6.0, be aware of the following limitations: 1) For Perl releases 5.6.0 through 5.8.0, the v-string code merely guesses, based on some characteristics of v-strings. You B use a three part version, e.g. 1.2.3 or v1.2.3 in order for this heuristic to be successful. 2) For Perl releases 5.8.1 and later, v-strings have changed in the Perl core to be magical, which means that the version.pm code can automatically determine whether the v-string encoding was used. 3) In all cases, a version created using v-strings will have a stringified form that has a leading 'v' character, for the simple reason that sometimes it is impossible to tell whether one was present initially. =head2 Version Object Internals version.pm provides an overloaded version object that is designed to both encapsulate the author's intended $VERSION assignment as well as make it completely natural to use those objects as if they were numbers (e.g. for comparisons). To do this, a version object contains both the original representation as typed by the author, as well as a parsed representation to ease comparisons. Version objects employ L methods to simplify code that needs to compare, print, etc the objects. The internal structure of version objects is a blessed hash with several components: bless( { 'original' => 'v1.2.3_4', 'alpha' => 1, 'qv' => 1, 'version' => [ 1, 2, 3, 4 ] }, 'version' ); =over 4 =item original A faithful representation of the value used to initialize this version object. The only time this will not be precisely the same characters that exist in the source file is if a short dotted-decimal version like v1.2 was used (in which case it will contain 'v1.2'). This form is B discouraged, in that it will confuse you and your users. =item qv A boolean that denotes whether this is a decimal or dotted-decimal version. See L. =item alpha A boolean that denotes whether this is an alpha version. NOTE: that the underscore can only appear in the last position. See L. =item version An array of non-negative integers that is used for comparison purposes with other version objects. =back =head2 Replacement UNIVERSAL::VERSION In addition to the version objects, this modules also replaces the core UNIVERSAL::VERSION function with one that uses version objects for its comparisons. The return from this operator is always the stringified form as a simple scalar (i.e. not an object), but the warning message generated includes either the stringified form or the normal form, depending on how it was called. For example: package Foo; $VERSION = 1.2; package Bar; $VERSION = "v1.3.5"; # works with all Perl's (since it is quoted) package main; use version; print $Foo::VERSION; # prints 1.2 print $Bar::VERSION; # prints 1.003005 eval "use foo 10"; print $@; # prints "foo version 10 required..." eval "use foo 1.3.5; # work in Perl 5.6.1 or better print $@; # prints "foo version 1.3.5 required..." eval "use bar 1.3.6"; print $@; # prints "bar version 1.3.6 required..." eval "use bar 1.004"; # note Decimal version print $@; # prints "bar version 1.004 required..." IMPORTANT NOTE: This may mean that code which searches for a specific string (to determine whether a given module is available) may need to be changed. It is always better to use the built-in comparison implicit in C or C, rather than manually poking at C<< class->VERSION >> and then doing a comparison yourself. The replacement UNIVERSAL::VERSION, when used as a function, like this: print $module->VERSION; will also exclusively return the stringified form. See L for more details. =head1 USAGE DETAILS =head2 Using modules that use version.pm As much as possible, the version.pm module remains compatible with all current code. However, if your module is using a module that has defined C<$VERSION> using the version class, there are a couple of things to be aware of. For purposes of discussion, we will assume that we have the following module installed: package Example; use version; $VERSION = qv('1.2.2'); ...module code here... 1; =over 4 =item Decimal versions always work Code of the form: use Example 1.002003; will always work correctly. The C will perform an automatic C<$VERSION> comparison using the floating point number given as the first term after the module name (e.g. above 1.002.003). In this case, the installed module is too old for the requested line, so you would see an error like: Example version 1.002003 (v1.2.3) required--this is only version 1.002002 (v1.2.2)... =item Dotted-Decimal version work sometimes With Perl >= 5.6.2, you can also use a line like this: use Example 1.2.3; and it will again work (i.e. give the error message as above), even with releases of Perl which do not normally support v-strings (see L above). This has to do with that fact that C only checks to see if the second term I and passes that to the replacement L. This is not true in Perl 5.005_04, however, so you are B to always use a Decimal version in your code, even for those versions of Perl which support the Dotted-Decimal version. =back =head2 Object Methods =over 4 =item new() Like many OO interfaces, the new() method is used to initialize version objects. If two arguments are passed to C, the B one will be used as if it were prefixed with "v". This is to support historical use of the C operator with the CVS variable $Revision, which is automatically incremented by CVS every time the file is committed to the repository. In order to facilitate this feature, the following code can be employed: $VERSION = version->new(qw$Revision: 2.7 $); and the version object will be created as if the following code were used: $VERSION = version->new("v2.7"); In other words, the version will be automatically parsed out of the string, and it will be quoted to preserve the meaning CVS normally carries for versions. The CVS $Revision$ increments differently from Decimal versions (i.e. 1.10 follows 1.9), so it must be handled as if it were a Dotted-Decimal Version. A new version object can be created as a copy of an existing version object, either as a class method: $v1 = version->new(12.3); $v2 = version->new($v1); or as an object method: $v1 = version->new(12.3); $v2 = $v1->new(12.3); and in each case, $v1 and $v2 will be identical. NOTE: if you create a new object using an existing object like this: $v2 = $v1->new(); the new object B be a clone of the existing object. In the example case, $v2 will be an empty object of the same type as $v1. =back =over 4 =item qv() An alternate way to create a new version object is through the exported qv() sub. This is not strictly like other q? operators (like qq, qw), in that the only delimiters supported are parentheses (or spaces). It is the best way to initialize a short version without triggering the floating point interpretation. For example: $v1 = qv(1.2); # v1.2.0 $v2 = qv("1.2"); # also v1.2.0 As you can see, either a bare number or a quoted string can usually be used interchangeably, except in the case of a trailing zero, which must be quoted to be converted properly. For this reason, it is strongly recommended that all initializers to qv() be quoted strings instead of bare numbers. To prevent the C function from being exported to the caller's namespace, either use version with a null parameter: use version (); or just require version, like this: require version; Both methods will prevent the import() method from firing and exporting the C sub. =back For the subsequent examples, the following three objects will be used: $ver = version->new("1.2.3.4"); # see "Quoting Rules" $alpha = version->new("1.2.3_4"); # see "Alpha Versions" $nver = version->new(1.002); # see "Decimal Versions" =over 4 =item Normal Form For any version object which is initialized with multiple decimal places (either quoted or if possible v-string), or initialized using the L operator, the stringified representation is returned in a normalized or reduced form (no extraneous zeros), and with a leading 'v': print $ver->normal; # prints as v1.2.3.4 print $ver->stringify; # ditto print $ver; # ditto print $nver->normal; # prints as v1.2.0 print $nver->stringify; # prints as 1.002, # see "Stringification" In order to preserve the meaning of the processed version, the normalized representation will always contain at least three sub terms. In other words, the following is guaranteed to always be true: my $newver = version->new($ver->stringify); if ($newver eq $ver ) # always true {...} =back =over 4 =item Numification Although all mathematical operations on version objects are forbidden by default, it is possible to retrieve a number which corresponds to the version object through the use of the $obj->numify method. For formatting purposes, when displaying a number which corresponds a version object, all sub versions are assumed to have three decimal places. So for example: print $ver->numify; # prints 1.002003004 print $nver->numify; # prints 1.002 Unlike the stringification operator, there is never any need to append trailing zeros to preserve the correct version value. =back =over 4 =item Stringification The default stringification for version objects returns exactly the same string as was used to create it, whether you used C or C, with one exception. The sole exception is if the object was created using C and the initializer did not have two decimal places or a leading 'v' (both optional), then the stringified form will have a leading 'v' prepended, in order to support round-trip processing. For example: Initialized as Stringifies to ============== ============== version->new("1.2") 1.2 version->new("v1.2") v1.2 qv("1.2.3") 1.2.3 qv("v1.3.5") v1.3.5 qv("1.2") v1.2 ### exceptional case See also L, as this also returns the stringified form when used as a class method. IMPORTANT NOTE: There is one exceptional cases shown in the above table where the "initializer" is not stringwise equivalent to the stringified representation. If you use the C() operator on a version without a leading 'v' B with only a single decimal place, the stringified output will have a leading 'v', to preserve the sense. See the L operator for more details. IMPORTANT NOTE 2: Attempting to bypass the normal stringification rules by manually applying L and L will sometimes yield surprising results: print version->new(version->new("v1.0")->numify)->normal; # v1.0.0 The reason for this is that the L operator will turn "v1.0" into the equivalent string "1.000000". Forcing the outer version object to L form will display the mathematically equivalent "v1.0.0". As the example in L shows, you can always create a copy of an existing version object with the same value by the very compact: $v2 = $v1->new($v1); and be assured that both C<$v1> and C<$v2> will be completely equivalent, down to the same internal representation as well as stringification. =back =over 4 =item Comparison operators Both C and C=E> operators perform the same comparison between terms (upgrading to a version object automatically). Perl automatically generates all of the other comparison operators based on those two. In addition to the obvious equalities listed below, appending a single trailing 0 term does not change the value of a version for comparison purposes. In other words "v1.2" and "1.2.0" will compare as identical. For example, the following relations hold: As Number As String Truth Value ------------- ---------------- ----------- $ver > 1.0 $ver gt "1.0" true $ver < 2.5 $ver lt true $ver != 1.3 $ver ne "1.3" true $ver == 1.2 $ver eq "1.2" false $ver == 1.2.3.4 $ver eq "1.2.3.4" see discussion below It is probably best to chose either the Decimal notation or the string notation and stick with it, to reduce confusion. Perl6 version objects B only support Decimal comparisons. See also L. WARNING: Comparing version with unequal numbers of decimal points (whether explicitly or implicitly initialized), may yield unexpected results at first glance. For example, the following inequalities hold: version->new(0.96) > version->new(0.95); # 0.960.0 > 0.950.0 version->new("0.96.1") < version->new(0.95); # 0.096.1 < 0.950.0 For this reason, it is best to use either exclusively L or L with multiple decimal points. =back =over 4 =item Logical Operators If you need to test whether a version object has been initialized, you can simply test it directly: $vobj = version->new($something); if ( $vobj ) # true only if $something was non-blank You can also test whether a version object is an alpha version, for example to prevent the use of some feature not present in the main release: $vobj = version->new("1.2_3"); # MUST QUOTE ...later... if ( $vobj->is_alpha ) # True =back =head1 AUTHOR John Peacock Ejpeacock@cpan.orgE =head1 SEE ALSO L. =cut version-0.9918/lib/version/regex.pm0000644000175000017500000001015613076366721017352 0ustar jpeacockjpeacockpackage version::regex; use strict; use vars qw( $VERSION $CLASS $STRICT $LAX $STRICT_DECIMAL_VERSION $STRICT_DOTTED_DECIMAL_VERSION $LAX_DECIMAL_VERSION $LAX_DOTTED_DECIMAL_VERSION ); $VERSION = 0.9918; #--------------------------------------------------------------------------# # Version regexp components #--------------------------------------------------------------------------# # Fraction part of a decimal version number. This is a common part of # both strict and lax decimal versions my $FRACTION_PART = qr/\.[0-9]+/; # First part of either decimal or dotted-decimal strict version number. # Unsigned integer with no leading zeroes (except for zero itself) to # avoid confusion with octal. my $STRICT_INTEGER_PART = qr/0|[1-9][0-9]*/; # First part of either decimal or dotted-decimal lax version number. # Unsigned integer, but allowing leading zeros. Always interpreted # as decimal. However, some forms of the resulting syntax give odd # results if used as ordinary Perl expressions, due to how perl treats # octals. E.g. # version->new("010" ) == 10 # version->new( 010 ) == 8 # version->new( 010.2) == 82 # "8" . "2" my $LAX_INTEGER_PART = qr/[0-9]+/; # Second and subsequent part of a strict dotted-decimal version number. # Leading zeroes are permitted, and the number is always decimal. # Limited to three digits to avoid overflow when converting to decimal # form and also avoid problematic style with excessive leading zeroes. my $STRICT_DOTTED_DECIMAL_PART = qr/\.[0-9]{1,3}/; # Second and subsequent part of a lax dotted-decimal version number. # Leading zeroes are permitted, and the number is always decimal. No # limit on the numerical value or number of digits, so there is the # possibility of overflow when converting to decimal form. my $LAX_DOTTED_DECIMAL_PART = qr/\.[0-9]+/; # Alpha suffix part of lax version number syntax. Acts like a # dotted-decimal part. my $LAX_ALPHA_PART = qr/_[0-9]+/; #--------------------------------------------------------------------------# # Strict version regexp definitions #--------------------------------------------------------------------------# # Strict decimal version number. $STRICT_DECIMAL_VERSION = qr/ $STRICT_INTEGER_PART $FRACTION_PART? /x; # Strict dotted-decimal version number. Must have both leading "v" and # at least three parts, to avoid confusion with decimal syntax. $STRICT_DOTTED_DECIMAL_VERSION = qr/ v $STRICT_INTEGER_PART $STRICT_DOTTED_DECIMAL_PART{2,} /x; # Complete strict version number syntax -- should generally be used # anchored: qr/ \A $STRICT \z /x $STRICT = qr/ $STRICT_DECIMAL_VERSION | $STRICT_DOTTED_DECIMAL_VERSION /x; #--------------------------------------------------------------------------# # Lax version regexp definitions #--------------------------------------------------------------------------# # Lax decimal version number. Just like the strict one except for # allowing an alpha suffix or allowing a leading or trailing # decimal-point $LAX_DECIMAL_VERSION = qr/ $LAX_INTEGER_PART (?: $FRACTION_PART | \. )? $LAX_ALPHA_PART? | $FRACTION_PART $LAX_ALPHA_PART? /x; # Lax dotted-decimal version number. Distinguished by having either # leading "v" or at least three non-alpha parts. Alpha part is only # permitted if there are at least two non-alpha parts. Strangely # enough, without the leading "v", Perl takes .1.2 to mean v0.1.2, # so when there is no "v", the leading part is optional $LAX_DOTTED_DECIMAL_VERSION = qr/ v $LAX_INTEGER_PART (?: $LAX_DOTTED_DECIMAL_PART+ $LAX_ALPHA_PART? )? | $LAX_INTEGER_PART? $LAX_DOTTED_DECIMAL_PART{2,} $LAX_ALPHA_PART? /x; # Complete lax version number syntax -- should generally be used # anchored: qr/ \A $LAX \z /x # # The string 'undef' is a special case to make for easier handling # of return values from ExtUtils::MM->parse_version $LAX = qr/ undef | $LAX_DOTTED_DECIMAL_VERSION | $LAX_DECIMAL_VERSION /x; #--------------------------------------------------------------------------# # Preloaded methods go here. sub is_strict { defined $_[0] && $_[0] =~ qr/ \A $STRICT \z /x } sub is_lax { defined $_[0] && $_[0] =~ qr/ \A $LAX \z /x } 1; version-0.9918/lib/version.pod0000644000175000017500000002320413074450200016364 0ustar jpeacockjpeacock=head1 NAME version - Perl extension for Version Objects =head1 SYNOPSIS # Parsing version strings (decimal or dotted-decimal) use version 0.77; # get latest bug-fixes and API $ver = version->parse($string) # Declaring a dotted-decimal $VERSION (keep on one line!) use version; our $VERSION = version->declare("v1.2.3"); # formal use version; our $VERSION = qv("v1.2.3"); # deprecated use version; our $VERSION = qv("v1.2_3"); # deprecated # Declaring an old-style decimal $VERSION (use quotes!) our $VERSION = "1.0203"; # recommended use version; our $VERSION = version->parse("1.0203"); # formal use version; our $VERSION = version->parse("1.02_03"); # alpha # Comparing mixed version styles (decimals, dotted-decimals, objects) if ( version->parse($v1) == version->parse($v2) ) { # do stuff } # Sorting mixed version styles @ordered = sort { version->parse($a) <=> version->parse($b) } @list; =head1 DESCRIPTION Version objects were added to Perl in 5.10. This module implements version objects for older version of Perl and provides the version object API for all versions of Perl. All previous releases before 0.74 are deprecated and should not be used due to incompatible API changes. Version 0.77 introduces the new 'parse' and 'declare' methods to standardize usage. You are strongly urged to set 0.77 as a minimum in your code, e.g. use version 0.77; # even for Perl v.5.10.0 =head1 TYPES OF VERSION OBJECTS There are two different types of version objects, corresponding to the two different styles of versions in use: =over 2 =item Decimal Versions The classic floating-point number $VERSION. The advantage to this style is that you don't need to do anything special, just type a number into your source file. Quoting is recommended, as it ensures that trailing zeroes ("1.50") are preserved in any warnings or other output. =item Dotted Decimal Versions The more modern form of version assignment, with 3 (or potentially more) integers separated by decimal points (e.g. v1.2.3). This is the form that Perl itself has used since 5.6.0 was released. The leading 'v' is now strongly recommended for clarity, and will throw a warning in a future release if omitted. A leading 'v' character is required to pass the L test. =back =head1 DECLARING VERSIONS If you have a module that uses a decimal $VERSION (floating point), and you do not intend to ever change that, this module is not for you. There is nothing that version.pm gains you over a simple $VERSION assignment: our $VERSION = "1.02"; Since Perl v5.10.0 includes the version.pm comparison logic anyways, you don't need to do anything at all. =head2 How to convert a module from decimal to dotted-decimal If you have used a decimal $VERSION in the past and wish to switch to a dotted-decimal $VERSION, then you need to make a one-time conversion to the new format. B: you must ensure that your new $VERSION is numerically greater than your current decimal $VERSION; this is not always obvious. First, convert your old decimal version (e.g. 1.02) to a normalized dotted-decimal form: $ perl -Mversion -e 'print version->parse("1.02")->normal' v1.20.0 Then increment any of the dotted-decimal components (v1.20.1 or v1.21.0). =head2 How to C a dotted-decimal version use version; our $VERSION = version->declare("v1.2.3"); The C method always creates dotted-decimal version objects. When used in a module, you B put it on the same line as "use version" to ensure that $VERSION is read correctly by PAUSE and installer tools. You should also add 'version' to the 'configure_requires' section of your module metadata file. See instructions in L or L for details. B: Even if you pass in what looks like a decimal number ("1.2"), a dotted-decimal will be created ("v1.200.0"). To avoid confusion or unintentional errors on older Perls, follow these guidelines: =over 2 =item * Always use a dotted-decimal with (at least) three components =item * Always use a leading-v =item * Always quote the version =back If you really insist on using version.pm with an ordinary decimal version, use C instead of declare. See the L for details. See also L for more on version number conversion, quoting, calculated version numbers and declaring developer or "alpha" version numbers. =head1 PARSING AND COMPARING VERSIONS If you need to compare version numbers, but can't be sure whether they are expressed as numbers, strings, v-strings or version objects, then you should use version.pm to parse them all into objects for comparison. =head2 How to C a version The C method takes in anything that might be a version and returns a corresponding version object, doing any necessary conversion along the way. =over 2 =item * Dotted-decimal: bare v-strings (v1.2.3) and strings with more than one decimal point and a leading 'v' ("v1.2.3"); NOTE you can technically use a v-string or strings with a leading-v and only one decimal point (v1.2 or "v1.2"), but you will confuse both yourself and others. =item * Decimal: regular decimal numbers (literal or in a string) =back Some examples: $variable version->parse($variable) --------- ------------------------- 1.23 v1.230.0 "1.23" v1.230.0 v1.23 v1.23.0 "v1.23" v1.23.0 "1.2.3" v1.2.3 "v1.2.3" v1.2.3 See L for more on version number conversion. =head2 How to check for a legal version string If you do not want to actually create a full blown version object, but would still like to verify that a given string meets the criteria to be parsed as a version, there are two helper functions that can be employed directly: =over 4 =item C The lax criteria corresponds to what is currently allowed by the version parser. All of the following formats are acceptable for dotted-decimal formats strings: v1.2 1.2345.6 v1.23_4 1.2345 1.2345_01 =item C If you want to limit yourself to a much more narrow definition of what a version string constitutes, C is limited to version strings like the following list: v1.234.5 2.3456 =back See L for details of the regular expressions that define the legal version string forms, as well as how to use those regular expressions in your own code if C and C are not sufficient for your needs. =head2 How to compare version objects Version objects overload the C and C<< <=> >> operators. Perl automatically generates all of the other comparison operators based on those two so all the normal logical comparisons will work. if ( version->parse($v1) == version->parse($v2) ) { # do stuff } If a version object is compared against a non-version object, the non-object term will be converted to a version object using C. This may give surprising results: $v1 = version->parse("v0.95.0"); $bool = $v1 < 0.96; # FALSE since 0.96 is v0.960.0 Always comparing to a version object will help avoid surprises: $bool = $v1 < version->parse("v0.96.0"); # TRUE Note that "alpha" version objects (where the version string contains a trailing underscore segment) compare as less than the equivalent version without an underscore: $bool = version->parse("1.23_45") < version->parse("1.2345"); # TRUE See L for more details on "alpha" versions. =head1 OBJECT METHODS =head2 is_alpha() True if and only if the version object was created with a underscore, e.g. version->parse('1.002_03')->is_alpha; # TRUE version->declare('1.2.3_4')->is_alpha; # TRUE =head2 is_qv() True only if the version object is a dotted-decimal version, e.g. version->parse('v1.2.0')->is_qv; # TRUE version->declare('v1.2')->is_qv; # TRUE qv('1.2')->is_qv; # TRUE version->parse('1.2')->is_qv; # FALSE =head2 normal() Returns a string with a standard 'normalized' dotted-decimal form with a leading-v and at least 3 components. version->declare('v1.2')->normal; # v1.2.0 version->parse('1.2')->normal; # v1.200.0 =head2 numify() Returns a value representing the object in a pure decimal form without trailing zeroes. version->declare('v1.2')->numify; # 1.002 version->parse('1.2')->numify; # 1.200 =head2 stringify() Returns a string that is as close to the original representation as possible. If the original representation was a numeric literal, it will be returned the way perl would normally represent it in a string. This method is used whenever a version object is interpolated into a string. version->declare('v1.2')->stringify; # v1.2 version->parse('1.200')->stringify; # 1.200 version->parse(1.02_30)->stringify; # 1.023 =head1 EXPORTED FUNCTIONS =head2 qv() This function is no longer recommended for use, but is maintained for compatibility with existing code. If you do not want to have it exported to your namespace, use this form: use version 0.77 (); =head2 is_lax() (Not exported by default) This function takes a scalar argument and returns a boolean value indicating whether the argument meets the "lax" rules for a version number. Leading and trailing spaces are not allowed. =head2 is_strict() (Not exported by default) This function takes a scalar argument and returns a boolean value indicating whether the argument meets the "strict" rules for a version number. Leading and trailing spaces are not allowed. =head1 AUTHOR John Peacock Ejpeacock@cpan.orgE =head1 SEE ALSO L. L. =cut version-0.9918/META.yml0000664000175000017500000000141013076366721014713 0ustar jpeacockjpeacock--- abstract: 'Structured version objects' author: - 'John Peacock ' build_requires: ExtUtils::MakeMaker: '0' File::Temp: '0.13' Test::More: '0.45' parent: '0.221' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: version no_index: directory: - t - inc package: - charstar requires: perl: '5.006002' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=version repository: https://bitbucket.org/jpeacock/version version: '0.9918' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' version-0.9918/vperl/0000755000175000017500000000000013076366721014574 5ustar jpeacockjpeacockversion-0.9918/vperl/vpp.pm0000644000175000017500000005256713076366721015756 0ustar jpeacockjpeacockpackage charstar; # a little helper class to emulate C char* semantics in Perl # so that prescan_version can use the same code as in C use overload ( '""' => \&thischar, '0+' => \&thischar, '++' => \&increment, '--' => \&decrement, '+' => \&plus, '-' => \&minus, '*' => \&multiply, 'cmp' => \&cmp, '<=>' => \&spaceship, 'bool' => \&thischar, '=' => \&clone, ); sub new { my ($self, $string) = @_; my $class = ref($self) || $self; my $obj = { string => [split(//,$string)], current => 0, }; return bless $obj, $class; } sub thischar { my ($self) = @_; my $last = $#{$self->{string}}; my $curr = $self->{current}; if ($curr >= 0 && $curr <= $last) { return $self->{string}->[$curr]; } else { return ''; } } sub increment { my ($self) = @_; $self->{current}++; } sub decrement { my ($self) = @_; $self->{current}--; } sub plus { my ($self, $offset) = @_; my $rself = $self->clone; $rself->{current} += $offset; return $rself; } sub minus { my ($self, $offset) = @_; my $rself = $self->clone; $rself->{current} -= $offset; return $rself; } sub multiply { my ($left, $right, $swapped) = @_; my $char = $left->thischar(); return $char * $right; } sub spaceship { my ($left, $right, $swapped) = @_; unless (ref($right)) { # not an object already $right = $left->new($right); } return $left->{current} <=> $right->{current}; } sub cmp { my ($left, $right, $swapped) = @_; unless (ref($right)) { # not an object already if (length($right) == 1) { # comparing single character only return $left->thischar cmp $right; } $right = $left->new($right); } return $left->currstr cmp $right->currstr; } sub bool { my ($self) = @_; my $char = $self->thischar; return ($char ne ''); } sub clone { my ($left, $right, $swapped) = @_; $right = { string => [@{$left->{string}}], current => $left->{current}, }; return bless $right, ref($left); } sub currstr { my ($self, $s) = @_; my $curr = $self->{current}; my $last = $#{$self->{string}}; if (defined($s) && $s->{current} < $last) { $last = $s->{current}; } my $string = join('', @{$self->{string}}[$curr..$last]); return $string; } package version::vpp; use 5.006002; use strict; use warnings::register; use Config; use vars qw($VERSION $CLASS @ISA $LAX $STRICT $WARN_CATEGORY); $VERSION = 0.9918; $CLASS = 'version::vpp'; if ($] > 5.015) { warnings::register_categories(qw/version/); $WARN_CATEGORY = 'version'; } else { $WARN_CATEGORY = 'numeric'; } require version::regex; *version::vpp::is_strict = \&version::regex::is_strict; *version::vpp::is_lax = \&version::regex::is_lax; *LAX = \$version::regex::LAX; *STRICT = \$version::regex::STRICT; use overload ( '""' => \&stringify, '0+' => \&numify, 'cmp' => \&vcmp, '<=>' => \&vcmp, 'bool' => \&vbool, '+' => \&vnoop, '-' => \&vnoop, '*' => \&vnoop, '/' => \&vnoop, '+=' => \&vnoop, '-=' => \&vnoop, '*=' => \&vnoop, '/=' => \&vnoop, 'abs' => \&vnoop, ); sub import { no strict 'refs'; my ($class) = shift; # Set up any derived class unless ($class eq $CLASS) { local $^W; *{$class.'::declare'} = \&{$CLASS.'::declare'}; *{$class.'::qv'} = \&{$CLASS.'::qv'}; } my %args; if (@_) { # any remaining terms are arguments map { $args{$_} = 1 } @_ } else { # no parameters at all on use line %args = ( qv => 1, 'UNIVERSAL::VERSION' => 1, ); } my $callpkg = caller(); if (exists($args{declare})) { *{$callpkg.'::declare'} = sub {return $class->declare(shift) } unless defined(&{$callpkg.'::declare'}); } if (exists($args{qv})) { *{$callpkg.'::qv'} = sub {return $class->qv(shift) } unless defined(&{$callpkg.'::qv'}); } if (exists($args{'UNIVERSAL::VERSION'})) { no warnings qw/redefine/; *UNIVERSAL::VERSION = \&{$CLASS.'::_VERSION'}; } if (exists($args{'VERSION'})) { *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'}; } if (exists($args{'is_strict'})) { *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'} unless defined(&{$callpkg.'::is_strict'}); } if (exists($args{'is_lax'})) { *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'} unless defined(&{$callpkg.'::is_lax'}); } } my $VERSION_MAX = 0x7FFFFFFF; # implement prescan_version as closely to the C version as possible use constant TRUE => 1; use constant FALSE => 0; sub isDIGIT { my ($char) = shift->thischar(); return ($char =~ /\d/); } sub isALPHA { my ($char) = shift->thischar(); return ($char =~ /[a-zA-Z]/); } sub isSPACE { my ($char) = shift->thischar(); return ($char =~ /\s/); } sub BADVERSION { my ($s, $errstr, $error) = @_; if ($errstr) { $$errstr = $error; } return $s; } sub prescan_version { my ($s, $strict, $errstr, $sqv, $ssaw_decimal, $swidth, $salpha) = @_; my $qv = defined $sqv ? $$sqv : FALSE; my $saw_decimal = defined $ssaw_decimal ? $$ssaw_decimal : 0; my $width = defined $swidth ? $$swidth : 3; my $alpha = defined $salpha ? $$salpha : FALSE; my $d = $s; if ($qv && isDIGIT($d)) { goto dotted_decimal_version; } if ($d eq 'v') { # explicit v-string $d++; if (isDIGIT($d)) { $qv = TRUE; } else { # degenerate v-string # requires v1.2.3 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } dotted_decimal_version: if ($strict && $d eq '0' && isDIGIT($d+1)) { # no leading zeros allowed return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)"); } while (isDIGIT($d)) { # integer part $d++; } if ($d eq '.') { $saw_decimal++; $d++; # decimal point } else { if ($strict) { # require v1.2.3 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } else { goto version_prescan_finish; } } { my $i = 0; my $j = 0; while (isDIGIT($d)) { # just keep reading $i++; while (isDIGIT($d)) { $d++; $j++; # maximum 3 digits between decimal if ($strict && $j > 3) { return BADVERSION($s,$errstr,"Invalid version format (maximum 3 digits between decimals)"); } } if ($d eq '_') { if ($strict) { return BADVERSION($s,$errstr,"Invalid version format (no underscores)"); } if ( $alpha ) { return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)"); } $d++; $alpha = TRUE; } elsif ($d eq '.') { if ($alpha) { return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)"); } $saw_decimal++; $d++; } elsif (!isDIGIT($d)) { last; } $j = 0; } if ($strict && $i < 2) { # requires v1.2.3 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)"); } } } # end if dotted-decimal else { # decimal versions my $j = 0; # special $strict case for leading '.' or '0' if ($strict) { if ($d eq '.') { return BADVERSION($s,$errstr,"Invalid version format (0 before decimal required)"); } if ($d eq '0' && isDIGIT($d+1)) { return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)"); } } # and we never support negative version numbers if ($d eq '-') { return BADVERSION($s,$errstr,"Invalid version format (negative version number)"); } # consume all of the integer part while (isDIGIT($d)) { $d++; } # look for a fractional part if ($d eq '.') { # we found it, so consume it $saw_decimal++; $d++; } elsif (!$d || $d eq ';' || isSPACE($d) || $d eq '}') { if ( $d == $s ) { # found nothing return BADVERSION($s,$errstr,"Invalid version format (version required)"); } # found just an integer goto version_prescan_finish; } elsif ( $d == $s ) { # didn't find either integer or period return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)"); } elsif ($d eq '_') { # underscore can't come after integer part if ($strict) { return BADVERSION($s,$errstr,"Invalid version format (no underscores)"); } elsif (isDIGIT($d+1)) { return BADVERSION($s,$errstr,"Invalid version format (alpha without decimal)"); } else { return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)"); } } elsif ($d) { # anything else after integer part is just invalid data return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)"); } # scan the fractional part after the decimal point if ($d && !isDIGIT($d) && ($strict || ! ($d eq ';' || isSPACE($d) || $d eq '}') )) { # $strict or lax-but-not-the-end return BADVERSION($s,$errstr,"Invalid version format (fractional part required)"); } while (isDIGIT($d)) { $d++; $j++; if ($d eq '.' && isDIGIT($d-1)) { if ($alpha) { return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)"); } if ($strict) { return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions must begin with 'v')"); } $d = $s; # start all over again $qv = TRUE; goto dotted_decimal_version; } if ($d eq '_') { if ($strict) { return BADVERSION($s,$errstr,"Invalid version format (no underscores)"); } if ( $alpha ) { return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)"); } if ( ! isDIGIT($d+1) ) { return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)"); } $width = $j; $d++; $alpha = TRUE; } } } version_prescan_finish: while (isSPACE($d)) { $d++; } if ($d && !isDIGIT($d) && (! ($d eq ';' || $d eq '}') )) { # trailing non-numeric data return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)"); } if ($saw_decimal > 1 && ($d-1) eq '.') { # no trailing period allowed return BADVERSION($s,$errstr,"Invalid version format (trailing decimal)"); } if (defined $sqv) { $$sqv = $qv; } if (defined $swidth) { $$swidth = $width; } if (defined $ssaw_decimal) { $$ssaw_decimal = $saw_decimal; } if (defined $salpha) { $$salpha = $alpha; } return $d; } sub scan_version { my ($s, $rv, $qv) = @_; my $start; my $pos; my $last; my $errstr; my $saw_decimal = 0; my $width = 3; my $alpha = FALSE; my $vinf = FALSE; my @av; $s = new charstar $s; while (isSPACE($s)) { # leading whitespace is OK $s++; } $last = prescan_version($s, FALSE, \$errstr, \$qv, \$saw_decimal, \$width, \$alpha); if ($errstr) { # 'undef' is a special case and not an error if ( $s ne 'undef') { require Carp; Carp::croak($errstr); } } $start = $s; if ($s eq 'v') { $s++; } $pos = $s; if ( $qv ) { $$rv->{qv} = $qv; } if ( $alpha ) { $$rv->{alpha} = $alpha; } if ( !$qv && $width < 3 ) { $$rv->{width} = $width; } while (isDIGIT($pos) || $pos eq '_') { $pos++; } if (!isALPHA($pos)) { my $rev; for (;;) { $rev = 0; { # this is atoi() that delimits on underscores my $end = $pos; my $mult = 1; my $orev; # the following if() will only be true after the decimal # point of a version originally created with a bare # floating point number, i.e. not quoted in any way # if ( !$qv && $s > $start && $saw_decimal == 1 ) { $mult *= 100; while ( $s < $end ) { next if $s eq '_'; $orev = $rev; $rev += $s * $mult; $mult /= 10; if ( (abs($orev) > abs($rev)) || (abs($rev) > $VERSION_MAX )) { warn("Integer overflow in version %d", $VERSION_MAX); $s = $end - 1; $rev = $VERSION_MAX; $vinf = 1; } $s++; if ( $s eq '_' ) { $s++; } } } else { while (--$end >= $s) { next if $end eq '_'; $orev = $rev; $rev += $end * $mult; $mult *= 10; if ( (abs($orev) > abs($rev)) || (abs($rev) > $VERSION_MAX )) { warn("Integer overflow in version"); $end = $s - 1; $rev = $VERSION_MAX; $vinf = 1; } } } } # Append revision push @av, $rev; if ( $vinf ) { $s = $last; last; } elsif ( $pos eq '.' ) { $s = ++$pos; } elsif ( $pos eq '_' && isDIGIT($pos+1) ) { $s = ++$pos; } elsif ( $pos eq ',' && isDIGIT($pos+1) ) { $s = ++$pos; } elsif ( isDIGIT($pos) ) { $s = $pos; } else { $s = $pos; last; } if ( $qv ) { while ( isDIGIT($pos) || $pos eq '_') { $pos++; } } else { my $digits = 0; while ( ( isDIGIT($pos) || $pos eq '_' ) && $digits < 3 ) { if ( $pos ne '_' ) { $digits++; } $pos++; } } } } if ( $qv ) { # quoted versions always get at least three terms my $len = $#av; # This for loop appears to trigger a compiler bug on OS X, as it # loops infinitely. Yes, len is negative. No, it makes no sense. # Compiler in question is: # gcc version 3.3 20030304 (Apple Computer, Inc. build 1640) # for ( len = 2 - len; len > 0; len-- ) # av_push(MUTABLE_AV(sv), newSViv(0)); # $len = 2 - $len; while ($len-- > 0) { push @av, 0; } } # need to save off the current version string for later if ( $vinf ) { $$rv->{original} = "v.Inf"; $$rv->{vinf} = 1; } elsif ( $s > $start ) { $$rv->{original} = $start->currstr($s); if ( $qv && $saw_decimal == 1 && $start ne 'v' ) { # need to insert a v to be consistent $$rv->{original} = 'v' . $$rv->{original}; } } else { $$rv->{original} = '0'; push(@av, 0); } # And finally, store the AV in the hash $$rv->{version} = \@av; # fix RT#19517 - special case 'undef' as string if ($s eq 'undef') { $s += 5; } return $s; } sub new { my $class = shift; unless (defined $class or $#_ > 1) { require Carp; Carp::croak('Usage: version::new(class, version)'); } my $self = bless ({}, ref ($class) || $class); my $qv = FALSE; if ( $#_ == 1 ) { # must be CVS-style $qv = TRUE; } my $value = pop; # always going to be the last element if ( ref($value) && eval('$value->isa("version")') ) { # Can copy the elements directly $self->{version} = [ @{$value->{version} } ]; $self->{qv} = 1 if $value->{qv}; $self->{alpha} = 1 if $value->{alpha}; $self->{original} = ''.$value->{original}; return $self; } if ( not defined $value or $value =~ /^undef$/ ) { # RT #19517 - special case for undef comparison # or someone forgot to pass a value push @{$self->{version}}, 0; $self->{original} = "0"; return ($self); } if (ref($value) =~ m/ARRAY|HASH/) { require Carp; Carp::croak("Invalid version format (non-numeric data)"); } $value = _un_vstring($value); if ($Config{d_setlocale}) { use POSIX qw/locale_h/; use if $Config{d_setlocale}, 'locale'; my $currlocale = setlocale(LC_ALL); # if the current locale uses commas for decimal points, we # just replace commas with decimal places, rather than changing # locales if ( localeconv()->{decimal_point} eq ',' ) { $value =~ tr/,/./; } } # exponential notation if ( $value =~ /\d+.?\d*e[-+]?\d+/ ) { $value = sprintf("%.9f",$value); $value =~ s/(0+)$//; # trim trailing zeros } my $s = scan_version($value, \$self, $qv); if ($s) { # must be something left over warn(sprintf "Version string '%s' contains invalid data; " ."ignoring: '%s'", $value, $s); } return ($self); } *parse = \&new; sub numify { my ($self) = @_; unless (_verify($self)) { require Carp; Carp::croak("Invalid version object"); } my $alpha = $self->{alpha} || ""; my $len = $#{$self->{version}}; my $digit = $self->{version}[0]; my $string = sprintf("%d.", $digit ); if ($alpha and warnings::enabled()) { warnings::warn($WARN_CATEGORY, 'alpha->numify() is lossy'); } for ( my $i = 1 ; $i <= $len ; $i++ ) { $digit = $self->{version}[$i]; $string .= sprintf("%03d", $digit); } if ( $len == 0 ) { $string .= sprintf("000"); } return $string; } sub normal { my ($self) = @_; unless (_verify($self)) { require Carp; Carp::croak("Invalid version object"); } my $len = $#{$self->{version}}; my $digit = $self->{version}[0]; my $string = sprintf("v%d", $digit ); for ( my $i = 1 ; $i <= $len ; $i++ ) { $digit = $self->{version}[$i]; $string .= sprintf(".%d", $digit); } if ( $len <= 2 ) { for ( $len = 2 - $len; $len != 0; $len-- ) { $string .= sprintf(".%0d", 0); } } return $string; } sub stringify { my ($self) = @_; unless (_verify($self)) { require Carp; Carp::croak("Invalid version object"); } return exists $self->{original} ? $self->{original} : exists $self->{qv} ? $self->normal : $self->numify; } sub vcmp { my ($left,$right,$swap) = @_; my $class = ref($left); unless ( UNIVERSAL::isa($right, $class) ) { $right = $class->new($right); } if ( $swap ) { ($left, $right) = ($right, $left); } unless (_verify($left)) { require Carp; Carp::croak("Invalid version object"); } unless (_verify($right)) { require Carp; Carp::croak("Invalid version format"); } my $l = $#{$left->{version}}; my $r = $#{$right->{version}}; my $m = $l < $r ? $l : $r; my $lalpha = $left->is_alpha; my $ralpha = $right->is_alpha; my $retval = 0; my $i = 0; while ( $i <= $m && $retval == 0 ) { $retval = $left->{version}[$i] <=> $right->{version}[$i]; $i++; } # possible match except for trailing 0's if ( $retval == 0 && $l != $r ) { if ( $l < $r ) { while ( $i <= $r && $retval == 0 ) { if ( $right->{version}[$i] != 0 ) { $retval = -1; # not a match after all } $i++; } } else { while ( $i <= $l && $retval == 0 ) { if ( $left->{version}[$i] != 0 ) { $retval = +1; # not a match after all } $i++; } } } return $retval; } sub vbool { my ($self) = @_; return vcmp($self,$self->new("0"),1); } sub vnoop { require Carp; Carp::croak("operation not supported with version object"); } sub is_alpha { my ($self) = @_; return (exists $self->{alpha}); } sub qv { my $value = shift; my $class = $CLASS; if (@_) { $class = ref($value) || $value; $value = shift; } $value = _un_vstring($value); $value = 'v'.$value unless $value =~ /(^v|\d+\.\d+\.\d)/; my $obj = $CLASS->new($value); return bless $obj, $class; } *declare = \&qv; sub is_qv { my ($self) = @_; return (exists $self->{qv}); } sub _verify { my ($self) = @_; if ( ref($self) && eval { exists $self->{version} } && ref($self->{version}) eq 'ARRAY' ) { return 1; } else { return 0; } } sub _is_non_alphanumeric { my $s = shift; $s = new charstar $s; while ($s) { return 0 if isSPACE($s); # early out return 1 unless (isALPHA($s) || isDIGIT($s) || $s =~ /[.-]/); $s++; } return 0; } sub _un_vstring { my $value = shift; # may be a v-string if ( length($value) >= 1 && $value !~ /[,._]/ && _is_non_alphanumeric($value)) { my $tvalue; if ( $] >= 5.008_001 ) { $tvalue = _find_magic_vstring($value); $value = $tvalue if length $tvalue; } elsif ( $] >= 5.006_000 ) { $tvalue = sprintf("v%vd",$value); if ( $tvalue =~ /^v\d+(\.\d+)*$/ ) { # must be a v-string $value = $tvalue; } } } return $value; } sub _find_magic_vstring { my $value = shift; my $tvalue = ''; require B; my $sv = B::svref_2object(\$value); my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef; while ( $magic ) { if ( $magic->TYPE eq 'V' ) { $tvalue = $magic->PTR; $tvalue =~ s/^v?(.+)$/v$1/; last; } else { $magic = $magic->MOREMAGIC; } } $tvalue =~ tr/_//d; return $tvalue; } sub _VERSION { my ($obj, $req) = @_; my $class = ref($obj) || $obj; no strict 'refs'; if ( exists $INC{"$class.pm"} and not %{"$class\::"} and $] >= 5.008) { # file but no package require Carp; Carp::croak( "$class defines neither package nor VERSION" ."--version check failed"); } my $version = eval "\$$class\::VERSION"; if ( defined $version ) { local $^W if $] <= 5.008; $version = version::vpp->new($version); } if ( defined $req ) { unless ( defined $version ) { require Carp; my $msg = $] < 5.006 ? "$class version $req required--this is only version " : "$class does not define \$$class\::VERSION" ."--version check failed"; if ( $ENV{VERSION_DEBUG} ) { Carp::confess($msg); } else { Carp::croak($msg); } } $req = version::vpp->new($req); if ( $req > $version ) { require Carp; if ( $req->is_qv ) { Carp::croak( sprintf ("%s version %s required--". "this is only version %s", $class, $req->normal, $version->normal) ); } else { Carp::croak( sprintf ("%s version %s required--". "this is only version %s", $class, $req->stringify, $version->stringify) ); } } } return defined $version ? $version->stringify : undef; } 1; #this line is important and will help the module return a true value version-0.9918/t/0000755000175000017500000000000013076366721013707 5ustar jpeacockjpeacockversion-0.9918/t/02derived.t0000644000175000017500000000602113076366721015657 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; use File::Spec; use File::Temp qw/tempfile/; BEGIN { my $coretests = File::Spec->rel2abs( File::Spec->catpath( (File::Spec->splitpath($0))[0,1], 'coretests.pm' ) ); require $coretests; use_ok("version", 0.9918); # If we made it this far, we are ok. } use lib qw/./; package version::Bad; use parent 'version'; sub new { my($self,$n)=@_; bless \$n, $self } # Bad subclass for SemVer failures seen with pure Perl version.pm only package version::Bad2; use parent 'version'; sub new { my ($class, $val) = @_; die 'Invalid version string format' unless version::is_strict($val); my $self = $class->SUPER::new($val); return $self; } sub declare { my ($class, $val) = @_; my $self = $class->SUPER::declare($val); return $self; } package main; my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; # dummy up a legal module for testing RT#19017 my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh <<"EOF"; # This is an empty subclass package $package; use parent 'version'; use vars '\$VERSION'; \$VERSION=0.001; EOF close $fh; sub main_reset { delete $main::INC{'$package'}; undef &qv; undef *::qv; # avoid 'used once' warning undef &declare; undef *::declare; # avoid 'used once' warning } use_ok($package, 0.001); my $testobj = $package->new(1.002_003); isa_ok( $testobj, $package ); ok( $testobj->numify == 1.002003, "Numified correctly" ); ok( $testobj->stringify eq "1.002003", "Stringified correctly" ); ok( $testobj->normal eq "v1.2.3", "Normalified correctly" ); my $verobj = version::->new("1.2.4"); ok( $verobj > $testobj, "Comparison vs parent class" ); BaseTests($package, "new", "qv"); main_reset; use_ok($package, 0.001, "declare"); BaseTests($package, "new", "declare"); main_reset; use_ok($package, 0.001); BaseTests($package, "parse", "qv"); main_reset; use_ok($package, 0.001, "declare"); BaseTests($package, "parse", "declare"); $testobj = version::Bad->new(1.002_003); isa_ok( $testobj, "version::Bad" ); eval { my $string = $testobj->numify }; like($@, qr/Invalid version object/, "Bad subclass numify"); eval { my $string = $testobj->normal }; like($@, qr/Invalid version object/, "Bad subclass normal"); eval { my $string = $testobj->stringify }; like($@, qr/Invalid version object/, "Bad subclass stringify"); eval { my $test = ($testobj > 1.0) }; like($@, qr/Invalid version object/, "Bad subclass vcmp"); # Bad subclassing for SemVer with pure Perl version.pm only eval { my $test = version::Bad2->new("01.1.2") }; like($@, qr/Invalid version string format/, "Correctly found invalid version"); eval { my $test = version::Bad2->declare("01.1.2") }; unlike($@, qr/Invalid version string format/, "Correctly ignored invalid version"); version-0.9918/t/07locale.t0000644000175000017500000001127313076366721015506 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use File::Basename; use File::Temp qw/tempfile/; use POSIX qw/locale_h/; use Test::More tests => 8; use Config; BEGIN { use_ok('version', 0.9918); } SKIP: { skip 'No locale testing for Perl < 5.6.0', 6 if $] < 5.006; skip 'No locale testing without d_setlocale', 6 if(!$Config{d_setlocale}); # test locale handling my $warning = ''; local $SIG{__WARN__} = sub { $warning = $_[0] }; my $ver = 1.23; # has to be floating point number my $loc; my $orig_loc = setlocale(LC_NUMERIC); ok ($ver eq "1.23", 'Not using locale yet'); # Don't use is(), # because have to # evaluate in current # scope use if $^O !~ /android/, 'locale'; while () { chomp; $loc = setlocale( LC_ALL, $_); last if $loc && localeconv()->{decimal_point} eq ','; } skip 'Cannot test locale handling without a comma locale', 6 unless $loc and localeconv()->{decimal_point} eq ','; setlocale(LC_NUMERIC, $loc); $ver = 1.23; # has to be floating point number ok ($ver eq "1,23", "Using locale: $loc"); $v = version->new($ver); unlike($warning, qr/Version string '1,23' contains invalid data/, "Process locale-dependent floating point"); ok ($v eq "1.23", "Locale doesn't apply to version objects"); ok ($v == $ver, "Comparison to locale floating point"); TODO: { # Resolve https://rt.cpan.org/Ticket/Display.html?id=102272 local $TODO = 'Fails for Perl 5.x.0 < 5.19.0' if $] < 5.019000; $ver = version->new($]); is "$ver", "$]", 'Use PV for dualvars'; } setlocale( LC_ALL, $orig_loc); # reset this before possible skip skip 'Cannot test RT#46921 with Perl < 5.008', 1 if ($] < 5.008); my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh <<"EOF"; package $package; use locale; use POSIX qw(locale_h); \$^W = 1; use version; setlocale (LC_ALL, '$loc'); use version ; eval "use Socket 1.7"; setlocale( LC_ALL, '$orig_loc'); 1; EOF close $fh; eval "use lib '.'; use $package;"; unlike($warning, qr"Version string '1,7' contains invalid data", 'Handle locale action-at-a-distance'); } __DATA__ af_ZA af_ZA.utf8 af_ZA.UTF-8 an_ES an_ES.utf8 an_ES.UTF-8 az_AZ.utf8 az_AZ.UTF-8 be_BY be_BY.utf8 be_BY.UTF-8 bg_BG bg_BG.utf8 bg_BG.UTF-8 br_FR br_FR@euro br_FR.utf8 br_FR.UTF-8 bs_BA bs_BA.utf8 bs_BA.UTF-8 ca_ES ca_ES@euro ca_ES.utf8 ca_ES.UTF-8 cs_CZ cs_CZ.utf8 cs_CZ.UTF-8 da_DK da_DK.utf8 da_DK.UTF-8 de_AT de_AT@euro de_AT.utf8 de_AT.UTF-8 de_BE de_BE@euro de_BE.utf8 de_BE.UTF-8 de_DE de_DE@euro de_DE.utf8 de_DE.UTF-8 de_DE.UTF-8 de_LU de_LU@euro de_LU.utf8 de_LU.UTF-8 el_GR el_GR.utf8 el_GR.UTF-8 en_DK en_DK.utf8 en_DK.UTF-8 es_AR es_AR.utf8 es_AR.UTF-8 es_BO es_BO.utf8 es_BO.UTF-8 es_CL es_CL.utf8 es_CL.UTF-8 es_CO es_CO.utf8 es_CO.UTF-8 es_EC es_EC.utf8 es_EC.UTF-8 es_ES es_ES@euro es_ES.utf8 es_ES.UTF-8 es_PY es_PY.utf8 es_PY.UTF-8 es_UY es_UY.utf8 es_UY.UTF-8 es_VE es_VE.utf8 es_VE.UTF-8 et_EE et_EE.iso885915 et_EE.utf8 et_EE.UTF-8 eu_ES eu_ES@euro eu_ES.utf8 eu_ES.UTF-8 fi_FI fi_FI@euro fi_FI.utf8 fi_FI.UTF-8 fo_FO fo_FO.utf8 fo_FO.UTF-8 fr_BE fr_BE@euro fr_BE.utf8 fr_BE.UTF-8 fr_CA fr_CA.utf8 fr_CA.UTF-8 fr_CH fr_CH.utf8 fr_CH.UTF-8 fr_FR fr_FR@euro fr_FR.utf8 fr_FR.UTF-8 fr_LU fr_LU@euro fr_LU.utf8 fr_LU.UTF-8 gl_ES gl_ES@euro gl_ES.utf8 gl_ES.UTF-8 hr_HR hr_HR.utf8 hr_HR.UTF-8 hu_HU hu_HU.utf8 hu_HU.UTF-8 id_ID id_ID.utf8 id_ID.UTF-8 is_IS is_IS.utf8 is_IS.UTF-8 it_CH it_CH.utf8 it_CH.UTF-8 it_IT it_IT@euro it_IT.utf8 it_IT.UTF-8 ka_GE ka_GE.utf8 ka_GE.UTF-8 kk_KZ kk_KZ.utf8 kk_KZ.UTF-8 kl_GL kl_GL.utf8 kl_GL.UTF-8 lt_LT lt_LT.utf8 lt_LT.UTF-8 lv_LV lv_LV.utf8 lv_LV.UTF-8 mk_MK mk_MK.utf8 mk_MK.UTF-8 mn_MN mn_MN.utf8 mn_MN.UTF-8 nb_NO nb_NO.utf8 nb_NO.UTF-8 nl_BE nl_BE@euro nl_BE.utf8 nl_BE.UTF-8 nl_NL nl_NL@euro nl_NL.utf8 nl_NL.UTF-8 nn_NO nn_NO.utf8 nn_NO.UTF-8 no_NO no_NO.utf8 no_NO.UTF-8 oc_FR oc_FR.utf8 oc_FR.UTF-8 pl_PL pl_PL.utf8 pl_PL.UTF-8 pt_BR pt_BR.utf8 pt_BR.UTF-8 pt_PT pt_PT@euro pt_PT.utf8 pt_PT.UTF-8 ro_RO ro_RO.utf8 ro_RO.UTF-8 ru_RU ru_RU.koi8r ru_RU.utf8 ru_RU.UTF-8 ru_UA ru_UA.utf8 ru_UA.UTF-8 se_NO se_NO.utf8 se_NO.UTF-8 sh_YU sh_YU.utf8 sh_YU.UTF-8 sk_SK sk_SK.utf8 sk_SK.UTF-8 sl_SI sl_SI.utf8 sl_SI.UTF-8 sq_AL sq_AL.utf8 sq_AL.UTF-8 sr_CS sr_CS.utf8 sr_CS.UTF-8 sv_FI sv_FI@euro sv_FI.utf8 sv_FI.UTF-8 sv_SE sv_SE.iso885915 sv_SE.utf8 sv_SE.UTF-8 tg_TJ tg_TJ.utf8 tg_TJ.UTF-8 tr_TR tr_TR.utf8 tr_TR.UTF-8 tt_RU.utf8 tt_RU.UTF-8 uk_UA uk_UA.utf8 uk_UA.UTF-8 vi_VN vi_VN.tcvn wa_BE wa_BE@euro wa_BE.utf8 wa_BE.UTF-8 version-0.9918/t/00impl-pp.t0000644000175000017500000000116013076366721015610 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; use File::Spec; BEGIN { my $coretests = File::Spec->rel2abs( File::Spec->catpath( (File::Spec->splitpath($0))[0,1], 'coretests.pm' ) ); require $coretests; use_ok('version::vpp', 0.9918); } BaseTests("version::vpp","new","qv"); BaseTests("version::vpp","new","declare"); BaseTests("version::vpp","parse", "qv"); BaseTests("version::vpp","parse", "declare"); version-0.9918/t/11_taint.t0000644000175000017500000000102013076366721015505 0ustar jpeacockjpeacock#!perl -T use Test::More; use version; BEGIN { eval "use Test::Taint"; if ($@) { plan skip_all => "No Test::Taint available"; } else { plan tests => 6; } } taint_checking_ok(); my $v = 'v1.2.3'; taint($v); tainted_ok($v, 'Set string as tainted'); my $v2 = version->parse($v); isnt("$v2", '', 'Correctly parsed the tainted string'); tainted_ok($v2, 'Resulting version object is tainted'); my $vs = "$v2"; tainted_ok($vs, 'Stringified object still tainted'); is $v2, 'v1.2.3', 'Comparison to tainted object'; version-0.9918/t/05sigdie.t0000644000175000017500000000066713076366721015516 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More tests => 1; BEGIN { $SIG{__DIE__} = sub { warn @_; BAIL_OUT( q[Couldn't use module; can't continue.] ); }; } BEGIN { use version 0.9918; } pass "Didn't get caught by the wrong DIE handler, which is a good thing"; version-0.9918/t/03require.t0000644000175000017500000000153513076366721015717 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; use File::Spec; BEGIN { my $coretests = File::Spec->rel2abs( File::Spec->catpath( (File::Spec->splitpath($0))[0,1], 'coretests.pm' ) ); require $coretests; } # Don't want to use, because we need to make sure that the import doesn't # fire just yet (some code does this to avoid importing qv() and delare()). require_ok("version"); is $version::VERSION, 0.9918, "Make sure we have the correct class"; ok(!"main"->can("qv"), "We don't have the imported qv()"); ok(!"main"->can("declare"), "We don't have the imported declare()"); BaseTests("version","new",undef); BaseTests("version","parse",undef); version-0.9918/t/01base.t0000644000175000017500000000303713076366721015152 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; use File::Spec; BEGIN { my $coretests = File::Spec->rel2abs( File::Spec->catpath( (File::Spec->splitpath($0))[0,1], 'coretests.pm' ) ); require $coretests; use_ok('version', 0.9918); } BaseTests("version","new","qv"); BaseTests("version","new","declare"); BaseTests("version","parse", "qv"); BaseTests("version","parse", "declare"); # dummy up a redundant call to satify David Wheeler local $SIG{__WARN__} = sub { die $_[0] }; eval 'use version;'; unlike ($@, qr/^Subroutine main::declare redefined/, "Only export declare once per package (to prevent redefined warnings)."); # https://rt.cpan.org/Ticket/Display.html?id=47980 my $v = eval { require IO::Handle; $@ = qq(Can't locate some/completely/fictitious/module.pm); return IO::Handle->VERSION; }; ok defined($v), 'Fix for RT #47980'; { # https://rt.cpan.org/Ticket/Display.html?id=81085 eval { version::new() }; like $@, qr'Usage: version::new\(class, version\)', 'No bus err when called as function'; eval { $x = 1; print version::new }; like $@, qr'Usage: version::new\(class, version\)', 'No implicit object creation when called as function'; eval { $x = "version"; print version::new }; like $@, qr'Usage: version::new\(class, version\)', 'No implicit object creation when called as function'; } version-0.9918/t/survey_locales0000755000175000017500000000057212610623754016673 0ustar jpeacockjpeacock#!/usr/bin/perl -w use POSIX qw/locale_h/; my $orig_loc = setlocale( LC_ALL ); my $loc; open my $LOCALES, '-|', 'locale -a'; local $\ = "\n"; print "The following locales use comma as decimal point"; while (<$LOCALES>) { chomp; $loc = setlocale( LC_ALL, $_); print $_ if localeconv()->{decimal_point} eq ','; } close $LOCALES; $loc = setlocale( LC_ALL, $orig_loc); version-0.9918/t/06noop.t0000644000175000017500000000244713076366721015224 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; BEGIN { use_ok('version', 0.9918); } my $v1 = version->new('1.2'); eval {$v1 = $v1 + 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 = $v1 - 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 = $v1 / 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 = $v1 * 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 = abs($v1)}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 += 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 -= 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 /= 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; eval {$v1 *= 1}; like $@, qr/operation not supported with version object/, 'No math ops with version objects'; version-0.9918/t/coretests.pm0000644000175000017500000005631312750333532016260 0ustar jpeacockjpeacock#! /usr/local/perl -w package main; require Test::Harness; use Data::Dumper; use File::Temp qw/tempfile/; use File::Basename; if ($Test::More::VERSION < 0.48) { # Fix for RT#48268 local $^W; *main::use_ok = sub ($;@) { my ($pkg, $req, @args) = @_; eval "use $pkg $req ".join(' ',@args); is ${"$pkg\::VERSION"}, eval($req), 'Had to manually use version'; # If we made it this far, we are ok. }; } sub BaseTests { my ($CLASS, $method, $qv_declare) = @_; my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # Test bare number processing $version = $CLASS->$method(5.005_03); is ( "$version" , "5.00503" , '5.005_03 eq 5.00503' ); $version = $CLASS->$method(1.23); is ( "$version" , "1.23" , '1.23 eq "1.23"' ); # Test explicit integer $version = $CLASS->$method(23); is ( "$version" , 23 , '23 eq "23"' ); # Test quoted number processing $version = $CLASS->$method("5.005_03"); is ( "$version" , "5.005_03" , '"5.005_03" eq "5.005_03"' ); $version = $CLASS->$method("v1.23"); is ( "$version" , "v1.23" , '"v1.23" eq "v1.23"' ); # Test stringify operator $version = $CLASS->$method("5.005"); is ( "$version" , "5.005" , '5.005 eq "5.005"' ); $version = $CLASS->$method("5.006.001"); is ( "$version" , "5.006.001" , '5.006.001 eq v5.6.1' ); unlike ($warning, qr/v-string without leading 'v' deprecated/, 'No leading v'); $version = $CLASS->$method("v1.2.3_4"); is ( "$version" , "v1.2.3_4" , 'alpha version 1.2.3_4 eq v1.2.3_4' ); # test illegal formats eval {my $version = $CLASS->$method("1.2_3_4")}; like($@, qr/multiple underscores/, "Invalid version format (multiple underscores)"); eval {my $version = $CLASS->$method("1.2_3.4")}; like($@, qr/underscores before decimal/, "Invalid version format (underscores before decimal)"); eval {my $version = $CLASS->$method("1_2")}; like($@, qr/alpha without decimal/, "Invalid version format (alpha without decimal)"); eval { $version = $CLASS->$method("1.2b3")}; like($@, qr/non-numeric data/, "Invalid version format (non-numeric data)"); eval { $version = $CLASS->$method("-1.23")}; like($@, qr/negative version number/, "Invalid version format (negative version number)"); # from here on out capture the warning and test independently { eval{$version = $CLASS->$method("99 and 44/100 pure")}; like($@, qr/non-numeric data/, "Invalid version format (non-numeric data)"); eval{$version = $CLASS->$method("something")}; like($@, qr/non-numeric data/, "Invalid version format (non-numeric data)"); # reset the test object to something reasonable $version = $CLASS->$method("1.2.3"); # Test boolean operator ok ($version, 'boolean'); # Test class membership isa_ok ( $version, $CLASS ); # Test comparison operators with self is ( $version <=> $version, 0, '$version <=> $version == 0' ); ok ( $version == $version, '$version == $version' ); # Test Numeric Comparison operators # test first with non-object $version = $CLASS->$method("5.006.001"); $new_version = "5.8.0"; ok ( $version == $version, '$version == $version' ); ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); # now test with existing object $new_version = $CLASS->$method($new_version); ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); # now test with actual numbers ok ( $version->numify() == 5.006001, '$version->numify() == 5.006001' ); ok ( $version->numify() <= 5.006001, '$version->numify() <= 5.006001' ); ok ( $version->numify() < 5.008, '$version->numify() < 5.008' ); #ok ( $version->numify() > v5.005_02, '$version->numify() > 5.005_02' ); # test with long decimals $version = $CLASS->$method(1.002003); ok ( $version == "1.2.3", '$version == "1.2.3"'); ok ( $version->numify == 1.002003, '$version->numify == 1.002003'); $version = $CLASS->$method("2002.09.30.1"); ok ( $version == "2002.9.30.1",'$version == 2002.9.30.1'); ok ( $version->numify == 2002.009030001, '$version->numify == 2002.009030001'); # now test with alpha version form with string $version = $CLASS->$method("1.2.3"); $new_version = "1.2.3_4"; ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); $version = $CLASS->$method("1.2.4"); ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); # now test with alpha version form with object $version = $CLASS->$method("1.2.3"); $new_version = $CLASS->$method("1.2.3_4"); ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); ok ( !$version->is_alpha, '!$version->is_alpha'); ok ( $new_version->is_alpha, '$new_version->is_alpha'); $version = $CLASS->$method("1.2.4"); ok ( $version < $new_version, '$version < $new_version' ); ok ( $new_version > $version, '$new_version > $version' ); ok ( $version != $new_version, '$version != $new_version' ); $version = $CLASS->$method("1.2.34"); $new_version = $CLASS->$method("1.2.3_4"); ok ( $version == $new_version, '$version == $new_version' ); $version = $CLASS->$method("v1.2.30"); $new_version = $CLASS->$method("1.2.30.0"); ok ( $version == $new_version, '$version == $new_version' ); $new_version = $CLASS->$method("1.2.3_0"); ok ( $version == $new_version, '$version == $new_version' ); $new_version = $CLASS->$method("1.2.30.1"); ok ( $version < $new_version, '$version < $new_version' ); $new_version = $CLASS->$method("1.2.30_1"); ok ( $version < $new_version, '$version < $new_version' ); $new_version = $CLASS->$method("1.1.999"); ok ( $version > $new_version, '$version > $new_version' ); $version = $CLASS->$method("v1.2.3"); eval { () = $version < 'version' }; # this test, and only this test, I have to do this or else $@ gets # "reset" before like() has a chance to evaluate it. Quite maddening!!! my $err = $@; like $err, qr/^Invalid version format/, "error with $version < 'version'"; # that which is not expressly permitted is forbidden ok ( !eval { ++$version }, "noop ++" ); ok ( !eval { --$version }, "noop --" ); ok ( !eval { $version/1 }, "noop /" ); ok ( !eval { $version*3 }, "noop *" ); ok ( !eval { abs($version) }, "noop abs" ); SKIP: { skip "version require'd instead of use'd, cannot test $qv_declare", 3 unless defined $qv_declare; # test the $qv_declare() sub $version = $CLASS->$qv_declare("1.2"); is ( "$version", "v1.2", $qv_declare.'("1.2") == "1.2.0"' ); $version = $CLASS->$qv_declare(1.2); is ( "$version", "v1.2", $qv_declare.'(1.2) == "1.2.0"' ); isa_ok( $CLASS->$qv_declare('5.008'), $CLASS ); } # test creation from existing version object ok (eval {$new_version = $CLASS->$method($version)}, "new from existing object"); ok ($new_version == $version, "class->$method($version) identical"); $new_version = $version->$method(0); isa_ok ($new_version, $CLASS ); is ($new_version, "0", "version->$method() doesn't clone"); $new_version = $version->$method("1.2.3"); is ($new_version, "1.2.3" , '$version->$method("1.2.3") works too'); # test the CVS revision mode $version = new $CLASS qw$Revision: 1.2$; ok ( $version == "1.2.0", 'qw$Revision: 1.2$ == 1.2.0' ); $version = new $CLASS qw$Revision: 1.2.3.4$; ok ( $version == "1.2.3.4", 'qw$Revision: 1.2.3.4$ == 1.2.3.4' ); # test the CPAN style reduced significant digit form $version = $CLASS->$method("1.23_01"); is ( "$version" , "1.23_01", "CPAN-style alpha version" ); ok ( $version > 1.23, "1.23_01 > 1.23"); ok ( $version < 1.24, "1.23_01 < 1.24"); # test reformed UNIVERSAL::VERSION my $error_regex = $] < 5.006 ? 'version \d required' : 'does not define \$t.{7}::VERSION'; { my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh "package $package;\n\$$package\::VERSION=0.58;\n1;\n"; close $fh; $version = 0.58; eval "use lib '.'; use $package $version"; unlike($@, qr/$package version $version/, 'Replacement eval works with exact version'); # test as class method $new_version = $package->VERSION; cmp_ok($new_version,'==',$version, "Called as class method"); eval "print Completely::Unknown::Module->VERSION"; if ( $] < 5.008 ) { unlike($@, qr/$error_regex/, "Don't freak if the module doesn't even exist"); } else { unlike($@, qr/defines neither package nor VERSION/, "Don't freak if the module doesn't even exist"); } # this should fail even with old UNIVERSAL::VERSION $version += 0.01; eval "use lib '.'; use $package $version"; like($@, qr/$package version $version/, 'Replacement eval works with incremented version'); $version =~ s/0+$//; #convert to string and remove trailing 0's chop($version); # shorten by 1 digit, should still succeed eval "use lib '.'; use $package $version"; unlike($@, qr/$package version $version/, 'Replacement eval works with single digit'); # this would fail with old UNIVERSAL::VERSION $version += 0.1; eval "use lib '.'; use $package $version"; like($@, qr/$package version $version/, 'Replacement eval works with incremented digit'); unlink $filename; } { # dummy up some variously broken modules for testing my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh "1;\n"; close $fh; eval "use lib '.'; use $package 3;"; if ( $] < 5.008 ) { like($@, qr/$error_regex/, 'Replacement handles modules without package or VERSION'); } else { like($@, qr/defines neither package nor VERSION/, 'Replacement handles modules without package or VERSION'); } eval "use lib '.'; use $package; \$version = $package->VERSION"; unlike ($@, qr/$error_regex/, 'Replacement handles modules without package or VERSION'); ok (!defined($version), "Called as class method"); unlink $filename; } { # dummy up some variously broken modules for testing my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh "package $package;\n#look ma no VERSION\n1;\n"; close $fh; eval "use lib '.'; use $package 3;"; like ($@, qr/$error_regex/, 'Replacement handles modules without VERSION'); eval "use lib '.'; use $package; print $package->VERSION"; unlike ($@, qr/$error_regex/, 'Replacement handles modules without VERSION'); unlink $filename; } { # dummy up some variously broken modules for testing my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh "package $package;\n\@VERSION = ();\n1;\n"; close $fh; eval "use lib '.'; use $package 3;"; like ($@, qr/$error_regex/, 'Replacement handles modules without VERSION'); eval "use lib '.'; use $package; print $package->VERSION"; unlike ($@, qr/$error_regex/, 'Replacement handles modules without VERSION'); unlink $filename; } SKIP: { # https://rt.perl.org/rt3/Ticket/Display.html?id=95544 skip "version require'd instead of use'd, cannot test UNIVERSAL::VERSION", 2 unless defined $qv_declare; my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh "package $package;\n\$VERSION = '3alpha';\n1;\n"; close $fh; eval "use lib '.'; use $package; print $package->VERSION"; like ($@, qr/Invalid version format \(non-numeric data\)/, 'Warn about bad \$VERSION'); eval "use lib '.'; use $package 1;"; like ($@, qr/Invalid version format \(non-numeric data\)/, 'Warn about bad $VERSION'); } SKIP: { skip 'Cannot test bare v-strings with Perl < 5.6.0', 4 if $] < 5.006_000; $version = $CLASS->$method(1.2.3); ok("$version" eq "v1.2.3", '"$version" eq 1.2.3'); $version = $CLASS->$method(1.0.0); $new_version = $CLASS->$method(1); ok($version == $new_version, '$version == $new_version'); skip "version require'd instead of use'd, cannot test declare", 1 unless defined $qv_declare; $version = &$qv_declare(1.2.3); ok("$version" eq "v1.2.3", 'v-string initialized $qv_declare()'); } SKIP: { skip 'Cannot test bare alpha v-strings with Perl < 5.8.1', 2 if $] lt 5.008_001; $version = $CLASS->$method(v1.2.3_4); $DB::single = 1; is($version, "v1.2.34", '"$version" eq "v1.2.34"'); $version = $CLASS->$method(eval "v1.2.3_4"); is($version, "v1.2.34", '"$version" eq "v1.2.34" (from eval)'); } # trailing zero testing (reported by Andreas Koenig). $version = $CLASS->$method("1"); ok($version->numify eq "1.000", "trailing zeros preserved"); $version = $CLASS->$method("1.0"); ok($version->numify eq "1.000", "trailing zeros preserved"); $version = $CLASS->$method("1.0.0"); ok($version->numify eq "1.000000", "trailing zeros preserved"); $version = $CLASS->$method("1.0.0.0"); ok($version->numify eq "1.000000000", "trailing zeros preserved"); # leading zero testing (reported by Andreas Koenig). $version = $CLASS->$method(".7"); ok($version->numify eq "0.700", "leading zero inferred"); # leading space testing (reported by Andreas Koenig). $version = $CLASS->$method(" 1.7"); ok($version->numify eq "1.700", "leading space ignored"); # RT 19517 - deal with undef and 'undef' initialization ok("$version" ne 'undef', "Undef version comparison #1"); ok("$version" ne undef, "Undef version comparison #2"); $version = $CLASS->$method('undef'); unlike($warning, qr/^Version string 'undef' contains invalid data/, "Version string 'undef'"); $version = $CLASS->$method(undef); like($warning, qr/^Use of uninitialized value/, "Version string 'undef'"); ok($version == 'undef', "Undef version comparison #3"); ok($version == undef, "Undef version comparison #4"); eval "\$version = \$CLASS->$method()"; # no parameter at all unlike($@, qr/^Bizarre copy of CODE/, "No initializer at all"); ok($version == 'undef', "Undef version comparison #5"); ok($version == undef, "Undef version comparison #6"); $version = $CLASS->$method(0.000001); unlike($warning, qr/^Version string '1e-06' contains invalid data/, "Very small version objects"); } SKIP: { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; # dummy up a legal module for testing RT#19017 my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh <<"EOF"; package $package; use $CLASS; \$VERSION = ${CLASS}->new('0.0.4'); 1; EOF close $fh; eval "use lib '.'; use $package 0.000008;"; like ($@, qr/^$package version 0.000008 required/, "Make sure very small versions don't freak"); eval "use lib '.'; use $package 1;"; like ($@, qr/^$package version 1 required/, "Comparing vs. version with no decimal"); eval "use lib '.'; use $package 1.;"; like ($@, qr/^$package version 1 required/, "Comparing vs. version with decimal only"); if ( $] < 5.006_000 ) { skip 'Cannot "use" extended versions with Perl < 5.6.0', 3; } eval "use lib '.'; use $package v0.0.8;"; my $regex = "^$package version v0.0.8 required"; like ($@, qr/$regex/, "Make sure very small versions don't freak"); $regex =~ s/8/4/; # set for second test eval "use lib '.'; use $package v0.0.4;"; unlike($@, qr/$regex/, 'Succeed - required == VERSION'); cmp_ok ( $package->VERSION, 'eq', '0.0.4', 'No undef warnings' ); unlink $filename; } SKIP: { skip "Cannot test \"use parent $CLASS\" when require is used", 3 unless defined $qv_declare; my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh <<"EOF"; package $package; use parent $CLASS; 1; EOF close $fh; # need to eliminate any other $qv_declare()'s undef *{"main\::$qv_declare"}; ok(!defined(&{"main\::$qv_declare"}), "make sure we cleared $qv_declare() properly"); eval "use lib '.'; use $package qw/declare qv/;"; ok(defined(&{"main\::$qv_declare"}), "make sure we exported $qv_declare() properly"); isa_ok( &$qv_declare(1.2), $package); unlink $filename; } SKIP: { if ( $] < 5.006_000 ) { skip 'Cannot "use" extended versions with Perl < 5.6.0', 3; } my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1); (my $package = basename($filename)) =~ s/\.pm$//; print $fh <<"EOF"; package $package; \$VERSION = 1.0; 1; EOF close $fh; eval "use lib '.'; use $package 1.001;"; like ($@, qr/^$package version 1.001 required/, "User typed numeric so we error with numeric"); eval "use lib '.'; use $package v1.1.0;"; like ($@, qr/^$package version v1.1.0 required/, "User typed extended so we error with extended"); unlink $filename; } eval 'my $v = $CLASS->$method("1._1");'; unlike($@, qr/^Invalid version format \(alpha with zero width\)/, "Invalid version format 1._1"); { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; eval 'my $v = $CLASS->$method(~0);'; unlike($@, qr/Integer overflow in version/, "Too large version"); like($warning, qr/Integer overflow in version/, "Too large version"); } { local $Data::Dumper::Sortkeys= 1; # http://rt.cpan.org/Public/Bug/Display.html?id=30004 my $v1 = $CLASS->$method("v0.1_1"); (my $alpha1 = Dumper($v1)) =~ s/.+'alpha' => ([^,]+),.+/$1/ms; my $v2 = $CLASS->$method($v1); (my $alpha2 = Dumper($v2)) =~ s/.+'alpha' => ([^,]+),.+/$1/ms; is $alpha2, $alpha1, "Don't fall for Data::Dumper's tricks"; } { # http://rt.perl.org/rt3/Ticket/Display.html?id=56606 my $badv = bless { version => [1,2,3] }, $CLASS; is $badv, '1.002003', "Deal with badly serialized versions from YAML"; my $badv2 = bless { qv => 1, version => [1,2,3] }, $CLASS; is $badv2, 'v1.2.3', "Deal with badly serialized versions from YAML "; } { # https://rt.cpan.org/Public/Bug/Display.html?id=70950 # test indirect usage of version objects my $sum = 0; eval '$sum += $CLASS->$method("v2.0.0")'; like $@, qr/operation not supported with version object/, 'No math operations with version objects'; # test direct usage of version objects my $v = $CLASS->$method("v2.0.0"); eval '$v += 1'; like $@, qr/operation not supported with version object/, 'No math operations with version objects'; } { # https://rt.cpan.org/Ticket/Display.html?id=72365 # https://rt.perl.org/rt3/Ticket/Display.html?id=102586 # https://rt.cpan.org/Ticket/Display.html?id=78328 eval 'my $v = $CLASS->$method("version")'; like $@, qr/Invalid version format/, "The string 'version' is not a version for $method"; eval 'my $v = $CLASS->$method("ver510n")'; like $@, qr/Invalid version format/, 'All strings starting with "v" are not versions'; } SKIP: { if ( $] < 5.006_000 ) { skip 'No v-string support at all < 5.6.0', 2; } # https://rt.cpan.org/Ticket/Display.html?id=49348 my $v = $CLASS->$method("420"); is "$v", "420", 'Correctly guesses this is not a v-string'; $v = $CLASS->$method(4.2.0); is "$v", 'v4.2.0', 'Correctly guess that this is a v-string'; } SKIP: { if ( $] < 5.006_000 ) { skip 'No v-string support at all < 5.6.0', 4; } # https://rt.cpan.org/Ticket/Display.html?id=50347 # Check that the qv() implementation does not change ok $CLASS->$method(1.2.3) < $CLASS->$method(1.2.3.1), 'Compare 3 and 4 digit v-strings' ; ok $CLASS->$method(v1.2.3) < $CLASS->$method(v1.2.3.1), 'Compare 3 and 4 digit v-strings, leaving v'; ok $CLASS->$method("1.2.3") < $CLASS->$method("1.2.3.1"), 'Compare 3 and 4 digit v-strings, quoted'; ok $CLASS->$method("v1.2.3") < $CLASS->$method("v1.2.3.1"), 'Compare 3 and 4 digit v-strings, quoted leading v'; } { eval '$CLASS->$method("version")'; pass("no crash with ${CLASS}->${method}('version')"); { package _102586; sub TIESCALAR { bless [] } sub FETCH { "version" } sub STORE { } my $v; tie $v, __PACKAGE__; $v = $CLASS->$method(1); eval '$CLASS->$method($v)'; } pass('no crash with version->new($tied) where $tied returns "version"'); } { # [perl #112478] $_112478::VERSION = 9e99; ok eval { _112478->VERSION(9e99); 1 }, '->VERSION(9e99) succeeds' or diag $@; $_112478::VERSION = 1; eval { _112478->VERSION(9e99) }; unlike $@, qr/panic/, '->VERSION(9e99) does not panic'; } { # https://rt.cpan.org/Ticket/Display.html?id=79259 my $v = $CLASS->new("0.52_0"); ok $v->is_alpha, 'Just checking'; is $v->numify, '0.520', 'Correctly nummified'; } { # https://rt.cpan.org/Ticket/Display.html?id=88495 @ver::ISA = $CLASS; is ref(ver->new), 'ver', 'ver can inherit from version'; is ref(ver->qv("1.2.3")), 'ver', 'ver can inherit from version'; } { # discovered while integrating with bleadperl eval {my $v = $CLASS->new([1,2,3]) }; like $@, qr/Invalid version format/, 'Do not crash for garbage'; eval {my $v = $CLASS->new({1 => 2}) }; like $@, qr/Invalid version format/, 'Do not crash for garbage'; } { # https://rt.cpan.org/Ticket/Display.html?id=93603 eval {my $v = $CLASS->$method('.1.')}; like $@, qr/trailing decimal/, 'Forbid trailing decimals'; eval {my $v = $CLASS->$method('.1.2.')}; like $@, qr/trailing decimal/, 'Forbid trailing decimals'; } { # https://rt.cpan.org/Ticket/Display.html?id=93715 eval {my $v = $CLASS->new(v1.2)}; unlike $@, qr/non-numeric data/, 'Handle short v-strings'; eval {my $v = $CLASS->new(v1)}; unlike $@, qr/non-numeric data/, 'Handle short v-strings'; } { my $two31 = '2147483648'; my $v = $CLASS->new($two31); is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX'; like $warning, qr/Integer overflow in version/, 'Overflow warning'; $v = $CLASS->new("1.$two31.$two31"); is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX'; like $warning, qr/Integer overflow in version/, 'Overflow warning'; } { # now as a number $two31 = 2**31; $v = $CLASS->new($two31); is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX'; like $warning, qr/Integer overflow in version/, 'Overflow warning'; } { # https://rt.cpan.org/Ticket/Display.html?id=101628 undef $warning; $v = $CLASS->new('1.1.00000000010'); is $v->normal, "v1.1.10", 'Ignore leading zeros'; unlike $warning, qr/Integer overflow in version/, 'No overflow warning'; } { # https://rt.cpan.org/Ticket/Display.html?id=93340 $v = $CLASS->parse(q[2.6_01]); is $v->normal, 'v2.601.0', 'Normal strips underscores from alphas' } { # https://rt.cpan.org/Ticket/Display.html?id=98744 $v = $CLASS->new("1.02_003"); is $v->numify, '1.020030', 'Ignore underscores for numify'; } } 1; version-0.9918/t/09_list_util.t0000644000175000017500000000147313076366721016421 0ustar jpeacockjpeacock# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use strict; use_ok("version", 0.9918); use Test::More; BEGIN { eval "use List::Util qw(reduce)"; if ($@) { plan skip_all => "No List::Util::reduce() available"; } else { plan tests => 3; } } # do strict lax tests in a sub to isolate a package to test importing # use again to get the import() use List::Util qw(reduce); { my $fail = 0; my $ret = reduce { version->parse($a); $fail++ unless defined $a; 1 } "0.039", "0.035"; is $fail, 0, 'reduce() with parse'; } { my $fail = 0; my $ret = reduce { version->qv($a); $fail++ unless defined $a; 1 } "0.039", "0.035"; is $fail, 0, 'reduce() with qv'; } version-0.9918/t/08_corelist.t0000644000175000017500000000127413076366721016233 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More tests => 3; use_ok("version", 0.9918); # do strict lax tests in a sub to isolate a package to test importing SKIP: { eval "use Module::CoreList 2.76"; skip 'No tied hash in Modules::CoreList in Perl', 2 if $@; my $foo = version->parse($Module::CoreList::version{5.008_000}{base}); is $foo, 1.03, 'Correctly handle tied hash'; $foo = version->qv($Module::CoreList::version{5.008_000}{Unicode}); is $foo, '3.2.0', 'Correctly handle tied hash with dotted decimal'; } version-0.9918/t/04strict_lax.t0000644000175000017500000000712513076366721016421 0ustar jpeacockjpeacock#! /usr/local/perl -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More qw/no_plan/; # do strict lax tests in a sub to isolate a package to test importing SKIP: { skip 'No extended regexes Perl < 5.006', 174 if $] < 5.006_000; strict_lax_tests(); is ref($version::LAX), 'Regexp', 'Can see $version::LAX '.$version::LAX ; is ref($version::STRICT), 'Regexp', 'Can see $version::STRICT '.$version::STRICT; { # https://rt.cpan.org/Ticket/Display.html?id=114712 my ($v) = ( "snapshot-1.2.3ga-001-432" =~ /($version::LAX)/ ); is $v, '1.2.3', "Extract just the version: $v"; ($v) = ( "snapshot-1.2ga-001-432" =~ /($version::LAX)/ ); is $v, '1.2', "Extract just the version: $v"; ($v) = ( "snapshot-v1.2.3ga-001-432" =~ /($version::STRICT)/ ); is $v, 'v1.2.3', "Extract just the version: $v"; } is ref($version::LAX_DECIMAL_VERSION), 'Regexp', 'Can see $version::LAX_DECIMAL_VERSION '.$version::LAX_DECIMAL_VERSION ; is ref($version::LAX_DOTTED_DECIMAL_VERSION), 'Regexp', 'Can see $version::LAX_DOTTED_DECIMAL_VERSION '.$version::LAX_DOTTED_DECIMAL_VERSION ; is ref($version::STRICT_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DECIMAL_VERSION '.$version::STRICT_DECIMAL_VERSION; is ref($version::STRICT_DOTTED_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DOTTED_DECIMAL_VERSION '.$version::STRICT_DOTTED_DECIMAL_VERSION; { # https://rt.cpan.org/Ticket/Display.html?id=119669 ($v) = ( "snapshot-1.2.3ga-001-432" =~ /($version::LAX_DOTTED_DECIMAL_VERSION)/ ); is $v, '1.2.3', "Extract just the version: $v"; ($v) = ( "snapshot-1.2ga-001-432" =~ /($version::LAX_DECIMAL_VERSION)/ ); is $v, '1.2', "Extract just the version: $v"; ($v) = ( "snapshot-v1.2.3ga-001-432" =~ /($version::STRICT_DOTTED_DECIMAL_VERSION)/ ); is $v, 'v1.2.3', "Extract just the version: $v"; ($v) = ( "snapshot-1.2ga-001-432" =~ /($version::STRICT_DECIMAL_VERSION)/ ); is $v, '1.2', "Extract just the version: $v"; } } sub strict_lax_tests { package temp12345; # copied from perl core test t/op/packagev.t # format: STRING STRICT_OK LAX_OK my $strict_lax_data = << 'CASE_DATA'; 1.00 pass pass 1.00001 pass pass 0.123 pass pass 12.345 pass pass 42 pass pass 0 pass pass 0.0 pass pass v1.2.3 pass pass v1.2.3.4 pass pass v0.1.2 pass pass v0.0.0 pass pass 01 fail pass 01.0203 fail pass v01 fail pass v01.02.03 fail pass .1 fail pass .1.2 fail pass 1. fail pass 1.a fail fail 1._ fail fail 1.02_03 fail pass v1.2_3 fail pass v1.02_03 fail pass v1.2_3_4 fail fail v1.2_3.4 fail fail 1.2_3.4 fail fail 0_ fail fail 1_ fail fail 1_. fail fail 1.1_ fail fail 1.02_03_04 fail fail 1.2.3 fail pass v1.2 fail pass v0 fail pass v1 fail pass v.1.2.3 fail fail v fail fail v1.2345.6 fail pass undef fail pass 1a fail fail 1.2a3 fail fail bar fail fail _ fail fail CASE_DATA require version; version->import( qw/is_strict is_lax/ ); for my $case ( split qr/\n/, $strict_lax_data ) { my ($v, $strict, $lax) = split qr/\t+/, $case; main::ok( $strict eq 'pass' ? is_strict($v) : ! is_strict($v), "is_strict($v) [$strict]" ); main::ok( $strict eq 'pass' ? version::is_strict($v) : ! version::is_strict($v), "version::is_strict($v) [$strict]" ); main::ok( $lax eq 'pass' ? is_lax($v) : ! is_lax($v), "is_lax($v) [$lax]" ); main::ok( $lax eq 'pass' ? version::is_lax($v) : ! version::is_lax($v), "version::is_lax($v) [$lax]" ); } } version-0.9918/t/10_lyon.t0000644000175000017500000000277413074407232015356 0ustar jpeacockjpeacock#! perl use Test::More qw/no_plan/; use version; # These values are from the Lyon consensus, as taken from # https://gist.github.com/dagolden/9559280 ok(version->new(1.0203) == version->new('1.0203')); ok(version->new(1.02_03) == version->new('1.02_03')); ok(version->new(v1.2.3) == version->new('v1.2.3')); if ($] >= 5.008_001) { ok(version->new(v1.2.3_0) == version->new('v1.2.3_0')); } cmp_ok(version->new(1.0203), '==', version->new('1.0203')); cmp_ok(version->new(1.02_03), '==', version->new('1.02_03')); cmp_ok(version->new(v1.2.3), '==', version->new('v1.2.3')); if ($] >= 5.008_001) { cmp_ok(version->new(v1.2.3_0), '==', version->new('v1.2.3_0')); } cmp_ok(version->new('1.0203')->numify, '==', '1.0203'); is(version->new('1.0203')->normal, 'v1.20.300'); cmp_ok(version->new('1.02_03')->numify, '==', '1.0203'); is(version->new('1.02_03')->normal, 'v1.20.300'); cmp_ok(version->new('v1.2.30')->numify, '==', '1.002030'); is(version->new('v1.2.30')->normal, 'v1.2.30'); cmp_ok(version->new('v1.2.3_0')->numify, '==', '1.002030'); is(version->new('v1.2.3_0')->normal, 'v1.2.30'); is(version->new("1.0203")->stringify, "1.0203"); is(version->new("1.02_03")->stringify, "1.02_03"); is(version->new("v1.2.30")->stringify, "v1.2.30"); is(version->new("v1.2.3_0")->stringify, "v1.2.3_0"); is(version->new(1.0203)->stringify, "1.0203"); is(version->new(1.02_03)->stringify, "1.0203"); is(version->new(v1.2.30)->stringify, "v1.2.30"); if ($] >= 5.008_001) { is(version->new(v1.2.3_0)->stringify, "v1.2.30"); } version-0.9918/Makefile.PL0000644000175000017500000001213513076366721015420 0ustar jpeacockjpeacock# This Makefile.PL stolen from Params::Validate # # The perl/C checking voodoo is stolen from Graham Barr's # Scalar-List-Utils distribution. use strict; use Config qw(%Config); use ExtUtils::MakeMaker; use File::Temp qw/tempdir tempfile/; if ($] < 5.006002) { die <<'EOL' Perl 5.006002 required. Please install version-0.9906 if you need to support an earlier Perl release. EOL } use vars qw ($no_xs $force_xs); unlink 'pm_to_blib'; # belts and braces if ($ENV{PERL_ONLY}) { $no_xs = 1; } for (@ARGV) { /^--perl_only/ and $no_xs = 1; /^--perl-only/ and $no_xs = 1; /^--xs/ and $force_xs = 1; } if ($] < 5.010) { # support pure Perl only $no_xs = 1; } unless (defined $no_xs or $force_xs) { check_for_compiler() or no_cc(); } write_makefile(); sub write_makefile { my %test_prereq = ( 'Test::More' => 0.45, 'File::Temp' => 0.13, 'parent' => 0.221, ); WriteMakefile( VERSION => '0.9918', NAME => 'version', LICENSE => 'perl', MIN_PERL_VERSION=> 5.006002, TEST_REQUIRES => \%test_prereq, NORECURS => $no_xs, ABSTRACT => 'Structured version objects', AUTHOR => 'John Peacock ', ( $] >= 5.009001 && $] < 5.011000 ? ( INSTALLDIRS => 'perl' ) : () ), ( ($] < 5.012 && ! $ENV{PERL_NO_HIGHLANDER} && ! ( $ENV{PERL_MM_OPT} && $ENV{PERL_MM_OPT} =~ /(?:INSTALL_BASE|PREFIX)/ ) && ! grep { /INSTALL_BASE/ || /PREFIX/ } @ARGV ) ? ( UNINST => 1 ) : () ), PM => {'lib/version.pm' => '$(INST_LIBDIR)/version.pm', 'lib/version.pod' => '$(INST_LIBDIR)/version.pod', 'lib/version/regex.pm' => '$(INST_LIBDIR)/version/regex.pm', 'lib/version/Internals.pod' => '$(INST_LIBDIR)/version/Internals.pod', 'vperl/vpp.pm' => '$(INST_LIBDIR)/version/vpp.pm', }, PL_FILES => {}, C => [], ( $no_xs ? () : ( DIR => ['vutil']) ), dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, META_MERGE => { "meta-spec" => { version => 2 }, resources => { repository => { type => 'hg', url => 'https://bitbucket.org/jpeacock/version' }, bugtracker => { web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=version', mailto => 'bug-version@rt.cpan.org', }, }, no_index => { package => ['charstar'], }, }, ); } sub no_cc { $no_xs = 1; print <<'EOF'; I cannot determine if you have a C compiler so I will install a perl-only implementation You can force installation of the XS version with perl Makefile.PL --xs EOF } sub check_for_compiler { # IMPORTANT NOTE: This is NOT used to determine how to compile # extensions properly; EU::MM does that for us. This is only # intended to see if that is likely to succeed. We do not try # to do anything here except compile (not even link). If you # want this to be a full featured test, feel free to submit a # patch or do something useful. print "Testing if you have a C compiler\n"; eval { require ExtUtils::CBuilder }; if ($@) { return _check_for_compiler_manually(); } else { return _check_for_compiler_with_cbuilder(); } } sub _check_for_compiler_with_cbuilder { my $cb = ExtUtils::CBuilder->new( quiet => 1 ); return $cb->have_compiler; } sub _check_for_compiler_manually { unless ( open F, ">test.c" ) { warn "Cannot write test.c, skipping test compilation and installing pure Perl version.\n"; return 0; } print F <<'EOF'; int main() { return 0; } EOF close F or return 0; my ($cc, $ccflags, $obj_ext) = map { $Config{$_} } qw/cc ccflags obj_ext/; my $command; if ($^O =~ /(dos|win32)/i && $Config{'cc'} =~ /^cl/) { $command = "$cc $ccflags /c test.c"; } elsif ($Config{gccversion}) { $command = "$cc $ccflags -o test$obj_ext test.c"; } else { warn "Unsupported system: can't test compiler availability. Patches welcome..."; return 0; } my $retval = system( $command ); map { unlink $_ if -f $_ } ('test.c',"test$obj_ext"); return not($retval); # system returns -1 } version-0.9918/META.json0000664000175000017500000000263613076366721015076 0ustar jpeacockjpeacock{ "abstract" : "Structured version objects", "author" : [ "John Peacock " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "version", "no_index" : { "directory" : [ "t", "inc" ], "package" : [ "charstar" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "perl" : "5.006002" } }, "test" : { "requires" : { "File::Temp" : "0.13", "Test::More" : "0.45", "parent" : "0.221" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-version@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=version" }, "repository" : { "type" : "hg", "url" : "https://bitbucket.org/jpeacock/version" } }, "version" : "0.9918", "x_serialization_backend" : "JSON::PP version 2.27300" } version-0.9918/MANIFEST0000644000175000017500000000115313076366721014575 0ustar jpeacockjpeacockCHANGES MANIFEST MANIFEST.SKIP Makefile.PL README lib/version.pm lib/version.pod lib/version/Internals.pod lib/version/regex.pm t/00impl-pp.t t/01base.t t/02derived.t t/03require.t t/04strict_lax.t t/05sigdie.t t/06noop.t t/07locale.t t/08_corelist.t t/09_list_util.t t/10_lyon.t t/11_taint.t t/coretests.pm t/survey_locales vperl/vpp.pm vutil/Makefile.PL vutil/lib/version/vxs.pm vutil/ppport.h vutil/vutil.c vutil/vutil.h vutil/vxs.inc vutil/vxs.xs META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker)