summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>1999-08-19 11:36:12 +0000
committersheldonh <sheldonh@FreeBSD.org>1999-08-19 11:36:12 +0000
commitc57b7dbc2aa6eb36ef1d3e3d0e7233b65452581a (patch)
tree0c0c190b9830b59c4456d2927b40b00a00f2f84e /bin
parent5b15ba9a9bb280c433490f21e32e80162449860f (diff)
downloadFreeBSD-src-c57b7dbc2aa6eb36ef1d3e3d0e7233b65452581a.zip
FreeBSD-src-c57b7dbc2aa6eb36ef1d3e3d0e7233b65452581a.tar.gz
Style issues in previous commit:
Use an upward approximation of the number of characters required for decimal representations of uid_t, gid_t and u_quad_t, intead of arbitrary values that may not be safe in the future. Fix disordering. Requested by: bde
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/ls.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 8aaba1f..5f2ca95 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
#else
static const char rcsid[] =
- "$Id: ls.c,v 1.24 1999/05/08 10:20:30 kris Exp $";
+ "$Id: ls.c,v 1.25 1999/08/02 14:55:58 sheldonh Exp $";
#endif
#endif /* not lint */
@@ -57,15 +57,23 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <fts.h>
+#include <limits.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <locale.h>
#include "ls.h"
#include "extern.h"
+/*
+ * Upward approximation of the maximum number of characters needed to
+ * represent a value of integral type t as a string, excluding the
+ * NUL terminator, with provision for a sign.
+ */
+#define STRBUF_SIZEOF(t) (CHAR_BIT * sizeof(t) / 3 + 1)
+
static void display __P((FTSENT *, FTSENT *));
static u_quad_t makenines __P((u_long));
static int mastercmp __P((const FTSENT **, const FTSENT **));
@@ -88,6 +96,7 @@ int f_listdot; /* list files beginning with . */
int f_longform; /* long listing format */
int f_nonprint; /* show unprintables as ? */
int f_nosort; /* don't sort output */
+int f_notabs; /* don't use tab-separated multi-col output */
int f_numericonly; /* don't convert uid/gid to name */
int f_octal; /* show unprintables as \xxx */
int f_octal_escape; /* like f_octal but use C escapes if possible */
@@ -97,7 +106,6 @@ int f_sectime; /* print the real time for all files */
int f_singlecol; /* use single column output */
int f_size; /* list size in short listing */
int f_statustime; /* use time of last mode change */
-int f_notabs; /* don't use tab-separated multi-col output */
int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
int f_whiteout; /* show whiteout entries */
@@ -405,7 +413,9 @@ display(p, list)
char *initmax;
int entries, needstats;
char *user, *group, *flags;
- char nuser[12], ngroup[12], buf[21]; /* 32 bits == 10 digits */
+ char buf[STRBUF_SIZEOF(u_quad_t) + 1];
+ char ngroup[STRBUF_SIZEOF(uid_t) + 1];
+ char nuser[STRBUF_SIZEOF(gid_t) + 1];
/*
* If list is NULL there are two possibilities: that the parent
OpenPOWER on IntegriCloud