This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move ftsuid ftsgid ftsvtx into Perl_pp_ftrowned.
authorNicholas Clark <nick@ccl4.org>
Wed, 2 Nov 2005 20:13:24 +0000 (20:13 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 2 Nov 2005 20:13:24 +0000 (20:13 +0000)
p4raw-id: //depot/perl@25962

mathoms.c
opcode.h
opcode.pl
pp_sys.c

index bb7230a..e814a80 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -906,6 +906,21 @@ PP(pp_ftpipe)
     return pp_ftrowned();
 }
 
+PP(pp_ftsuid)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftsgid)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftsvtx)
+{
+    return pp_ftrowned();
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index 46628c9..090621c 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1023,9 +1023,9 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftdir */
        MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftpipe */
        MEMBER_TO_FPTR(Perl_pp_ftlink),
-       MEMBER_TO_FPTR(Perl_pp_ftsuid),
-       MEMBER_TO_FPTR(Perl_pp_ftsgid),
-       MEMBER_TO_FPTR(Perl_pp_ftsvtx),
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftsuid */
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftsgid */
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftsvtx */
        MEMBER_TO_FPTR(Perl_pp_fttty),
        MEMBER_TO_FPTR(Perl_pp_fttext),
        MEMBER_TO_FPTR(Perl_pp_fttext), /* Perl_pp_ftbinary */
index 23f6c35..7ac9922 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -54,7 +54,8 @@ my @raw_alias = (
                 Perl_pp_getpeername => ['getsockname'],
                 Perl_pp_stat => ['lstat'],
                 Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk
-                                        ftfile ftdir ftpipe)],
+                                        ftfile ftdir ftpipe ftsuid ftsgid
+                                        ftsvtx)],
                 Perl_pp_fttext => ['ftbinary'],
                 Perl_pp_gmtime => ['localtime'],
                 Perl_pp_semget => [qw(shmget msgget)],
index d005366..d932c2f 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3085,6 +3085,22 @@ PP(pp_ftrowned)
 {
     I32 result;
     dSP;
+
+    /* 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)
+       RETPUSHNO;
+#endif
+#ifndef S_ISGID
+    if(PL_op->op_type == OP_FTSGID)
+       RETPUSHNO;
+#endif
+#ifndef S_ISVTX
+    if(PL_op->op_type == OP_FTSVTX)
+       RETPUSHNO;
+#endif
+
     STACKED_FTEST_CHECK;
     result = my_stat();
     SPAGAIN;
@@ -3127,66 +3143,36 @@ PP(pp_ftrowned)
        if (S_ISFIFO(PL_statcache.st_mode))
            RETPUSHYES;
        break;
-    }
-    RETPUSHNO;
-}
-
-PP(pp_ftlink)
-{
-    I32 result = my_lstat();
-    dSP;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISLNK(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftsuid)
-{
-    dSP;
 #ifdef S_ISUID
-    I32 result;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (PL_statcache.st_mode & S_ISUID)
-       RETPUSHYES;
+    case OP_FTSUID:
+       if (PL_statcache.st_mode & S_ISUID)
+           RETPUSHYES;
+       break;
 #endif
-    RETPUSHNO;
-}
-
-PP(pp_ftsgid)
-{
-    dSP;
 #ifdef S_ISGID
-    I32 result;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (PL_statcache.st_mode & S_ISGID)
-       RETPUSHYES;
+    case OP_FTSGID:
+       if (PL_statcache.st_mode & S_ISGID)
+           RETPUSHYES;
+       break;
+#endif
+#ifdef S_ISVTX
+    case OP_FTSVTX:
+       if (PL_statcache.st_mode & S_ISVTX)
+           RETPUSHYES;
+       break;
 #endif
+    }
     RETPUSHNO;
 }
 
-PP(pp_ftsvtx)
+PP(pp_ftlink)
 {
+    I32 result = my_lstat();
     dSP;
-#ifdef S_ISVTX
-    I32 result;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
     if (result < 0)
        RETPUSHUNDEF;
-    if (PL_statcache.st_mode & S_ISVTX)
+    if (S_ISLNK(PL_statcache.st_mode))
        RETPUSHYES;
-#endif
     RETPUSHNO;
 }