RE: [PATCH] use 5.010 is ugly; use 5.10.0 warns
authorRobin Barker <RMBarker@cpan.org>
Wed, 26 Sep 2007 13:25:49 +0000 (14:25 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 26 Sep 2007 12:46:53 +0000 (12:46 +0000)
From: "Robin Barker" <Robin.Barker@npl.co.uk>
Message-ID: <2C2E01334A940D4792B3E115F95B7226C9D1C3@exchsvr1.npl.ad.local>

p4raw-id: //depot/perl@31978

embedvar.h
intrpvar.h
perlapi.h
pod/perldiag.pod
pod/perlfunc.pod
pp_ctl.c
sv.c
t/lib/warnings/pp_ctl

index 15057bc..93ba32e 100644 (file)
 #define PL_utf8_xdigit         (vTHX->Iutf8_xdigit)
 #define PL_utf8cache           (vTHX->Iutf8cache)
 #define PL_utf8locale          (vTHX->Iutf8locale)
+#define PL_v_string_ok         (vTHX->Iv_string_ok)
 #define PL_warnhook            (vTHX->Iwarnhook)
 #define PL_watchaddr           (vTHX->Iwatchaddr)
 #define PL_watchok             (vTHX->Iwatchok)
 #define PL_Iutf8_xdigit                PL_utf8_xdigit
 #define PL_Iutf8cache          PL_utf8cache
 #define PL_Iutf8locale         PL_utf8locale
+#define PL_Iv_string_ok                PL_v_string_ok
 #define PL_Iwarnhook           PL_warnhook
 #define PL_Iwatchaddr          PL_watchaddr
 #define PL_Iwatchok            PL_watchok
index a6a4a1c..6fd9b5d 100644 (file)
@@ -668,7 +668,9 @@ PERLVARI(Islabs, I32**, NULL)       /* Array of slabs that have been allocated */
 PERLVARI(Islab_count, U32, 0)  /* Size of the array */
 #endif
 
-PERLVARI(Iisarev, HV*, NULL) /* Reverse map of @ISA dependencies */
+PERLVARI(Iisarev, HV*, NULL)   /* Reverse map of @ISA dependencies */
+
+PERLVARI(Iv_string_ok, bool, FALSE)    /* use/require v_string OK */
 
 /* If you are adding a U8 or U16, see the 'Space' comments above on where
  * there are gaps which currently will be structure padding.  */
index 05cf09f..dfe593b 100644 (file)
--- a/perlapi.h
+++ b/perlapi.h
@@ -726,6 +726,8 @@ END_EXTERN_C
 #define PL_utf8cache           (*Perl_Iutf8cache_ptr(aTHX))
 #undef  PL_utf8locale
 #define PL_utf8locale          (*Perl_Iutf8locale_ptr(aTHX))
+#undef  PL_v_string_ok
+#define PL_v_string_ok         (*Perl_Iv_string_ok_ptr(aTHX))
 #undef  PL_warnhook
 #define PL_warnhook            (*Perl_Iwarnhook_ptr(aTHX))
 #undef  PL_watchaddr
index 1d2650f..9d79311 100644 (file)
@@ -4942,6 +4942,8 @@ C<use 5.006_001>.  This of course won't help: the older Perls
 won't suddenly start understanding newer features, but at least
 they will show a sensible error message indicating the required
 minimum version.
+This warning is suppressed if the C<use 5.x.y> is preceded by a
+C<use 5.006> (see C<use VERSION> in L<perlfunc/use>).
 
 =item Warning: something's wrong
 
index 48478f3..49df408 100644 (file)
@@ -6853,9 +6853,15 @@ avoided, because it leads to misleading error messages under earlier
 versions of Perl that do not support this syntax.  The equivalent numeric
 version should be used instead.
 
+Alternatively, you can use a numeric version C<use 5.006> followed by a
+v-string version like C<use v5.10.1>, to avoid the unintuitive C<use
+5.010_001>. (older perl versions fail gracefully at the first C<use>,
+later perl versions understand the v-string syntax in the second).
+
     use v5.6.1;                # compile time version check
     use 5.6.1;         # ditto
     use 5.006_001;     # ditto; preferred for backwards compatibility
+    use 5.006; use 5.6.1;      # ditto, for compatibility and readability
 
 This is often useful if you need to check the current Perl version before
 C<use>ing library modules that have changed in incompatible ways from
index 7ecae35..673e324 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3085,11 +3085,18 @@ PP(pp_require)
 
     sv = POPs;
     if ( (SvNIOKp(sv) || SvVOK(sv)) && PL_op->op_type != OP_DOFILE) {
-       if ( SvVOK(sv) && ckWARN(WARN_PORTABLE) )       /* require v5.6.1 */
+       if (!PL_v_string_ok && 
+           SvVOK(sv) && ckWARN(WARN_PORTABLE) )        /* require v5.6.1 */
                Perl_warner(aTHX_ packWARN(WARN_PORTABLE),
                         "v-string in use/require non-portable");
 
        sv = new_version(sv);
+       if (PL_compcv &&
+           vcmp(sv, sv_2mortal(upg_version(newSVnv(5.006), FALSE))) >= 0)
+               /* version 5.006 recognises 5.x.y in C<use 5.x.y> so
+                   can portably C<use 5.10.0> following C<use 5.006> */
+                   PL_v_string_ok = TRUE;
+
        if (!sv_derived_from(PL_patchlevel, "version"))
            upg_version(PL_patchlevel, TRUE);
        if (cUNOP->op_first->op_type == OP_CONST && cUNOP->op_first->op_private & OPpCONST_NOVER) {
diff --git a/sv.c b/sv.c
index f94e1ba..a07a57f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11534,6 +11534,8 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
          PTR2UV(PL_watchok));
     }
 
+    PL_v_string_ok     = proto_perl->Iv_string_ok;
+
     if (!(flags & CLONEf_KEEP_PTR_TABLE)) {
         ptr_table_free(PL_ptr_table);
         PL_ptr_table = NULL;
index d27e896..dac3552 100644 (file)
@@ -240,3 +240,8 @@ use warnings;
     eval 'print $foo';
 }
 EXPECT
+########
+# pp_ctl.c
+use warnings;
+eval 'use 5.006; use 5.10.0';
+EXPECT