-/* $OpenBSD: gen_subs.c,v 1.24 2014/01/08 05:52:47 guenther Exp $ */
+/* $OpenBSD: gen_subs.c,v 1.25 2014/01/09 03:12:25 guenther Exp $ */
/* $NetBSD: gen_subs.c,v 1.5 1995/03/21 09:07:26 cgd Exp $ */
/*-
#define CURFRMT "%b %e %H:%M"
#define OLDFRMT "%b %e %Y"
#define NAME_WIDTH 8
+#define TIMEFMT(t, now) \
+ (((t) + SIXMONTHS <= (now) || (t) > (now)) ? OLDFRMT : CURFRMT)
/*
* ls_list()
struct stat *sbp;
char f_mode[MODELEN];
char f_date[DATELEN];
- const char *timefrmt;
int term;
term = zeroflag ? '\0' : '\n'; /* path termination character */
sbp = &(arcn->sb);
strmode(sbp->st_mode, f_mode);
- if (ltmfrmt == NULL) {
- /*
- * no locale specified format. time format based on age
- * compared to the time pax was started.
- */
- if ((sbp->st_mtime + SIXMONTHS) <= now)
- timefrmt = OLDFRMT;
- else
- timefrmt = CURFRMT;
- } else
- timefrmt = ltmfrmt;
-
/*
* print file mode, link count, uid, gid and time
*/
- if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
+ if (strftime(f_date, sizeof(f_date), TIMEFMT(sbp->st_mtime, now),
+ localtime(&(sbp->st_mtime))) == 0)
f_date[0] = '\0';
(void)fprintf(fp, "%s%2u %-*.*s %-*.*s ", f_mode, sbp->st_nlink,
NAME_WIDTH, UT_NAMESIZE, name_uid(sbp->st_uid, 1),
* print device id's for devices, or sizes for other nodes
*/
if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
- (void)fprintf(fp, "%4lu,%4lu ",
+ (void)fprintf(fp, "%4lu, %4lu ",
(unsigned long)MAJOR(sbp->st_rdev),
(unsigned long)MINOR(sbp->st_rdev));
else {
{
char f_date[DATELEN];
char f_mode[MODELEN];
- const char *timefrmt;
-
- if (ltmfrmt == NULL) {
- /*
- * no locale specified format
- */
- if ((arcn->sb.st_mtime + SIXMONTHS) <= time(NULL))
- timefrmt = OLDFRMT;
- else
- timefrmt = CURFRMT;
- } else
- timefrmt = ltmfrmt;
+ time_t now = time(NULL);
/*
* convert time to string, and print
*/
- if (strftime(f_date, DATELEN, timefrmt,
+ if (strftime(f_date, DATELEN, TIMEFMT(arcn->sb.st_mtime, now),
localtime(&(arcn->sb.st_mtime))) == 0)
f_date[0] = '\0';
strmode(arcn->sb.st_mode, f_mode);
-/* $OpenBSD: pax.c,v 1.34 2012/12/04 02:24:45 deraadt Exp $ */
+/* $OpenBSD: pax.c,v 1.35 2014/01/09 03:12:25 guenther Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
int exit_val; /* exit value */
int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
-char *ltmfrmt; /* -v locale time format (if any) */
char *argv0; /* root of argv[0] */
sigset_t s_mask; /* signal mask for cleanup critical sect */
FILE *listf = stderr; /* file pointer to print file list to */
(void)setrlimit(RLIMIT_RSS , &reslimit);
}
- /*
- * Handle posix locale
- *
- * set user defines time printing format for -v option
- */
- ltmfrmt = getenv("LC_TIME");
-
/*
* signal handling to reset stored directory times and modes. Since
* we deal with broken pipes via failed writes we ignore it. We also