From 43a2b57f3d2e186fa9c96baf53cc8fdf1f4f4e5f Mon Sep 17 00:00:00 2001 From: James Youngman Date: Sat, 14 Jun 2003 15:20:03 +0000 Subject: [PATCH] Update code to reflect gnulib's changes to the arguments of human_readable(). Drop support for "FIND_BLOCK_SIZE" environment variable --- README-CVS | 3 +++ find/defs.h | 5 +++++ find/find.c | 8 ++++++++ find/pred.c | 21 +++++++++++++-------- lib/listfile.c | 13 +++++++++---- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/README-CVS b/README-CVS index 342be65b..781cb737 100644 --- a/README-CVS +++ b/README-CVS @@ -28,6 +28,9 @@ checked out of CVS, rather than from a releasaed source distribution. sh import-gnulib.sh +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. diff --git a/find/defs.h b/find/defs.h index 3afd59ed..faedba39 100644 --- a/find/defs.h +++ b/find/defs.h @@ -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 +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)(); diff --git a/find/find.c b/find/find.c index f6be4abf..d909874b 100644 --- a/find/find.c +++ b/find/find.c @@ -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)); diff --git a/find/pred.c b/find/pred.c index d3748ec1..641f45f3 100644 --- a/find/pred.c +++ b/find/pred.c @@ -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; diff --git a/lib/listfile.c b/lib/listfile.c index cdbb7474..322a1cb5 100644 --- a/lib/listfile.c +++ b/lib/listfile.c @@ -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);