aboutsummaryrefslogtreecommitdiff
path: root/bin/ls/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r--bin/ls/print.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index bbe5c6f8a6f6..979ad0ffc43e 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/acl.h>
@@ -234,9 +226,11 @@ printlong(const DISPLAY *dp)
strmode(sp->st_mode, buf);
aclmode(buf, p);
np = p->fts_pointer;
- (void)printf("%s %*ju %-*s %-*s ", buf, dp->s_nlink,
- (uintmax_t)sp->st_nlink, dp->s_user, np->user, dp->s_group,
- np->group);
+ (void)printf("%s %*ju ", buf, dp->s_nlink,
+ (uintmax_t)sp->st_nlink);
+ if (!f_sowner)
+ (void)printf("%-*s ", dp->s_user, np->user);
+ (void)printf("%-*s ", dp->s_group, np->group);
if (f_flags)
(void)printf("%-*s ", dp->s_flags, np->flags);
if (f_label)
@@ -432,18 +426,17 @@ printdev(size_t width, dev_t dev)
(void)printf("%#*jx ", (u_int)width, (uintmax_t)dev);
}
-static size_t
+static void
ls_strftime(char *str, size_t len, const char *fmt, const struct tm *tm)
{
char *posb, nfmt[BUFSIZ];
const char *format = fmt;
- size_t ret;
if ((posb = strstr(fmt, "%b")) != NULL) {
if (month_max_size == 0) {
compute_abbreviated_month_size();
}
- if (month_max_size > 0) {
+ if (month_max_size > 0 && tm != NULL) {
snprintf(nfmt, sizeof(nfmt), "%.*s%s%*s%s",
(int)(posb - fmt), fmt,
get_abmon(tm->tm_mon),
@@ -453,8 +446,10 @@ ls_strftime(char *str, size_t len, const char *fmt, const struct tm *tm)
format = nfmt;
}
}
- ret = strftime(str, len, format, tm);
- return (ret);
+ if (tm != NULL)
+ strftime(str, len, format, tm);
+ else
+ strlcpy(str, "bad date val", len);
}
static void