Update code to reflect gnulib's changes to the arguments of human_readable(). Drop support for "FIND_BLOCK_SIZE" environment variable

This commit is contained in:
James Youngman 2003-06-14 15:20:03 +00:00
parent cd0a24a4b6
commit 43a2b57f3d
5 changed files with 38 additions and 12 deletions

View File

@ -28,6 +28,9 @@ checked out of CVS, rather than from a releasaed source distribution.
sh import-gnulib.sh <name of the directory containing gnulib>
The above command may result in some errors from autoconf and
automake. These are benign unless they occur again in the following
step - so don;t worry about them unless you see them both times.
4. Generate the configure scripts and Makefile.in files.

View File

@ -127,10 +127,15 @@ int stat PARAMS((const char *__path, struct stat *__statbuf));
#define MODE_RWX (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
#define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
#if 1
#include <stdbool.h>
typedef bool boolean;
#else
/* Not char because of type promotion; NeXT gcc can't handle it. */
typedef int boolean;
#define true 1
#define false 0
#endif
/* Pointer to function returning boolean. */
typedef boolean (*PFB)();

View File

@ -184,7 +184,15 @@ main (int argc, char **argv)
xstat = lstat;
#endif /* !DEBUG_STAT */
#if 0
human_block_size (getenv ("FIND_BLOCK_SIZE"), 0, &output_block_size);
#else
if (getenv("FIND_BLOCK_SIZE"))
{
error (1, errno, _("The environment variable FIND_BLOCK_SIZE is not supported"));
}
#endif
#ifdef DEBUG
printf ("cur_day_start = %s", ctime (&cur_day_start));

View File

@ -560,7 +560,8 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
case 'b': /* size in 512-byte blocks */
fprintf (fp, segment->text,
human_readable ((uintmax_t) ST_NBLOCKS (*stat_buf),
hbuf, ST_NBLOCKSIZE, 512));
hbuf, human_ceiling,
ST_NBLOCKSIZE, 512));
break;
case 'c': /* ctime in `ctime' format */
fprintf (fp, segment->text, ctime_format (stat_buf->st_ctime));
@ -590,7 +591,8 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
}
case 'G': /* GID number */
fprintf (fp, segment->text,
human_readable ((uintmax_t) stat_buf->st_gid, hbuf, 1, 1));
human_readable ((uintmax_t) stat_buf->st_gid, hbuf,
human_ceiling, 1, 1));
break;
case 'h': /* leading directories part of path */
{
@ -616,12 +618,13 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
}
case 'i': /* inode number */
fprintf (fp, segment->text,
human_readable ((uintmax_t) stat_buf->st_ino, hbuf, 1, 1));
human_readable ((uintmax_t) stat_buf->st_ino, hbuf,
human_ceiling, 1, 1));
break;
case 'k': /* size in 1K blocks */
fprintf (fp, segment->text,
human_readable ((uintmax_t) ST_NBLOCKS (*stat_buf),
hbuf, ST_NBLOCKSIZE, 1024));
hbuf, human_ceiling, ST_NBLOCKSIZE, 1024));
break;
case 'l': /* object of symlink */
#ifdef S_ISLNK
@ -676,7 +679,7 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
case 'n': /* number of links */
fprintf (fp, segment->text,
human_readable ((uintmax_t) stat_buf->st_nlink,
hbuf, 1, 1));
hbuf, human_ceiling, 1, 1));
break;
case 'p': /* pathname */
fprintf (fp, segment->text, pathname);
@ -699,7 +702,7 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
case 's': /* size in bytes */
fprintf (fp, segment->text,
human_readable ((uintmax_t) stat_buf->st_size,
hbuf, 1, 1));
hbuf, human_ceiling, 1, 1));
break;
case 't': /* mtime in `ctime' format */
fprintf (fp, segment->text, ctime_format (stat_buf->st_mtime));
@ -719,7 +722,8 @@ pred_fprintf (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
}
case 'U': /* UID number */
fprintf (fp, segment->text,
human_readable ((uintmax_t) stat_buf->st_uid, hbuf, 1, 1));
human_readable ((uintmax_t) stat_buf->st_uid, hbuf,
human_ceiling, 1, 1));
break;
}
}
@ -1319,7 +1323,8 @@ format_date (time_t when, int kind)
else
{
uintmax_t w = when;
char *p = human_readable (when < 0 ? -w : w, buf + 1, 1, 1);
char *p = human_readable (when < 0 ? -w : w, buf + 1,
human_ceiling, 1, 1);
if (when < 0)
*--p = '-';
return p;

View File

@ -216,10 +216,12 @@ list_file (name, relname, statp, current_time, output_block_size, stream)
modebuf[10] = '\0';
fprintf (stream, "%6s ",
human_readable ((uintmax_t) statp->st_ino, hbuf, 1, 1));
human_readable ((uintmax_t) statp->st_ino, hbuf, human_ceiling,
1, 1));
fprintf (stream, "%4s ",
human_readable ((uintmax_t) ST_NBLOCKS (*statp), hbuf,
human_ceiling,
ST_NBLOCKSIZE, output_block_size));
/* The space between the mode and the number of links is the POSIX
@ -248,7 +250,8 @@ list_file (name, relname, statp, current_time, output_block_size, stream)
#endif
else
fprintf (stream, "%8s ",
human_readable ((uintmax_t) statp->st_size, hbuf, 1,
human_readable ((uintmax_t) statp->st_size, hbuf, human_ceiling,
1,
output_block_size < 0 ? output_block_size : 1));
if ((when_local = localtime (&statp->st_mtime)))
@ -285,14 +288,16 @@ list_file (name, relname, statp, current_time, output_block_size, stream)
if (statp->st_mtime < 0)
{
char const *num = human_readable (- (uintmax_t) statp->st_mtime,
hbuf, 1, 1);
hbuf, human_ceiling, 1, 1);
int sign_width = width - strlen (num);
fprintf (stream, "%*s%s ",
sign_width < 0 ? 0 : sign_width, "-", num);
}
else
fprintf (stream, "%*s ", width,
human_readable ((uintmax_t) statp->st_mtime, hbuf, 1, 1));
human_readable ((uintmax_t) statp->st_mtime, hbuf,
human_ceiling,
1, 1));
}
print_name_with_quoting (name, stream);