Deleted Added
full compact
print.c (196773) print.c (202945)
1/*-
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Michael Fischbein.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#if 0
34#ifndef lint
35static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
36#endif /* not lint */
37#endif
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Michael Fischbein.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#if 0
34#ifndef lint
35static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
36#endif /* not lint */
37#endif
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/ls/print.c 196773 2009-09-02 20:50:39Z trasz $");
39__FBSDID("$FreeBSD: head/bin/ls/print.c 202945 2010-01-24 19:23:07Z jh $");
40
41#include <sys/param.h>
42#include <sys/stat.h>
43#include <sys/acl.h>
44
45#include <err.h>
46#include <errno.h>
47#include <fts.h>

--- 9 unchanged lines hidden (view full) ---

57#include <termcap.h>
58#include <signal.h>
59#endif
60
61#include "ls.h"
62#include "extern.h"
63
64static int printaname(const FTSENT *, u_long, u_long);
40
41#include <sys/param.h>
42#include <sys/stat.h>
43#include <sys/acl.h>
44
45#include <err.h>
46#include <errno.h>
47#include <fts.h>

--- 9 unchanged lines hidden (view full) ---

57#include <termcap.h>
58#include <signal.h>
59#endif
60
61#include "ls.h"
62#include "extern.h"
63
64static int printaname(const FTSENT *, u_long, u_long);
65static void printdev(size_t, dev_t);
65static void printlink(const FTSENT *);
66static void printtime(time_t);
67static int printtype(u_int);
68static void printsize(size_t, off_t);
69#ifdef COLORLS
70static void endcolor(int);
71static int colortype(mode_t);
72#endif

--- 87 unchanged lines hidden (view full) ---

160 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
161 sp->st_nlink, dp->s_user, np->user, dp->s_group,
162 np->group);
163 if (f_flags)
164 (void)printf("%-*s ", dp->s_flags, np->flags);
165 if (f_label)
166 (void)printf("%-*s ", dp->s_label, np->label);
167 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
66static void printlink(const FTSENT *);
67static void printtime(time_t);
68static int printtype(u_int);
69static void printsize(size_t, off_t);
70#ifdef COLORLS
71static void endcolor(int);
72static int colortype(mode_t);
73#endif

--- 87 unchanged lines hidden (view full) ---

161 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
162 sp->st_nlink, dp->s_user, np->user, dp->s_group,
163 np->group);
164 if (f_flags)
165 (void)printf("%-*s ", dp->s_flags, np->flags);
166 if (f_label)
167 (void)printf("%-*s ", dp->s_label, np->label);
168 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
168 if (minor(sp->st_rdev) > 255 || minor(sp->st_rdev) < 0)
169 (void)printf("%3d, 0x%08x ",
170 major(sp->st_rdev),
171 (u_int)minor(sp->st_rdev));
172 else
173 (void)printf("%3d, %3d ",
174 major(sp->st_rdev), minor(sp->st_rdev));
175 else if (dp->bcfile)
176 (void)printf("%*s%*jd ",
177 8 - dp->s_size, "", dp->s_size, sp->st_size);
169 printdev(dp->s_size, sp->st_rdev);
178 else
179 printsize(dp->s_size, sp->st_size);
180 if (f_accesstime)
181 printtime(sp->st_atime);
182 else if (f_birthtime)
183 printtime(sp->st_birthtime);
184 else if (f_statustime)
185 printtime(sp->st_ctime);

--- 162 unchanged lines hidden (view full) ---

348 if (f_color && color_printed)
349 endcolor(0);
350#endif
351 if (f_type)
352 chcnt += printtype(sp->st_mode);
353 return (chcnt);
354}
355
170 else
171 printsize(dp->s_size, sp->st_size);
172 if (f_accesstime)
173 printtime(sp->st_atime);
174 else if (f_birthtime)
175 printtime(sp->st_birthtime);
176 else if (f_statustime)
177 printtime(sp->st_ctime);

--- 162 unchanged lines hidden (view full) ---

340 if (f_color && color_printed)
341 endcolor(0);
342#endif
343 if (f_type)
344 chcnt += printtype(sp->st_mode);
345 return (chcnt);
346}
347
348/*
349 * Print device special file major and minor numbers.
350 */
356static void
351static void
352printdev(size_t width, dev_t dev)
353{
354 char buf[DEVSTR_HEX_LEN + 1];
355
356 if (minor(dev) > 255 || minor(dev) < 0)
357 (void)snprintf(buf, sizeof(buf), "%3d, 0x%08x",
358 major(dev), (u_int)minor(dev));
359 else
360 (void)snprintf(buf, sizeof(buf), "%3d, %3d",
361 major(dev), minor(dev));
362
363 (void)printf("%*s ", (u_int)width, buf);
364}
365
366static void
357printtime(time_t ftime)
358{
359 char longstring[80];
360 static time_t now = 0;
361 const char *format;
362 static int d_first = -1;
363
364 if (d_first < 0)

--- 222 unchanged lines hidden (view full) ---

587 (void)printname(path);
588}
589
590static void
591printsize(size_t width, off_t bytes)
592{
593
594 if (f_humanval) {
367printtime(time_t ftime)
368{
369 char longstring[80];
370 static time_t now = 0;
371 const char *format;
372 static int d_first = -1;
373
374 if (d_first < 0)

--- 222 unchanged lines hidden (view full) ---

597 (void)printname(path);
598}
599
600static void
601printsize(size_t width, off_t bytes)
602{
603
604 if (f_humanval) {
595 char buf[5];
605 /*
606 * Reserve one space before the size and allocate room for
607 * the trailing '\0'.
608 */
609 char buf[HUMANVALSTR_LEN - 1 + 1];
596
597 humanize_number(buf, sizeof(buf), (int64_t)bytes, "",
598 HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
610
611 humanize_number(buf, sizeof(buf), (int64_t)bytes, "",
612 HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
599 (void)printf("%5s ", buf);
613 (void)printf("%*s ", (u_int)width, buf);
600 } else
601 (void)printf("%*jd ", (u_int)width, bytes);
602}
603
604/*
605 * Add a + after the standard rwxrwxrwx mode if the file has an
606 * ACL. strmode() reserves space at the end of the string.
607 */

--- 66 unchanged lines hidden ---
614 } else
615 (void)printf("%*jd ", (u_int)width, bytes);
616}
617
618/*
619 * Add a + after the standard rwxrwxrwx mode if the file has an
620 * ACL. strmode() reserves space at the end of the string.
621 */

--- 66 unchanged lines hidden ---