summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJohn Peacock <john.peacock@havurah-software.org>2013-03-06 19:22:26 -0500
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-03-07 19:14:00 +0000
commitb2a8d771f2f5721aa711c6ecdb42fdc198bfd244 (patch)
tree3d5418026ba426898422b255ae84fd3825ad4ecd /util.c
parent96d268e2f48e69b4cb65326df6690ffc21120f3c (diff)
downloadperl-b2a8d771f2f5721aa711c6ecdb42fdc198bfd244.tar.gz
Bring core up to version-0.9902
The attached patch bring the core Perl version code (including a fairly significant leak when run in a tight loop) up to parity with CPAN 0.9902. This deals with all open issues except: https://rt.cpan.org/Ticket/Display.html?id=81294 which I am having a hard time modeling. John Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
Diffstat (limited to 'util.c')
-rw-r--r--util.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/util.c b/util.c
index a3fbd3c30c..2c745bfd6c 100644
--- a/util.c
+++ b/util.c
@@ -4500,7 +4500,7 @@ it doesn't.
const char *
Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
{
- const char *start;
+ const char *start = s;
const char *pos;
const char *last;
const char *errstr = NULL;
@@ -4508,17 +4508,11 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
int width = 3;
bool alpha = FALSE;
bool vinf = FALSE;
- AV * const av = newAV();
- SV * const hv = newSVrv(rv, "version"); /* create an SV and upgrade the RV */
+ AV * av;
+ SV * hv;
PERL_ARGS_ASSERT_SCAN_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
-
while (isSPACE(*s)) /* leading whitespace is OK */
s++;
@@ -4526,6 +4520,7 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
if (errstr) {
/* "undef" is a special case and not an error */
if ( ! ( *s == 'u' && strEQ(s,"undef")) ) {
+ Safefree(start);
Perl_croak(aTHX_ "%s", errstr);
}
}
@@ -4535,13 +4530,22 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
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++;
if (!isALPHA(*pos)) {
@@ -4712,7 +4716,7 @@ Perl_new_version(pTHX_ SV *ver)
if ( hv_exists(MUTABLE_HV(ver), "alpha", 5) )
(void)hv_stores(MUTABLE_HV(hv), "alpha", newSViv(1));
-
+
if ( hv_exists(MUTABLE_HV(ver), "width", 5 ) )
{
const I32 width = SvIV(*hv_fetchs(MUTABLE_HV(ver), "width", FALSE));
@@ -4846,7 +4850,7 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
}
/* is definitely a v-string */
- if ( saw_decimal >= 2 ) {
+ if ( saw_decimal >= 2 ) {
Safefree(version);
version = nver;
}