Merge ftzero ftsock ftchr ftblk ftfile ftdir ftpipe into
Nicholas Clark [Wed, 2 Nov 2005 19:04:10 +0000 (19:04 +0000)]
Perl_pp_ftrowned

p4raw-id: //depot/perl@25961

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

index 2ad9de5..bb7230a 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -871,6 +871,41 @@ PP(pp_ftctime)
     return pp_ftis();
 }
 
+PP(pp_ftzero)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftsock)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftchr)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftblk)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftfile)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftdir)
+{
+    return pp_ftrowned();
+}
+
+PP(pp_ftpipe)
+{
+    return pp_ftrowned();
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index 68c1cbd..46628c9 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1011,17 +1011,17 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        MEMBER_TO_FPTR(Perl_pp_ftis),
        MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_fteowned */
        MEMBER_TO_FPTR(Perl_pp_ftrowned),
-       MEMBER_TO_FPTR(Perl_pp_ftzero),
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftzero */
        MEMBER_TO_FPTR(Perl_pp_ftis),   /* Perl_pp_ftsize */
        MEMBER_TO_FPTR(Perl_pp_ftis),   /* Perl_pp_ftmtime */
        MEMBER_TO_FPTR(Perl_pp_ftis),   /* Perl_pp_ftatime */
        MEMBER_TO_FPTR(Perl_pp_ftis),   /* Perl_pp_ftctime */
-       MEMBER_TO_FPTR(Perl_pp_ftsock),
-       MEMBER_TO_FPTR(Perl_pp_ftchr),
-       MEMBER_TO_FPTR(Perl_pp_ftblk),
-       MEMBER_TO_FPTR(Perl_pp_ftfile),
-       MEMBER_TO_FPTR(Perl_pp_ftdir),
-       MEMBER_TO_FPTR(Perl_pp_ftpipe),
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftsock */
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftchr */
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftblk */
+       MEMBER_TO_FPTR(Perl_pp_ftrowned),       /* Perl_pp_ftfile */
+       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),
index e4cda78..23f6c35 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -53,7 +53,8 @@ my @raw_alias = (
                 Perl_pp_ssockopt => ['gsockopt'],
                 Perl_pp_getpeername => ['getsockname'],
                 Perl_pp_stat => ['lstat'],
-                Perl_pp_ftrowned => ['fteowned'],
+                Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk
+                                        ftfile ftdir ftpipe)],
                 Perl_pp_fttext => ['ftbinary'],
                 Perl_pp_gmtime => ['localtime'],
                 Perl_pp_semget => [qw(shmget msgget)],
index 98c7348..d005366 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3090,107 +3090,44 @@ PP(pp_ftrowned)
     SPAGAIN;
     if (result < 0)
        RETPUSHUNDEF;
-    if (PL_statcache.st_uid == (PL_op->op_type == OP_FTEOWNED ?
-                               PL_euid : PL_uid) )
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftzero)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (PL_statcache.st_size == 0)
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftsock)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISSOCK(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftchr)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISCHR(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftblk)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISBLK(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftfile)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISREG(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftdir)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISDIR(PL_statcache.st_mode))
-       RETPUSHYES;
-    RETPUSHNO;
-}
-
-PP(pp_ftpipe)
-{
-    I32 result;
-    dSP;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    if (S_ISFIFO(PL_statcache.st_mode))
-       RETPUSHYES;
+    switch (PL_op->op_type) {
+    case OP_FTROWNED:
+       if (PL_statcache.st_uid == PL_uid);
+           RETPUSHYES;
+       break;
+    case OP_FTEOWNED:
+       if (PL_statcache.st_uid == PL_euid)
+           RETPUSHYES;
+       break;
+    case OP_FTZERO:
+       if (PL_statcache.st_size == 0)
+           RETPUSHYES;
+       break;
+    case OP_FTSOCK:
+       if (S_ISSOCK(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    case OP_FTCHR:
+       if (S_ISCHR(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    case OP_FTBLK:
+       if (S_ISBLK(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    case OP_FTFILE:
+       if (S_ISREG(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    case OP_FTDIR:
+       if (S_ISDIR(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    case OP_FTPIPE:
+       if (S_ISFIFO(PL_statcache.st_mode))
+           RETPUSHYES;
+       break;
+    }
     RETPUSHNO;
 }