]> git.saurik.com Git - apple/file_cmds.git/blobdiff - stat/stat.c
file_cmds-321.100.10.0.1.tar.gz
[apple/file_cmds.git] / stat / stat.c
index 5603a0596055d428b0c1e0327cd6822d3d53af12..610eff94d732e87e01652a40196fa77cd51c5d2f 100644 (file)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD: src/usr.bin/stat/stat.c,v 1.6 2003/10/06 01:55:17 dougb Exp
 #define HAVE_STRUCT_STAT_ST_GEN 1
 #define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
 #define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
+#define HAVE_STRUCT_STAT_ST_ATIM 0
 #define HAVE_DEVNAME 1
 #endif /* HAVE_CONFIG_H */
 
@@ -67,12 +68,6 @@ __FBSDID("$FreeBSD: src/usr.bin/stat/stat.c,v 1.6 2003/10/06 01:55:17 dougb Exp
 #include <time.h>
 #include <unistd.h>
 
-#ifdef __APPLE__
-#define stat stat64
-#define fstat fstat64
-#define lstat lstat64
-#endif /* __APPLE__ */
-
 #if HAVE_STRUCT_STAT_ST_FLAGS
 #define DEF_F "%#Xf "
 #define RAW_F "%f "
@@ -554,13 +549,13 @@ format1(const struct stat *st,
        struct passwd *pw;
        struct group *gr;
        const struct timespec *tsp;
-       struct timespec ts;
+       struct timespec ts = {0,0};
        struct tm *tm;
        int l, small, formats;
 
        tsp = NULL;
-       formats = 0;
-       small = 0;
+//     formats = 0;
+//     small = 0;
 
        /*
         * First, pick out the data and tweak it based on hilo or
@@ -695,8 +690,11 @@ format1(const struct stat *st,
                ts = *tsp;              /* copy so we can muck with it */
                small = (sizeof(ts.tv_sec) == 4);
                data = ts.tv_sec;
-               small = 1;
                tm = localtime(&ts.tv_sec);
+               if (tm == NULL) {
+                       ts.tv_sec = 0;
+                       tm = localtime(&ts.tv_sec);
+               }
                (void)strftime(path, sizeof(path), timefmt, tm);
                sdata = path;
                formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
@@ -733,7 +731,14 @@ format1(const struct stat *st,
                small = (sizeof(st->st_flags) == 4);
                data = st->st_flags;
                sdata = NULL;
-               formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
+               formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
+                       FMTF_STRING;
+               if (ofmt == FMTF_STRING) {
+                       small = 0;
+                       data = 0;
+                       snprintf(path, sizeof(path), "%s", fflagstostr(st->st_flags));
+                       sdata = path;
+               }
                if (ofmt == 0)
                        ofmt = FMTF_UNSIGNED;
                break;