This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make sure the stack is balanced in the case that we fake the result of unsupported...
authorAndy Armstrong <andy@hexten.net>
Sun, 15 Aug 2010 11:05:23 +0000 (12:05 +0100)
committerGeorge Greer <perl@greerga.m-l.org>
Tue, 17 Aug 2010 22:36:31 +0000 (18:36 -0400)
This time with an appropriate comment on the test. And with that I'll
attempt to stop spamming P5P, at least for today, and go and do
something less risky. Running with scissors perhaps.

MANIFEST
pp_sys.c
t/op/filetest_stack_ok.t [new file with mode: 0644]

index faf8974..be87229 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4483,6 +4483,7 @@ t/op/exp.t                        See if math functions work
 t/op/fh.t                      See if filehandles work
 t/op/filehandle.t              Tests for http://rt.perl.org/rt3/Ticket/Display.html?id=72586
 t/op/filetest.t                        See if file tests work
+t/op/filetest_stack_ok.t        See if file tests leave their argument on the stack
 t/op/filetest_t.t              See if -t file test works
 t/op/flip.t                    See if range operator works
 t/op/fork.t                    See if fork works
index 80a70ce..ec82610 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3219,16 +3219,22 @@ PP(pp_ftrowned)
     /* I believe that all these three are likely to be defined on most every
        system these days.  */
 #ifndef S_ISUID
-    if(PL_op->op_type == OP_FTSUID)
+    if(PL_op->op_type == OP_FTSUID) {
+       (void) POPs;
        RETPUSHNO;
+    }
 #endif
 #ifndef S_ISGID
-    if(PL_op->op_type == OP_FTSGID)
+    if(PL_op->op_type == OP_FTSGID) {
+       (void) POPs;
        RETPUSHNO;
+    }
 #endif
 #ifndef S_ISVTX
-    if(PL_op->op_type == OP_FTSVTX)
+    if(PL_op->op_type == OP_FTSVTX) {
+       (void) POPs;
        RETPUSHNO;
+    }
 #endif
 
     STACKED_FTEST_CHECK;
diff --git a/t/op/filetest_stack_ok.t b/t/op/filetest_stack_ok.t
new file mode 100644 (file)
index 0000000..91e31e0
--- /dev/null
@@ -0,0 +1,19 @@
+#!./perl
+
+# On platforms that don't support all of the filetest operators the code
+# that faked the results of missing tests used to leave the test's
+# argument on the stack.
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+}
+
+my @ops = split //, 'rwxoRWXOezsfdlpSbctugkTMBAC';
+
+plan( tests => @ops * 1 );
+
+for my $op (@ops) {
+    ok( 1 == @{ [ eval "-$op 'TEST'" ] }, "-$op returns single value" );
+}