This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge ftsize ftmtime ftatime ftctime into Perl_pp_ftis
authorNicholas Clark <nick@ccl4.org>
Wed, 2 Nov 2005 15:59:30 +0000 (15:59 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 2 Nov 2005 15:59:30 +0000 (15:59 +0000)
p4raw-id: //depot/perl@25958

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

index 894fd93..18886db 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -851,6 +851,26 @@ PP(pp_ggrgid)
     return pp_ggrent();
 }
 
+PP(pp_ftsize)
+{
+    return Perl_pp_ftis();
+}
+
+PP(pp_ftmtime)
+{
+    return Perl_pp_ftis();
+}
+
+PP(pp_ftatime)
+{
+    return Perl_pp_ftis();
+}
+
+PP(pp_ftctime)
+{
+    return Perl_pp_ftis();
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index 3964c8d..68c1cbd 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1012,10 +1012,10 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        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_ftsize),
-       MEMBER_TO_FPTR(Perl_pp_ftmtime),
-       MEMBER_TO_FPTR(Perl_pp_ftatime),
-       MEMBER_TO_FPTR(Perl_pp_ftctime),
+       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),
index 4a2aa5a..e4cda78 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -65,6 +65,8 @@ my @raw_alias = (
                 Perl_pp_gservent => [qw(gsbyname gsbyport)],
                 Perl_pp_gpwent => [qw(gpwnam gpwuid)],
                 Perl_pp_ggrent => [qw(ggrnam ggrgid)],
+
+                Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)],
 );
 
 while (my ($func, $names) = splice @raw_alias, 0, 2) {
index 0bf34cb..3f0a25b 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3052,7 +3052,30 @@ PP(pp_ftis)
     SPAGAIN;
     if (result < 0)
        RETPUSHUNDEF;
-    RETPUSHYES;
+    {
+       dTARGET;
+       switch (PL_op->op_type) {
+       case OP_FTIS:
+           RETPUSHYES;
+       case OP_FTSIZE:
+#if Off_t_size > IVSIZE
+           PUSHn(PL_statcache.st_size);
+#else
+           PUSHi(PL_statcache.st_size);
+#endif
+           break;
+       case OP_FTMTIME:
+           PUSHn( (((NV)PL_basetime - PL_statcache.st_mtime)) / 86400.0 );
+           break;
+       case OP_FTATIME:
+           PUSHn( (((NV)PL_basetime - PL_statcache.st_atime)) / 86400.0 );
+           break;
+       case OP_FTCTIME:
+           PUSHn( (((NV)PL_basetime - PL_statcache.st_ctime)) / 86400.0 );
+           break;
+       }
+    }
+    RETURN;
 }
 
 PP(pp_ftrowned)
@@ -3084,62 +3107,6 @@ PP(pp_ftzero)
     RETPUSHNO;
 }
 
-PP(pp_ftsize)
-{
-    I32 result;
-    dSP; dTARGET;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-#if Off_t_size > IVSIZE
-    PUSHn(PL_statcache.st_size);
-#else
-    PUSHi(PL_statcache.st_size);
-#endif
-    RETURN;
-}
-
-PP(pp_ftmtime)
-{
-    I32 result;
-    dSP; dTARGET;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    PUSHn( (((NV)PL_basetime - PL_statcache.st_mtime)) / 86400.0 );
-    RETURN;
-}
-
-PP(pp_ftatime)
-{
-    I32 result;
-    dSP; dTARGET;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    PUSHn( (((NV)PL_basetime - PL_statcache.st_atime)) / 86400.0 );
-    RETURN;
-}
-
-PP(pp_ftctime)
-{
-    I32 result;
-    dSP; dTARGET;
-    STACKED_FTEST_CHECK;
-    result = my_stat();
-    SPAGAIN;
-    if (result < 0)
-       RETPUSHUNDEF;
-    PUSHn( (((NV)PL_basetime - PL_statcache.st_ctime)) / 86400.0 );
-    RETURN;
-}
-
 PP(pp_ftsock)
 {
     I32 result;