In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/cae71c5daa29ee5b24cc6ad145eadb323c1e1612?hp=cb93cfd8a42cd5393400053115e38b60d71174cc>

- Log -----------------------------------------------------------------
commit cae71c5daa29ee5b24cc6ad145eadb323c1e1612
Author: Tony Cook <[email protected]>
Date:   Thu Oct 2 13:40:22 2014 +1000

    deprecate POSIX::tmpnam
    
    This patch avoids repeating the deprecation warning if the same tmpnam()
    call is executed multiple times.
-----------------------------------------------------------------------

Summary of changes:
 ext/POSIX/POSIX.xs     |  7 +++++++
 ext/POSIX/lib/POSIX.pm |  2 +-
 ext/POSIX/t/posix.t    | 17 ++++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 1757549..5f546f5 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -2912,6 +2912,13 @@ tmpnam()
         *
         * Then again, maybe this should be removed at some point.
         * No point in enabling dangerous interfaces. */
+        if (ckWARN_d(WARN_DEPRECATED)) {
+           HV *warned = get_hv("POSIX::_warned", GV_ADD | GV_ADDMULTI);
+            if (! hv_exists(warned, (const char *)&PL_op, sizeof(PL_op))) {
+                Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), "Calling 
POSIX::tmpnam() is deprecated");
+                hv_store(warned, (const char *)&PL_op, sizeof(PL_op), 
&PL_sv_yes, 0);
+            }
+        }
        len = strlen(tmpnam(SvPV(RETVAL, i)));
        SvCUR_set(RETVAL, len);
     OUTPUT:
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm
index be1f097..4770a54 100644
--- a/ext/POSIX/lib/POSIX.pm
+++ b/ext/POSIX/lib/POSIX.pm
@@ -4,7 +4,7 @@ use warnings;
 
 our ($AUTOLOAD, %SIGRT);
 
-our $VERSION = '1.44';
+our $VERSION = '1.45';
 
 require XSLoader;
 
diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t
index 398928c..18ea0be 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -8,7 +8,7 @@ BEGIN {
     }
 }
 
-use Test::More tests => 117;
+use Test::More tests => 120;
 
 use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
             errno localeconv dup dup2 lseek access);
@@ -433,6 +433,21 @@ SKIP: {
     cmp_ok($!, '==', POSIX::ENOTDIR);
 }
 
+{   # tmpnam() is deprecated
+    my @warn;
+    local $SIG{__WARN__} = sub { push @warn, "@_"; note "@_"; };
+    my $x = sub { POSIX::tmpnam() };
+    my $foo = $x->();
+    $foo = $x->();
+    is(@warn, 1, "POSIX::tmpnam() should warn only once per location");
+    like($warn[0], qr!^Calling POSIX::tmpnam\(\) is deprecated at t/posix.t 
line \d+\.$!,
+       "check POSIX::tmpnam warns by default");
+    no warnings "deprecated";
+    undef $warn;
+    my $foo = POSIX::tmpnam();
+    is($warn, undef, "... but the warning can be disabled");
+}
+
 # Check that output is not flushed by _exit. This test should be last
 # in the file, and is not counted in the total number of tests.
 if ($^O eq 'vos') {

--
Perl5 Master Repository

Reply via email to