Compare commits

...

100 Commits

Author SHA1 Message Date
Jim Meyering
0654f3206d Check for strtol. Mainly as a cue to cause automake to include
strtol.c -- that file is included by each of strtoul.c and strtoull.c.
Check for limits.h -- strtol.c needs it.
2000-12-06 11:06:39 +00:00
Jim Meyering
67cf94a857 *** empty log message *** 2000-12-06 10:52:37 +00:00
Jim Meyering
69ed54e544 Check for declarations of strtoul and strtoull. 2000-12-06 10:52:28 +00:00
Jim Meyering
3dabe6b533 separate conditions for strtoul and strtoull 2000-12-06 10:26:51 +00:00
Jim Meyering
2845214164 *** empty log message *** 2000-12-06 09:55:03 +00:00
Jim Meyering
6b8102a180 *** empty log message *** 2000-12-06 09:35:48 +00:00
Jim Meyering
570074d6d1 (jm_AC_PREREQ_XSTRTOUMAX): If we need the replacement
strtoull, we may well need the replacement strtoul, too.
2000-12-06 09:35:40 +00:00
Jim Meyering
72a6d74ab2 . 2000-12-05 13:53:13 +00:00
Jim Meyering
cd6f0af0ea (dir_name_r): Add `const' in a few local declarations. 2000-12-05 13:14:13 +00:00
Jim Meyering
2746cd50c3 *** empty log message *** 2000-12-04 09:41:28 +00:00
Jim Meyering
8a4261c7a5 *** empty log message *** 2000-12-04 09:37:40 +00:00
Jim Meyering
90799b6c68 Also include memory.h, stdlib.h, unistd.h if appropriate. 2000-12-04 09:37:33 +00:00
Jim Meyering
1c6320fe7c *** empty log message *** 2000-12-04 09:15:54 +00:00
Jim Meyering
fecdd2bd2b [!HAVE_DECL_MALLOC]: Declare malloc. 2000-12-04 09:15:49 +00:00
Jim Meyering
15691fb64f *** empty log message *** 2000-12-03 22:40:40 +00:00
Jim Meyering
cb366955f3 (gobble_file) [USE_ACL]: Set have_acl member unconditionally
to avoid uninitialized memory reference via FILE_HAS_ACL.
2000-12-03 22:40:31 +00:00
Jim Meyering
82a6fbda1c *** empty log message *** 2000-12-03 20:46:07 +00:00
Jim Meyering
177b2553e2 (TESTS): Add assert-2. 2000-12-03 20:43:51 +00:00
Jim Meyering
814e63e371 remove instrumentation 2000-12-03 20:37:55 +00:00
Jim Meyering
2eed25f2ed add instrumentation to detect some UMRs 2000-12-03 20:37:18 +00:00
Jim Meyering
1be9e19c7d *** empty log message *** 2000-12-03 20:36:29 +00:00
Jim Meyering
b7895d0d10 (tail_file): Initialize ignore, dev, and ino members,
when tailing forever and the open failed.  Otherwise, we could get
uninitialized memory references of those fields in recheck.
2000-12-03 20:36:19 +00:00
Jim Meyering
8461820956 *** empty log message *** 2000-12-03 13:10:48 +00:00
Jim Meyering
86960ce221 *** empty log message *** 2000-12-03 12:46:55 +00:00
Jim Meyering
6670163eee (alpha): Use rsync rather than scp, so the destination
file is created only after the successful completion of the copy.
2000-12-03 12:46:44 +00:00
Jim Meyering
437f8becaa . 2000-12-03 12:31:59 +00:00
Jim Meyering
5233121102 use CHAR_BIT, not BITSPERBYTE 2000-12-03 11:00:06 +00:00
Jim Meyering
25c2989d30 *** empty log message *** 2000-12-03 10:59:49 +00:00
Jim Meyering
4f96dfa43e (CHAR_BIT): Define. 2000-12-03 10:59:44 +00:00
Jim Meyering
f559a4afa3 *** empty log message *** 2000-12-03 10:39:03 +00:00
Jim Meyering
b5d4b2c555 *** empty log message *** 2000-12-03 10:22:32 +00:00
Jim Meyering
d8a157a00e *** empty log message *** 2000-12-03 10:21:34 +00:00
Jim Meyering
85a75d3a16 *** empty log message *** 2000-12-03 10:18:09 +00:00
Jim Meyering
d183ecddcd Make od print valid addresses for offsets of 2^32 and larger. (cont'd)
(MAX_ADDRESS_LENGTH): Don't hard-code as a literal.
Rather, define in terms of the type, off_t.
(string_min): Declare to be of type size_t.
(flag_dump_strings): Declare to be of type int.
(print_s_char): Declare the n_bytes parameter and the local, `i',
to be of type off_t.
(print_char): Likewise.
(print_s_short): Likewise.
(print_short): Likewise.
(print_int): Likewise.
(print_long): Likewise.
(print_long_long): Likewise.
(print_float): Likewise.
(print_double): Likewise.
(print_long_double): Likewise.
(dump_hexl_mode_trailer): Likewise.
(print_named_ascii): Likewise.
(print_ascii): Likewise.
(write_block): Likewise.
(print_ascii): Declare local, `print_function' with a prototype.
Change a few `>' comparisons to the equivalent `<' form.
(parse_options): Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if the specified offset if larger than OFF_T_MAX.
(dump_strings): Declare local `i' to be of type size_t.
Remove the now-unnecessary cast-to-off_t.
(main) [IF_LINT]: Initialize desired_width to avoid a warning.
Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if minimum string length is larger than SIZE_MAX.
Fail if specified width is larger than ULONG_MAX.
2000-12-03 10:18:04 +00:00
Jim Meyering
e30c09b4cb Add this:
AC_REQUIRE([AC_TYPE_OFF_T])
2000-12-03 10:04:30 +00:00
Jim Meyering
9d5d7f0d50 (OFF_T_MIN): Remove definition.
(OFF_T_MAX): Likewise.
2000-12-03 08:55:51 +00:00
Jim Meyering
caae4ed5a7 (OFF_T_MIN): Define.
(OFF_T_MAX): Define.
2000-12-03 08:54:37 +00:00
Jim Meyering
a1ca60f4e5 Make od print valid addresses for offsets of 2^32 and larger.
(format_address): Use off_t, not long unsigned_int as the
parameter type.
(format_address_none): Likewise.  Mark parameter as unused.
(format_address_std): Likewise.
(format_address_label): Likewise.
(print_ascii): Mark format string parameter as unused.
(write_block): Use off_t, not long unsigned_int as offset type.
(expand_address_fmt): New function.
(main): Use it to expand each address format string template.
Reported by Mark Nudelman, via Andreas Jaeger.
2000-12-03 08:44:12 +00:00
Jim Meyering
ce861b2cb3 (parse_options): Use xstrtoumax to parse the byte and line
offset.  Give a better diagnostic when the requested offset is still
representable but larger than OFF_T_MAX.
2000-12-03 08:35:48 +00:00
Jim Meyering
67ec78d188 *** empty log message *** 2000-12-02 22:18:29 +00:00
Jim Meyering
d661be38ed (valid_format): Move pre-increment to a separate statement to avoid a warning. 2000-12-02 22:18:21 +00:00
Jim Meyering
69e30c7f2a Move dcls of globals used only in main...
(main): ...to here.
(usage): Clarify option descriptions.
2000-12-02 22:16:41 +00:00
Jim Meyering
8973e2b38c whoops. rename the use, too -- not just the decl!! 2000-12-02 21:14:41 +00:00
Jim Meyering
df52f23ebf *** empty log message *** 2000-12-02 21:14:09 +00:00
Jim Meyering
5edc91fc05 (checkfp): Rename local `buf' to avoid shadowing previous declaration. 2000-12-02 21:14:02 +00:00
Jim Meyering
8b4ac20908 (skip): Use lseek instead of worrying about fseeko or fseek.
This should be portable, as we seek before doing any I/O.
(fseeko): Remove; no longer used.
2000-12-02 21:08:01 +00:00
Jim Meyering
1a0d9ea086 add back the parens Paul removed :-) 2000-12-02 20:55:25 +00:00
Jim Meyering
e49511faef (gobble_file): Do not fall back on lstat if stat
fails; POSIX.2 does not allow this.  Invoke acl only on
non-symlinks, and only if lstat or stat succeeds.
2000-12-02 20:55:02 +00:00
Jim Meyering
e05c32a868 *** empty log message *** 2000-12-02 20:52:09 +00:00
Jim Meyering
c2f898236f *** empty log message *** 2000-12-02 20:45:40 +00:00
Jim Meyering
501ebc1cba Make idempotent, to avoid some obscure warnings. 2000-12-02 20:45:30 +00:00
Jim Meyering
77182607c0 . 2000-12-02 18:52:17 +00:00
Jim Meyering
6769657fa3 *** empty log message *** 2000-12-02 18:52:03 +00:00
Jim Meyering
dab453378b (OFF_T_PRINTF_FORMAT_STRING): require it. 2000-12-02 18:51:26 +00:00
Jim Meyering
aa266c29eb *** empty log message *** 2000-12-02 18:04:19 +00:00
Jim Meyering
6b94589fa4 *** empty log message *** 2000-12-02 18:02:05 +00:00
Jim Meyering
0d849addb3 *** empty log message *** 2000-12-02 17:44:04 +00:00
Jim Meyering
1698b85090 *** empty log message *** 2000-12-02 17:40:26 +00:00
Jim Meyering
a538ba0149 *** empty log message *** 2000-12-02 17:39:59 +00:00
Jim Meyering
41f20fd38f *** empty log message *** 2000-12-02 14:53:18 +00:00
Jim Meyering
1c8189de61 (TESTS): Add follow-slink. 2000-12-02 14:53:07 +00:00
Jim Meyering
525e76fce0 *** empty log message *** 2000-12-02 14:52:45 +00:00
Jim Meyering
d91624bd99 *** empty log message *** 2000-12-02 14:43:34 +00:00
Jim Meyering
1c71127370 (NONZERO): Define and use it to make the code a tiny
bit more readable.
2000-12-02 14:43:28 +00:00
Jim Meyering
4f1553c89f *** empty log message *** 2000-12-02 14:28:23 +00:00
Jim Meyering
1b9cb7ea23 (sort invocation): Clarify how -t works when
a sort key specifies a range of fields.  From Karl O. Pinc.
2000-12-02 14:28:11 +00:00
Jim Meyering
479aba180c *** empty log message *** 2000-12-02 14:10:37 +00:00
Jim Meyering
8eeae63a74 . 2000-12-02 14:04:05 +00:00
Jim Meyering
07584e33ec add test that would fail on NetBSD before the last change 2000-12-02 14:02:34 +00:00
Jim Meyering
33ba435db5 *** empty log message *** 2000-12-02 13:22:57 +00:00
Jim Meyering
73fe66c783 *** empty log message *** 2000-12-02 13:22:14 +00:00
Jim Meyering
cc27b86c60 (main): Remove any trailing slash unconditionally.
Reported by Volker Borchert.
2000-12-02 13:20:37 +00:00
Jim Meyering
9db47bb808 *** empty log message *** 2000-12-02 12:15:00 +00:00
Jim Meyering
8bf3961df0 *** empty log message *** 2000-12-02 12:05:15 +00:00
Jim Meyering
df7d583cc2 (TESTS): Add skip-seek2 2000-12-02 12:05:03 +00:00
Jim Meyering
271e41850b *** empty log message *** 2000-12-02 12:04:32 +00:00
Jim Meyering
97b58344c5 *** empty log message *** 2000-12-02 09:58:43 +00:00
Jim Meyering
627dac6c07 Include <config.h> before any system include file. 2000-12-02 09:58:31 +00:00
Jim Meyering
0742bc284e *** empty log message *** 2000-12-02 08:19:31 +00:00
Jim Meyering
acca4638b8 (skip, dd_copy): Use ssize_t to store result of
safe_read, to avoid overflow e.g. on 64-bit Solaris sparc.
(dd_copy): Remove unnecessary cast.
2000-12-02 08:19:21 +00:00
Jim Meyering
05aabec021 *** empty log message *** 2000-12-02 08:14:33 +00:00
Jim Meyering
e996c1bd77 Undo most of the changes since 2000-11-24, since we've
documented a standard way to do it.
(skip_bytes, seek_bytes): Remove.
(usage): Remove B suffix.
(scanargs, skip, dd_copy, main): Remove support for B suffix.
2000-12-02 08:12:56 +00:00
Jim Meyering
b529a77be8 *** empty log message *** 2000-11-30 20:36:08 +00:00
Jim Meyering
4faf0a9a17 *** empty log message *** 2000-11-30 20:35:02 +00:00
Jim Meyering
3e50cea2f5 (jm_MACROS): Add stdint.h to the list of headers. 2000-11-30 20:34:23 +00:00
Jim Meyering
339738f351 s/SIZE_T_MAX/SIZE_MAX/. 2000-11-30 20:30:04 +00:00
Jim Meyering
a48a4d5c63 Include <stdint.h> if HAVE_STDINT_H.
(SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX.
All uses changed.
2000-11-30 20:27:49 +00:00
Jim Meyering
57a0382b5f *** empty log message *** 2000-11-30 11:39:19 +00:00
Jim Meyering
835a8fa634 (SIZE_T_MAX): Define. 2000-11-30 11:39:08 +00:00
Jim Meyering
4ff7ab63ab *** empty log message *** 2000-11-30 11:33:57 +00:00
Jim Meyering
d92f4ac85e Port GNU "sort" to hosts where sizes don't fit in "int",
e.g. 64-bit Solaris (sparc).

("human.h", "xstrtol.h"): Include.
(struct line): length member is now size_t, not int.
(struct lines): Likewise for used, alloc, limit members.
(struct buffer): Likewise for used, alloc, left, newline_free members.
(struct keyfield): Likewise for sword, schar, eword, echar members.
(sortalloc, mergealloc, linelength): Now size_t, not int.

(initbuf, fillbuf, initlines, begfield, limfield, findlines,
numcompare, getmonth, keycompare, compare, checkfp, mergefps,
sortlines, sort): Accept, return, and use size_t for sizes, not int.

(fillbuf, initlines, findlines, checkfp, sort): Check for overflow
when computing buffer sizes.

(begfield, limfield): Do not index past end of array.

(checkfp): Return a boolean, not a line number, as the line
number may not fit in int.  All callers changed.  Use
uintmax_t for line numbers, not int.

(sort): Don't allocate tmp until we need it (and know the right size).

(parse_field_count): New function.

(main): Use it to check for overflow in field counts.
"outfile" is now a pointer to const.
2000-11-30 11:33:49 +00:00
Jim Meyering
21b8c52ae9 *** empty log message *** 2000-11-30 09:36:04 +00:00
Jim Meyering
7303ca25db (dir_name_r): Fix typo: int -> size_t. 2000-11-30 09:35:52 +00:00
Jim Meyering
060fb58f86 *** empty log message *** 2000-11-30 07:45:38 +00:00
Jim Meyering
d185a442b9 s/ifval/m4_ifval/ to accommodate new autoconf. 2000-11-30 07:44:58 +00:00
Jim Meyering
86046cb32f . 2000-11-30 07:40:16 +00:00
Jim Meyering
1500316caf remove useless parens 2000-11-27 09:33:53 +00:00
Jim Meyering
72454050bb *** empty log message *** 2000-11-27 09:04:38 +00:00
Jim Meyering
b0b9c6fee7 *** empty log message *** 2000-11-27 08:47:13 +00:00
Jim Meyering
4a9feba665 add an echo 2000-11-27 08:45:46 +00:00
41 changed files with 852 additions and 391 deletions

View File

@@ -121,6 +121,7 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
for url in $(url_dir_list); do \
echo " $$url/$(xd-delta)"; \
done; \
echo; \
echo "Here are the MD5 and SHA1 signatures for the .tar.gz file"; \
echo; \
echo "$(md5) $(distdir).tar.gz"; \
@@ -171,7 +172,7 @@ alpha: writable-files po-check
cvs ci -m. $(prev_version_file)
@echo =====================================
@echo =====================================
@echo 'scp $(xd-delta) $(distdir).tar.gz \'
@echo 'rsync -e ssh --pro -av $(xd-delta) $(distdir).tar.gz \'
@echo ' $(b_host):$(b_real_dir)'
@echo '# send the /tmp/announcement e-mail'
@echo =====================================

1
THANKS
View File

@@ -186,6 +186,7 @@ Mark D. Roth roth@uiuc.edu
Mark Harris mark@monitor.designacc.com
Mark Hewitt mhewitt@armature.com
Mark Kettenis kettenis@phys.uva.nl
Mark Nudelman marknu@flash.net
Mark W. Eichin eichin@cygnus.com
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
Martin martin@dresden.nacamar.de

View File

@@ -2269,7 +2269,9 @@ string between a non-whitespace character and a whitespace character.
That is, given the input line @w{@samp{ foo bar}}, @code{sort} breaks it
into fields @w{@samp{ foo}} and @w{@samp{ bar}}. The field separator is
not considered to be part of either the field preceding or the field
following.
following. But note that sort fields that extend to the end of the line,
as @samp{-k 2}, or sort fields consisting of a range, as @samp{-k 2,3},
retain the field separators present between the endpoints of the range.
@item -T @var{tempdir}
@opindex -T

View File

@@ -1,3 +1,25 @@
2000-12-05 Jim Meyering <meyering@lucent.com>
* dirname.c (dir_name_r): Add `const' in a few local declarations.
2000-12-04 Jim Meyering <meyering@lucent.com>
* path-concat.c: [!HAVE_DECL_MALLOC]: Declare malloc.
Also include memory.h, stdlib.h, unistd.h if appropriate.
Reported by Andreas Jaeger (conflicting declaration of malloc).
2000-12-02 Jim Meyering <meyering@lucent.com>
* closeout.h: Make idempotent, to avoid some obscure warnings.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* lib/memrchr.c: Include <config.h> before any system include file.
2000-11-29 Paul Eggert <eggert@twinsun.com>
* lib/dirname.c (dir_name_r): Fix typo: int -> size_t.
2000-11-26 Jim Meyering <meyering@lucent.com>
* memcoll.c: Include sys/types.h. From Werner Almesberger.

View File

@@ -387,6 +387,8 @@ localcharset_.c: localcharset.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/localcharset.c; then echo $(srcdir)/localcharset.c; else echo localcharset.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > localcharset_.c
long-options_.c: long-options.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/long-options.c; then echo $(srcdir)/long-options.c; else echo long-options.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > long-options_.c
lstat_.c: lstat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lstat.c; then echo $(srcdir)/lstat.c; else echo lstat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > lstat_.c
makepath_.c: makepath.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/makepath.c; then echo $(srcdir)/makepath.c; else echo makepath.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > makepath_.c
malloc_.c: malloc.c $(ANSI2KNR)
@@ -453,6 +455,8 @@ savedir_.c: savedir.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/savedir.c; then echo $(srcdir)/savedir.c; else echo savedir.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > savedir_.c
sha_.c: sha.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sha.c; then echo $(srcdir)/sha.c; else echo sha.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > sha_.c
stat_.c: stat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stat.c; then echo $(srcdir)/stat.c; else echo stat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stat_.c
stime_.c: stime.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stime.c; then echo $(srcdir)/stime.c; else echo stime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stime_.c
stpcpy_.c: stpcpy.c $(ANSI2KNR)
@@ -522,19 +526,19 @@ fnmatch_.o fsusage_.o ftruncate_.o full-write_.o getdate_.o \
getgroups_.o gethostname_.o getline_.o getloadavg_.o getopt_.o \
getopt1_.o getpass_.o getstr_.o getugroups_.o getusershell_.o \
group-member_.o hard-locale_.o hash_.o human_.o idcache_.o isdir_.o \
lchown_.o linebuffer_.o localcharset_.o long-options_.o makepath_.o \
malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o memcmp_.o \
memcoll_.o memcpy_.o memmove_.o memrchr_.o memset_.o mktime_.o \
modechange_.o mountlist_.o nanosleep_.o obstack_.o path-concat_.o \
posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o readutmp_.o \
realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o same_.o \
save-cwd_.o savedir_.o sha_.o stime_.o stpcpy_.o strcasecmp_.o \
strcspn_.o strdup_.o strftime_.o stripslash_.o strncasecmp_.o \
strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o strtol_.o \
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o \
userspec_.o utime_.o version-etc_.o xgetcwd_.o xgethostname_.o \
xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
yesno_.o : $(ANSI2KNR)
lchown_.o linebuffer_.o localcharset_.o long-options_.o lstat_.o \
makepath_.o malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o \
memcmp_.o memcoll_.o memcpy_.o memmove_.o memrchr_.o memset_.o \
mktime_.o modechange_.o mountlist_.o nanosleep_.o obstack_.o \
path-concat_.o posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o \
readutmp_.o realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o \
same_.o save-cwd_.o savedir_.o sha_.o stat_.o stime_.o stpcpy_.o \
strcasecmp_.o strcspn_.o strdup_.o strftime_.o stripslash_.o \
strncasecmp_.o strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o \
strtol_.o strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o \
unicodeio_.o userspec_.o utime_.o version-etc_.o xgetcwd_.o \
xgethostname_.o xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o \
xstrtoumax_.o yesno_.o : $(ANSI2KNR)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \

View File

@@ -1,12 +1,17 @@
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
#ifndef CLOSEOUT_H
# define CLOSEOUT_H 1
# ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
# endif
#endif
void close_stdout_set_status PARAMS ((int status));
void close_stdout_set_file_name PARAMS ((const char *file));
void close_stdout PARAMS ((void));
void close_stdout_status PARAMS ((int status));
#endif

View File

@@ -54,15 +54,15 @@ void *memrchr ();
Works properly even if there are trailing slashes
(by effectively ignoring them). */
size_t
dir_name_r (const char *path, const char **result)
dir_name_r (char const *path, char const **result)
{
char *slash;
int length; /* Length of result, not including NUL. */
char const *slash;
size_t length; /* Length of result, not including NUL. */
slash = strrchr (path, '/');
if (BACKSLASH_IS_PATH_SEPARATOR)
{
char *b = strrchr (path, '\\');
char const *b = strrchr (path, '\\');
if (b && slash < b)
slash = b;
}
@@ -81,7 +81,7 @@ dir_name_r (const char *path, const char **result)
slash = memrchr (path, '/', slash - path);
if (BACKSLASH_IS_PATH_SEPARATOR)
{
char *b = memrchr (path, '\\', slash - path);
char const *b = memrchr (path, '\\', slash - path);
if (b && slash < b)
slash = b;
}
@@ -99,7 +99,7 @@ dir_name_r (const char *path, const char **result)
/* Remove any trailing slashes from the result. */
if (BACKSLASH_IS_PATH_SEPARATOR)
{
const char *lim = ((path[0] >= 'A' && path[0] <= 'z'
char const *lim = ((path[0] >= 'A' && path[0] <= 'z'
&& path[1] == ':')
? path + 2 : path);
@@ -126,9 +126,9 @@ dir_name_r (const char *path, const char **result)
(by effectively ignoring them). */
char *
dir_name (const char *path)
dir_name (char const *path)
{
const char *result;
char const *result;
size_t length = dir_name_r (path, &result);
char *newpath = (char *) malloc (length + 1);
if (newpath == 0)
@@ -170,7 +170,7 @@ main ()
{
char path[MAX_BUFF_LEN];
char expected_result[MAX_BUFF_LEN];
char *result;
char const *result;
sscanf (buff, "%s %s", path, expected_result);
result = dir_name (path);
if (strcmp (result, expected_result))

View File

@@ -145,7 +145,7 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
/* The following is from gnupg-1.0.2's cipher/bithelp.h. */
/* Rotate a 32 bit integer by n bytes */
#if defined(__GNUC__) && defined(__i386__)
#if defined __GNUC__ && defined __i386__
static inline md5_uint32
rol(md5_uint32 x, int n)
{

View File

@@ -21,12 +21,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#undef __ptr_t
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
# define __ptr_t void *

View File

@@ -26,12 +26,31 @@
#endif
#include <stdio.h>
#if HAVE_STRING_H
# include <string.h>
#endif
#include <sys/types.h>
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#else
# if HAVE_STRINGS_H
# include <strings.h>
# endif
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef HAVE_DECL_MALLOC
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_MALLOC
char *malloc ();
#endif
#ifndef strdup
char *strdup ();
#endif

View File

@@ -1,3 +1,22 @@
2000-12-06 Jim Meyering <meyering@lucent.com>
* xstrtoumax.m4 (jm_AC_PREREQ_XSTRTOUMAX): If we need the replacement
strtoull, we may well need the replacement strtoul, too.
Check for declarations of strtoul and strtoull.
2000-12-02 Jim Meyering <meyering@lucent.com>
* off_t-format.m4 (OFF_T_PRINTF_FORMAT_STRING): New file/macro.
* jm-macros.m4 (jm_MACROS): require it.
2000-11-30 Jim Meyering <meyering@lucent.com>
* jm-macros.m4 (jm_MACROS): Check for stdint.h.
2000-11-30 Jim Meyering <meyering@lucent.com>
* getloadavg.m4: s/ifval/m4_ifval/ to accommodate new autoconf.
2000-11-03 Bruno Haible <haible@clisp.cons.org>
* jm-macros.m4 (jm_MACROS): Add test for wcrtomb.

View File

@@ -44,6 +44,7 @@ mbstate_t.m4 \
mbswidth.m4 \
memcmp.m4 \
nanosleep.m4 \
off_t-format.m4 \
perl.m4 \
prereq.m4 \
progtest.m4 \

View File

@@ -159,6 +159,7 @@ mbstate_t.m4 \
mbswidth.m4 \
memcmp.m4 \
nanosleep.m4 \
off_t-format.m4 \
perl.m4 \
prereq.m4 \
progtest.m4 \

View File

@@ -1,4 +1,4 @@
#serial 7
#serial 8
# A replacement for autoconf's macro by the same name. This version
# accepts an optional argument specifying the name of the $srcdir-relative
@@ -15,7 +15,7 @@ AC_DEFUN([AC_FUNC_GETLOADAVG],
# By default, expect to find getloadavg.c in $srcdir/.
ac_lib_dir_getloadavg=$srcdir
# But if there's an argument, DIR, expect to find getloadavg.c in $srcdir/DIR.
ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
m4_ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
# Make sure getloadavg.c is where it belongs, at ./configure-time.
test -f $ac_lib_dir_getloadavg/getloadavg.c \
|| AC_MSG_ERROR([getloadavg.c is not in $ac_lib_dir_getloadavg])

View File

@@ -1,4 +1,4 @@
#serial 27
#serial 28 -*- autoconf -*-
dnl Misc type-related macros for fileutils, sh-utils, textutils.
@@ -32,6 +32,7 @@ AC_DEFUN(jm_MACROS,
paths.h \
stdlib.h \
stddef.h \
stdint.h \
string.h \
sys/acl.h \
sys/filsys.h \
@@ -69,6 +70,7 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([jm_PREREQ])
AC_REQUIRE([jm_SYS_OFF_T_PRINTF_FORMAT])
AC_REQUIRE([jm_FUNC_LCHOWN])
AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
AC_REQUIRE([jm_FUNC_CHOWN])

55
m4/off_t-format.m4 Normal file
View File

@@ -0,0 +1,55 @@
#serial 1 -*- autoconf -*-
dnl FIXME
AC_DEFUN(jm_SYS_OFF_T_PRINTF_FORMAT,
[dnl
AC_REQUIRE([AC_TYPE_OFF_T])
AC_CHECK_HEADERS(string.h stdlinb.h)
AC_CACHE_CHECK([for printf format that works with type off_t],
jm_cv_sys_off_t_printf_format,
[
jm_cv_sys_off_t_printf_format=undef
for jm_fmt in '' L ll q; do
jm_OFF_T_FORMAT="$jm_fmt"
export jm_OFF_T_FORMAT
AC_TRY_RUN([
# include <sys/types.h>
# include <stdio.h>
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
# if HAVE_STRING_H
# include <string.h>
# endif
int
main()
{
static off_t x[] = {1, 255, 65535, 99999999};
char buf[50], fmt[50];
/* this should be one of these values: "", "L", "ll", "q" */
char *f = getenv ("jm_OFF_T_FORMAT");
sprintf (fmt, "%%%sd %%%sx %%%sx %%%sd", f, f, f, f);
sprintf (buf, fmt, x[0], x[1], x[2], x[3]);
exit (strcmp (buf, "1 ff ffff 99999999"));
}
], jm_cv_sys_off_t_printf_format=$jm_fmt; break
, dnl didn't work
dnl Cross compiling -- you lose. Specify it via the cache.
)
done
# Die if none of the above worked.
# FIXME: If this failure become a problem that we can't work around,
# an alternative would be to arrange not to build od.
if test "$jm_cv_sys_off_t_printf_format" = undef; then
AC_MSG_ERROR(dnl
[couldn't find a printf format that works with the type, off_t])
fi
])
AC_DEFINE_UNQUOTED(OFF_T_PRINTF_FORMAT_STRING,
"$jm_cv_sys_off_t_printf_format",
[printf format string for type off_t, without the `%'])
])

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
# autoconf tests required for use of xstrtoumax.c
@@ -7,7 +7,8 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_DECLS([strtoul, strtoull])
AC_CHECK_HEADERS(limits.h stdlib.h)
AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
jm_cv_func_strtoumax_macro,
@@ -28,7 +29,13 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
dnl so we need the replacement strtoull only if strtoumax does not exist.
case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
yes,no,no)
AC_REPLACE_FUNCS(strtoull)
AC_REPLACE_FUNCS(strtoull strtol)
;;
esac
case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
no,no)
AC_REPLACE_FUNCS(strtoul strtol)
;;
esac

View File

@@ -1,8 +1,62 @@
2000-12-03 Jim Meyering <meyering@lucent.com>
* Version 4.0.34.
* src/ls.c (gobble_file) [USE_ACL]: Set have_acl member unconditionally
to avoid uninitialized memory reference via FILE_HAS_ACL.
* Makefile.maint (alpha): Use rsync rather than scp, so the destination
file is created only after the successful completion of the copy.
2000-12-02 Jim Meyering <meyering@lucent.com>
* tests/ls/Makefile.am (TESTS): Add follow-slink.
* tests/ls/follow-slink: New file.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* src/ls.c (gobble_file): Do not fall back on lstat if stat
fails; POSIX.2 does not allow this. Invoke acl only on
non-symlinks, and only if lstat or stat succeeds.
2000-12-02 Jim Meyering <meyering@lucent.com>
* configure: Regenerate using the very latest version (in CVS) of
autoconf.
* tests/dd/skip-seek: Remove test #2, now that support for the
`B' suffix is gone.
* tests/dd/Makefile.am (TESTS): Add skip-seek2
* tests/dd/skip-seek2: New file.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* src/dd.c (skip, dd_copy): Use ssize_t to store result of
safe_read, to avoid overflow e.g. on 64-bit Solaris sparc.
(dd_copy): Remove unnecessary cast.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* doc/fileutils.texi: Remove B suffix. Document how to have
the desired effect without it.
* src/dd.c: Undo most of the changes since 2000-11-24, since we've
documented a standard way to do it.
(skip_bytes, seek_bytes): Remove.
(usage): Remove B suffix.
(scanargs, skip, dd_copy, main): Remove support for B suffix.
2000-11-28 Jim Meyering <meyering@lucent.com>
* src/mkdir.c (main): Remove any trailing slash unconditionally.
Reported by Volker Borchert.
* tests/mkdir/t-slash: Add a test for this.
2000-11-27 Jim Meyering <meyering@lucent.com>
* Version 4.0.33.
* tests/touch/no-rights: Use touch with `-d tomorrow' to avoid
* tests/touch/no-rights: Use touch with `-d tomorrow' to avoid a
race condition.
* tests/Fetish.pm (_compare_files): New function.

View File

@@ -1,7 +1,12 @@
Changes in release 4.01:
[4.0.34]
* `ls -L dangling-symlink' now fails (per POSIX) rather than printing the
link name
* dd no longer honors the just-added `B' suffix on skip= and seek= arguments.
* `mkdir no-such-dir/' no longer fails on NetBSD systems
[4.0.33]
* dd now accepts skip=nB and seek=nB, to advance past some number of bytes, n,
that is smaller than the block size.
that need not be a multiple of the block size.
* dd (without conv=notrunc) now uses ftruncate only on regular files
* chmod --changes (-c) once again issues diagnostics only for the files
with changed permissions

View File

@@ -1,7 +1,18 @@
2000-11-18 Jim Meyering <meyering@lucent.com>
2000-12-02 Jim Meyering <meyering@lucent.com>
* Version 2.0.12.
* src/seq.c (valid_format): Move pre-increment to a separate statement
to avoid a warning.
* src/id.c: Move dcls of globals used only in main...
(main): ...to here.
(usage): Clarify option descriptions.
2000-11-18 Jim Meyering <meyering@lucent.com>
* po/Makefile.in.in: Sync with the one from fileutils.
* configure, config.h.in, Makefile.in, etc.: Regenerate using the
very latest version (in CVS) of autoconf.

View File

@@ -1,7 +1,135 @@
2000-11-27 Jim Meyering <meyering@lucent.com>
2000-12-03 Jim Meyering <meyering@lucent.com>
* src/tail.c (tail_file): Initialize ignore, dev, and ino members,
when tailing forever and the open failed. Otherwise, we could get
uninitialized memory references of those fields in recheck.
* tests/tail-2/Makefile.am (TESTS): Add assert-2.
* tests/tail-2/assert-2: New file.
* Version 2.0.9.
Make od print valid addresses for offsets of 2^32 and larger, and
allow byte offset (-j) and byte count (-N) to be 2^32 and larger.
* src/od.c (MAX_ADDRESS_LENGTH): Don't hard-code as a literal.
Rather, define in terms of the type, off_t.
(string_min): Declare to be of type size_t.
(flag_dump_strings): Declare to be of type int.
(print_s_char): Declare the n_bytes parameter and the local, `i',
to be of type off_t.
(print_char): Likewise.
(print_s_short): Likewise.
(print_short): Likewise.
(print_int): Likewise.
(print_long): Likewise.
(print_long_long): Likewise.
(print_float): Likewise.
(print_double): Likewise.
(print_long_double): Likewise.
(dump_hexl_mode_trailer): Likewise.
(print_named_ascii): Likewise.
(print_ascii): Likewise.
(write_block): Likewise.
(print_ascii): Declare local, `print_function' with a prototype.
Change a few `>' comparisons to the equivalent `<' form.
(parse_options): Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if the specified offset if larger than OFF_T_MAX.
(dump_strings): Declare local `i' to be of type size_t.
Remove the now-unnecessary cast-to-off_t.
(main) [IF_LINT]: Initialize desired_width to avoid a warning.
Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if minimum string length is larger than SIZE_MAX.
Fail if specified width is larger than ULONG_MAX.
* src/od.c (format_address): Use off_t, not long unsigned_int as the
parameter type.
(format_address_none): Likewise. Mark parameter as unused.
(format_address_std): Likewise.
(format_address_label): Likewise.
(print_ascii): Mark format string parameter as unused.
(write_block): Use off_t, not long unsigned_int as offset type.
(expand_address_fmt): New function.
(main): Use it to expand each address format string template.
Reported by Mark Nudelman, via Andreas Jaeger.
* src/sys2.h (OFF_T_MIN): Define here instead.
(OFF_T_MAX): Likewise.
(CHAR_BIT): Define.
* src/tail.c (parse_options): Use xstrtoumax to parse the byte and line
offset. Give a better diagnostic when the requested offset is still
representable but larger than OFF_T_MAX.
(OFF_T_MIN): Remove definition.
(OFF_T_MAX): Likewise.
2000-12-02 Jim Meyering <meyering@lucent.com>
* src/sort.c (checkfp): Rename local `buf' to avoid shadowing previous
declaration.
* src/sort.c (NONZERO): Define and use it to make the code a tiny
bit more readable.
* doc/textutils.texi (sort invocation): Clarify how -t works
when a sort key specifies a range of fields. From Karl O. Pinc.
2000-11-26 Paul Eggert <eggert@twinsun.com>
* src/od.c (skip): Use lseek instead of worrying about fseeko or fseek.
This should be portable, as we seek before doing any I/O.
(fseeko): Remove; no longer used.
2000-11-30 Jim Meyering <meyering@lucent.com>
* src/sort.c: s/SIZE_T_MAX/SIZE_MAX/.
2000-11-30 Paul Eggert <eggert@twinsun.com>
* src/sys2.h: Include <stdint.h> if HAVE_STDINT_H.
(SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX.
All uses changed.
2000-11-30 Jim Meyering <meyering@lucent.com>
* src/sort.c: SIZE_MAX is not defined, so s/SIZE_MAX/SIZE_T_MAX/, and...
* src/sys2.h (SIZE_T_MAX): ... define.
2000-11-29 Paul Eggert <eggert@twinsun.com>
Port GNU "sort" to hosts where sizes don't fit in "int",
e.g. 64-bit Solaris (sparc).
* src/sort.c ("human.h", "xstrtol.h"): Include.
(struct line): length member is now size_t, not int.
(struct lines): Likewise for used, alloc, limit members.
(struct buffer): Likewise for used, alloc, left, newline_free members.
(struct keyfield): Likewise for sword, schar, eword, echar members.
(sortalloc, mergealloc, linelength): Now size_t, not int.
(initbuf, fillbuf, initlines, begfield, limfield, findlines,
numcompare, getmonth, keycompare, compare, checkfp, mergefps,
sortlines, sort): Accept, return, and use size_t for sizes, not int.
(fillbuf, initlines, findlines, checkfp, sort): Check for overflow
when computing buffer sizes.
(begfield, limfield): Do not index past end of array.
(checkfp): Return a boolean, not a line number, as the line
number may not fit in int. All callers changed. Use
uintmax_t for line numbers, not int.
(sort): Don't allocate tmp until we need it (and know the right size).
(parse_field_count): New function.
(main): Use it to check for overflow in field counts.
"outfile" is now a pointer to const.
2000-11-27 Jim Meyering <meyering@lucent.com>
* src/checksum.h: Don't include system.h here.
* src/md5.c: Include config.h, stdio.h, sys/types.h. and system.h here
instead.

View File

@@ -1,5 +1,9 @@
Changes in release 2.1
[2.0.9]
* od now prints valid addresses for offsets of 2^32 and larger, and allows
the byte offset (-j) and byte count (-N) arguments to be 2^32 and larger.
* tail now works with line and byte counts of 2^32 and larger, on systems
with large file support
* join now works with an 8-bit delimiter
* fix a compilation failure on some Solaris systems with wc.c
[2.0.8]

View File

@@ -103,15 +103,9 @@ static size_t conversion_blocksize = 0;
/* Skip this many records of `input_blocksize' bytes before input. */
static uintmax_t skip_records = 0;
/* Nonzero if SKIP_RECORDS is actually a byte count, not a record count. */
static int skip_bytes = 0;
/* Skip this many records of `output_blocksize' bytes before output. */
static uintmax_t seek_records = 0;
/* Nonzero if SEEK_RECORDS is actually a byte count, not a record count. */
static int seek_bytes = 0;
/* Copy only this many records. The default is effectively infinity. */
static uintmax_t max_records = (uintmax_t) -1;
@@ -311,7 +305,6 @@ Copy a file, converting and formatting according to the options.\n\
BLOCKS and BYTES may be followed by the following multiplicative suffixes:\n\
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,\n\
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.\n\
For seek= and skip=, a B suffix for BLOCKS means it counts bytes not blocks.\n\
Each KEYWORD may be:\n\
\n\
ascii from EBCDIC to ASCII\n\
@@ -566,18 +559,7 @@ scanargs (int argc, char **argv)
else
{
int invalid = 0;
uintmax_t n;
int count_bytes = 0;
if (STREQ (name, "seek") || STREQ (name, "skip"))
{
size_t vallen = strlen (val);
count_bytes = vallen && val[vallen - 1] == 'B';
if (count_bytes)
val[vallen - 1] = '\0';
}
n = parse_integer (val, &invalid);
uintmax_t n = parse_integer (val, &invalid);
if (STREQ (name, "ibs"))
{
@@ -603,15 +585,9 @@ scanargs (int argc, char **argv)
|| conversion_blocksize == 0);
}
else if (STREQ (name, "skip"))
{
skip_records = n;
skip_bytes = count_bytes;
}
skip_records = n;
else if (STREQ (name, "seek"))
{
seek_records = n;
seek_bytes = count_bytes;
}
seek_records = n;
else if (STREQ (name, "count"))
max_records = n;
else
@@ -783,32 +759,23 @@ buggy_lseek_support (int fdesc)
nonzero. */
static void
skip (int fdesc, char *file, int count_bytes, uintmax_t records,
size_t blocksize, unsigned char *buf)
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
unsigned char *buf)
{
size_t seek_blocksize = count_bytes ? 1 : blocksize;
off_t offset = records * seek_blocksize;
off_t offset = records * blocksize;
/* Try lseek and if an error indicates it was an inappropriate
operation, fall back on using read. Some broken versions of
lseek may return zero, so count that as an error too as a valid
zero return is not possible here. */
if (offset / seek_blocksize != records
if (offset / blocksize != records
|| buggy_lseek_support (fdesc)
|| lseek (fdesc, offset, SEEK_CUR) <= 0)
{
if (count_bytes)
records = offset;
while (records)
while (records--)
{
int nread;
if (count_bytes && records < blocksize)
blocksize = records;
nread = safe_read (fdesc, buf, blocksize);
ssize_t nread = safe_read (fdesc, buf, blocksize);
if (nread < 0)
{
error (0, errno, _("reading %s"), quote (file));
@@ -819,8 +786,6 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records,
FIXME: maybe give a warning. */
if (nread == 0)
break;
records -= (count_bytes ? nread : 1);
}
}
}
@@ -927,7 +892,7 @@ dd_copy (void)
unsigned char *ibuf, *bufstart; /* Input buffer. */
unsigned char *real_buf; /* real buffer address before alignment */
unsigned char *real_obuf;
int nread; /* Bytes read in the current block. */
ssize_t nread; /* Bytes read in the current block. */
int exit_status = 0;
size_t page_size = getpagesize ();
size_t n_bytes_read;
@@ -970,8 +935,7 @@ dd_copy (void)
}
if (skip_records != 0)
skip (STDIN_FILENO, input_file, skip_bytes, skip_records,
input_blocksize, ibuf);
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
if (seek_records != 0)
{
@@ -982,8 +946,7 @@ dd_copy (void)
0+0 records out
*/
skip (STDOUT_FILENO, output_file, seek_bytes, seek_records,
output_blocksize, obuf);
skip (STDOUT_FILENO, output_file, seek_records, output_blocksize, obuf);
}
if (max_records == 0)
@@ -1028,7 +991,7 @@ dd_copy (void)
}
}
n_bytes_read = (size_t) nread;
n_bytes_read = nread;
if (n_bytes_read < input_blocksize)
{
@@ -1190,9 +1153,8 @@ main (int argc, char **argv)
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
{
struct stat stdout_stat;
size_t blocksize = seek_bytes ? 1 : output_blocksize;
off_t o = seek_records * blocksize;
if (o / blocksize != seek_records)
off_t o = seek_records * output_blocksize;
if (o / output_blocksize != seek_records)
error (1, 0, _("file offset out of range"));
if (fstat (STDOUT_FILENO, &stdout_stat) != 0)

View File

@@ -54,21 +54,9 @@ static void print_full_info PARAMS ((const char *username));
/* The name this program was run with. */
char *program_name;
/* If nonzero, output only the group ID(s). -g */
static int just_group = 0;
/* If nonzero, output user/group name instead of ID number. -n */
static int use_name = 0;
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
static int use_real = 0;
/* If nonzero, output only the user ID(s). -u */
static int just_user = 0;
/* If nonzero, output only the supplementary groups. -G */
static int just_group_list = 0;
/* The real and effective IDs of the user to print. */
static uid_t ruid, euid;
static gid_t rgid, egid;
@@ -101,11 +89,11 @@ usage (int status)
Print information for USERNAME, or the current user.\n\
\n\
-a ignore, for compatibility with other versions\n\
-g, --group print only the group ID\n\
-G, --groups print only the supplementary groups\n\
-g, --group print only the effective group ID\n\
-G, --groups print all group IDs\n\
-n, --name print a name instead of a number, for -ugG\n\
-r, --real print the real ID instead of effective ID, for -ugG\n\
-u, --user print only the user ID\n\
-r, --real print the real ID instead of the effective ID, with -ugG\n\
-u, --user print only the effective user ID\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
@@ -121,6 +109,15 @@ main (int argc, char **argv)
{
int optc;
/* If nonzero, output the list of all group IDs. -G */
int just_group_list = 0;
/* If nonzero, output only the group ID(s). -g */
int just_group = 0;
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
int use_real = 0;
/* If nonzero, output only the user ID(s). -u */
int just_user = 0;
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);

View File

@@ -1887,23 +1887,9 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
attach (path, dirname, name);
}
if (trace_links)
{
val = stat (path, &files[files_index].stat);
if (val < 0)
{
/* Perhaps a symbolically-linked to file doesn't exist; stat
the link instead. */
val = lstat (path, &files[files_index].stat);
}
}
else
{
val = lstat (path, &files[files_index].stat);
#if USE_ACL
files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
#endif
}
val = (trace_links
? stat (path, &files[files_index].stat)
: lstat (path, &files[files_index].stat));
if (val < 0)
{
@@ -1912,6 +1898,12 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
return 0;
}
#if USE_ACL
files[files_index].have_acl =
(! S_ISLNK (files[files_index].stat.st_mode)
&& 4 < acl (path, GETACLCNT, 0, NULL));
#endif
if (S_ISLNK (files[files_index].stat.st_mode)
&& (explicit_arg || format == long_format || check_symlink_color))
{

View File

@@ -143,23 +143,19 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
{
int fail = 0;
/* Remove any trailing slashes. Not removing them would lead to calling
`mkdir ("dir/", mode)' for e.g., the commands `mkdir dir/' and
`mkdir -p dir/', and such a call fails on NetBSD systems when `dir'
doesn't already exist. */
strip_trailing_slashes (argv[optind]);
if (create_parents)
{
char *parents = dir_name (argv[optind]);
fail = make_path (parents, parent_mode, parent_mode,
-1, -1, 1, verbose_fmt_string);
free (parents);
/* If we're creating parent directories, then it's ok to remove
trailing slashes. In fact, *not* removing them would lead
to calling `mkdir ("dir/", mode)' for the command `mkdir -p dir/',
and such a call fails on NetBSD systems if `dir' doesn't already
exist. */
/* An alternate approach would be to change make_path to interpret
an argument with a trailing slash as if it also had a trailing
`.'. In fact, that would be more consistent with POSIX, so
FIXME: some day. */
strip_trailing_slashes (argv[optind]);
}
if (fail == 0)

190
src/od.c
View File

@@ -65,11 +65,6 @@ typedef double LONG_DOUBLE;
# define LDBL_DIG DBL_DIG
#endif
#if !HAVE_FSEEKO
# undef fseeko
# define fseeko(Stream, Offset, Whence) (-1)
#endif
enum size_spec
{
NO_SIZE,
@@ -158,16 +153,17 @@ static const char *const charname[33] =
/* A printf control string for printing a file offset. */
static const char *output_address_fmt_string;
/* FIXME: make this the number of octal digits in an unsigned long. */
#define MAX_ADDRESS_LENGTH 13
/* The number of octal digits required to represent the largest off_t value. */
#define MAX_ADDRESS_LENGTH \
((sizeof (off_t) * CHAR_BIT + CHAR_BIT - 1) / 3)
/* Space for a normal address, a space, a pseudo address, parentheses
around the pseudo address, and a trailing zero byte. */
static char address_fmt_buffer[2 * MAX_ADDRESS_LENGTH + 4];
static char address_pad[MAX_ADDRESS_LENGTH + 1];
static unsigned long int string_min;
static unsigned long int flag_dump_strings;
static size_t string_min;
static int flag_dump_strings;
/* Non-zero if we should recognize the pre-POSIX non-option arguments
that specified at most one file and optional arguments specifying
@@ -183,7 +179,7 @@ static long int pseudo_offset;
/* Function to format an address and optionally an additional parenthesized
pseudo-address; it returns the formatted string. */
static const char *(*format_address) PARAMS ((long unsigned int));
static const char *(*format_address) PARAMS ((off_t));
/* The number of input bytes to skip before formatting and writing. */
static off_t n_bytes_to_skip = 0;
@@ -364,10 +360,9 @@ lcm (unsigned int u, unsigned int v)
}
static void
print_s_char (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_s_char (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
int tmp = (unsigned) *(const unsigned char *) block;
@@ -380,10 +375,9 @@ print_s_char (long unsigned int n_bytes, const char *block,
}
static void
print_char (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_char (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int tmp = *(const unsigned char *) block;
@@ -393,10 +387,9 @@ print_char (long unsigned int n_bytes, const char *block,
}
static void
print_s_short (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_s_short (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
{
int tmp = (unsigned) *(const unsigned short *) block;
@@ -409,10 +402,9 @@ print_s_short (long unsigned int n_bytes, const char *block,
}
static void
print_short (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_short (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
{
unsigned int tmp = *(const unsigned short *) block;
@@ -422,10 +414,9 @@ print_short (long unsigned int n_bytes, const char *block,
}
static void
print_int (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_int (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned int); i > 0; i--)
{
unsigned int tmp = *(const unsigned int *) block;
@@ -435,10 +426,9 @@ print_int (long unsigned int n_bytes, const char *block,
}
static void
print_long (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned long); i > 0; i--)
{
unsigned long tmp = *(const unsigned long *) block;
@@ -449,10 +439,9 @@ print_long (long unsigned int n_bytes, const char *block,
#ifdef HAVE_UNSIGNED_LONG_LONG
static void
print_long_long (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long_long (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned long long); i > 0; i--)
{
unsigned long long tmp = *(const unsigned long long *) block;
@@ -463,10 +452,9 @@ print_long_long (long unsigned int n_bytes, const char *block,
#endif
static void
print_float (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_float (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (float); i > 0; i--)
{
float tmp = *(const float *) block;
@@ -476,10 +464,9 @@ print_float (long unsigned int n_bytes, const char *block,
}
static void
print_double (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_double (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (double); i > 0; i--)
{
double tmp = *(const double *) block;
@@ -490,10 +477,9 @@ print_double (long unsigned int n_bytes, const char *block,
#ifdef HAVE_LONG_DOUBLE
static void
print_long_double (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long_double (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (LONG_DOUBLE); i > 0; i--)
{
LONG_DOUBLE tmp = *(const LONG_DOUBLE *) block;
@@ -505,9 +491,9 @@ print_long_double (long unsigned int n_bytes, const char *block,
#endif
static void
dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
dump_hexl_mode_trailer (off_t n_bytes, const char *block)
{
int i;
off_t i;
fputs (" >", stdout);
for (i = n_bytes; i > 0; i--)
{
@@ -520,10 +506,10 @@ dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
}
static void
print_named_ascii (long unsigned int n_bytes, const char *block,
const char *unused_fmt_string)
print_named_ascii (off_t n_bytes, const char *block,
const char *unused_fmt_string ATTRIBUTE_UNUSED)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int c = *(const unsigned char *) block;
@@ -547,10 +533,10 @@ print_named_ascii (long unsigned int n_bytes, const char *block,
}
static void
print_ascii (long unsigned int n_bytes, const char *block,
const char *unused_fmt_string)
print_ascii (off_t n_bytes, const char *block,
const char *unused_fmt_string ATTRIBUTE_UNUSED)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int c = *(const unsigned char *) block;
@@ -652,7 +638,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
enum output_format fmt;
const char *pre_fmt_string;
char *fmt_string;
void (*print_function) ();
void (*print_function) PARAMS ((off_t, const char *, const char *));
const char *p;
unsigned int c;
unsigned int field_width = 0;
@@ -702,7 +688,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
size = sizeof (int);
else
{
if (size > MAX_INTEGRAL_TYPE_SIZE
if (MAX_INTEGRAL_TYPE_SIZE < size
|| integral_type_size[size] == NO_SIZE)
{
error (0, 0, _("invalid type string `%s';\n\
@@ -986,15 +972,15 @@ skip (off_t n_skip)
if (n_skip == 0)
break;
/* First try using fseek. For large offsets, this extra work is
/* First try seeking. For large offsets, this extra work is
worthwhile. If the offset is below some threshold it may be
more efficient to move the pointer by reading. There are two
issues when trying to use fseek:
issues when trying to seek:
- the file must be seekable.
- before seeking to the specified position, make sure
that the new position is in the current file.
Try to do that by getting file's size using fstat().
But that will work only for regular files and dirs. */
Try to do that by getting file's size using fstat.
But that will work only for regular files. */
if (fstat (fileno (in_stream), &file_stats))
{
@@ -1010,7 +996,7 @@ skip (off_t n_skip)
n_skip and go on to the next file. */
if (S_ISREG (file_stats.st_mode))
{
if (n_skip >= file_stats.st_size)
if (file_stats.st_size <= n_skip)
{
n_skip -= file_stats.st_size;
if (in_stream != stdin && fclose (in_stream) == EOF)
@@ -1022,10 +1008,7 @@ skip (off_t n_skip)
}
else
{
/* Try fseeko if available, fseek otherwise. */
if (fseeko (in_stream, n_skip, SEEK_SET) == 0
|| (n_skip <= LONG_MAX
&& fseek (in_stream, (long) n_skip, SEEK_SET) == 0))
if (0 <= lseek (fileno (in_stream), n_skip, SEEK_CUR))
{
n_skip = 0;
break;
@@ -1036,10 +1019,10 @@ skip (off_t n_skip)
/* Seek didn't work or wasn't attempted; position the file pointer
by reading. */
for (j = n_skip / BUFSIZ; j >= 0; j--)
for (j = n_skip / BUFSIZ; 0 <= j; j--)
{
char buf[BUFSIZ];
size_t n_bytes_to_read = (j > 0
size_t n_bytes_to_read = (0 < j
? BUFSIZ
: n_skip % BUFSIZ);
size_t n_bytes_read;
@@ -1060,13 +1043,13 @@ skip (off_t n_skip)
}
static const char *
format_address_none (long unsigned int address)
format_address_none (off_t address ATTRIBUTE_UNUSED)
{
return "";
}
static const char *
format_address_std (long unsigned int address)
format_address_std (off_t address)
{
const char *address_string;
@@ -1076,7 +1059,7 @@ format_address_std (long unsigned int address)
}
static const char *
format_address_label (long unsigned int address)
format_address_label (off_t address)
{
const char *address_string;
assert (output_address_fmt_string != NULL);
@@ -1099,7 +1082,7 @@ format_address_label (long unsigned int address)
only when it has not been padded to length BYTES_PER_BLOCK. */
static void
write_block (long unsigned int current_offset, long unsigned int n_bytes,
write_block (off_t current_offset, off_t n_bytes,
const char *prev_block, const char *curr_block)
{
static int first = 1;
@@ -1264,7 +1247,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
{
int err;
assert (n > 0 && n <= bytes_per_block);
assert (0 < n && n <= bytes_per_block);
*n_bytes_in_buffer = 0;
@@ -1341,7 +1324,7 @@ parse_old_offset (const char *s)
int radix;
off_t offset;
enum strtol_error s_err;
long unsigned int tmp;
uintmax_t tmp;
if (*s == '\0')
return -1;
@@ -1363,12 +1346,15 @@ parse_old_offset (const char *s)
radix = 8;
}
s_err = xstrtoul (s, NULL, radix, &tmp, "Bb");
s_err = xstrtoumax (s, NULL, radix, &tmp, "Bb");
if (s_err != LONGINT_OK)
{
STRTOL_FAIL_WARN (s, _("old-style offset"), s_err);
return -1;
}
if (OFF_T_MAX < tmp)
error (EXIT_FAILURE, 0,
_("%s is larger than the maximum file size on this system"), s);
offset = tmp;
return offset;
}
@@ -1485,15 +1471,14 @@ dump_strings (void)
err = 0;
while (1)
{
unsigned int i;
size_t i;
int c;
/* See if the next `string_min' chars are all printing chars. */
tryline:
if (limit_bytes_to_format
&& address >= (n_bytes_to_skip + max_bytes_to_format -
(off_t) string_min))
&& address >= (n_bytes_to_skip + max_bytes_to_format - string_min))
break;
for (i = 0; i < string_min; i++)
@@ -1590,6 +1575,26 @@ dump_strings (void)
return err;
}
/* There must be exactly one %s format specifier in FORMAT_TEMPLATE.
Return the just-malloc'd result of using sprintf to insert
OFF_T_PRINTF_FORMAT_STRING into FORMAT_TEMPLATE.
Technically, the caller should free this memory, but IMHO it's not
worth it in this case. */
static char *
expand_address_fmt (char const *format_template)
{
size_t len = strlen (format_template);
char *fmt = xmalloc (len + 1);
/* Ensure that the literal we're inserting is no longer than the two-byte
string `%s' it's replacing. There's also the %%, so technically we don't
even need the `+ 1' above. */
assert (OFF_T_PRINTF_FORMAT_STRING[0] == 0
|| OFF_T_PRINTF_FORMAT_STRING[1] == 0
|| OFF_T_PRINTF_FORMAT_STRING[2] == 0);
sprintf (fmt, format_template, OFF_T_PRINTF_FORMAT_STRING);
return fmt;
}
int
main (int argc, char **argv)
{
@@ -1598,7 +1603,7 @@ main (int argc, char **argv)
unsigned int i;
unsigned int l_c_m;
unsigned int address_pad_len;
unsigned long int desired_width;
unsigned long int desired_width IF_LINT (= 0);
int width_specified = 0;
int n_failed_decodes = 0;
int err;
@@ -1641,7 +1646,7 @@ main (int argc, char **argv)
n_specs_allocated = 5;
spec = (struct tspec *) xmalloc (n_specs_allocated * sizeof (struct tspec));
output_address_fmt_string = "%07o";
output_address_fmt_string = expand_address_fmt ("%%07%so");
format_address = format_address_std;
address_pad_len = 7;
flag_dump_strings = 0;
@@ -1649,7 +1654,7 @@ main (int argc, char **argv)
while ((c = getopt_long (argc, argv, "abcdfhilos::xw::A:j:N:t:v",
long_options, NULL)) != -1)
{
unsigned long int tmp;
uintmax_t tmp;
enum strtol_error s_err;
switch (c)
@@ -1661,17 +1666,17 @@ main (int argc, char **argv)
switch (optarg[0])
{
case 'd':
output_address_fmt_string = "%07d";
output_address_fmt_string = expand_address_fmt ("%%07%sd");
format_address = format_address_std;
address_pad_len = 7;
break;
case 'o':
output_address_fmt_string = "%07o";
output_address_fmt_string = expand_address_fmt ("%%07%so");
format_address = format_address_std;
address_pad_len = 7;
break;
case 'x':
output_address_fmt_string = "%06x";
output_address_fmt_string = expand_address_fmt ("%%06%sx");
format_address = format_address_std;
address_pad_len = 6;
break;
@@ -1690,7 +1695,7 @@ it must be one character from [doxn]"),
break;
case 'j':
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
n_bytes_to_skip = tmp;
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("skip argument"), s_err);
@@ -1699,17 +1704,15 @@ it must be one character from [doxn]"),
case 'N':
limit_bytes_to_format = 1;
/* FIXME: if off_t is long long and that's an 8-byte type,
use xstrtouq here. */
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
max_bytes_to_format = tmp;
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("limit argument"), s_err);
if (tmp > LONG_MAX)
if (OFF_T_MAX < tmp)
error (EXIT_FAILURE, 0,
_("specified number of bytes `%s' is larger than \
the maximum\nrepresentable value of type `long'"), optarg);
_("%s is larger than the maximum file size on this system"),
optarg);
break;
case 's':
@@ -1717,11 +1720,18 @@ the maximum\nrepresentable value of type `long'"), optarg);
string_min = 3;
else
{
s_err = xstrtoul (optarg, NULL, 0, &string_min, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("minimum string length"), s_err);
/* The minimum string length may be no larger than SIZE_MAX,
since we may allocate a buffer of this size. */
if (SIZE_MAX < tmp)
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
string_min = tmp;
}
++flag_dump_strings;
flag_dump_strings = 1;
break;
case 't':
@@ -1771,9 +1781,13 @@ the maximum\nrepresentable value of type `long'"), optarg);
}
else
{
s_err = xstrtoul (optarg, NULL, 10, &desired_width, "");
uintmax_t w_tmp;
s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, "");
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("width specification"), s_err);
if (ULONG_MAX < w_tmp)
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
desired_width = w_tmp;
}
break;
@@ -1875,7 +1889,7 @@ the maximum\nrepresentable value of type `long'"), optarg);
if (output_address_fmt_string == NULL)
{
output_address_fmt_string = "(%07o)";
output_address_fmt_string = expand_address_fmt ("(%%07%so)");
format_address = format_address_std;
}
else

View File

@@ -147,7 +147,10 @@ valid_format (const char *fmt)
fmt += strspn (fmt, "0123456789");
if (*fmt == '.')
fmt += strspn (++fmt, "0123456789");
{
++fmt;
fmt += strspn (fmt, "0123456789");
}
}
if (!(*fmt == 'e' || *fmt == 'f' || *fmt == 'g'))

View File

@@ -32,8 +32,10 @@
#include "long-options.h"
#include "error.h"
#include "hard-locale.h"
#include "human.h"
#include "memcoll.h"
#include "xalloc.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "sort"
@@ -99,6 +101,8 @@ static int hard_LC_TIME;
#endif
#define NONZERO(x) (x != 0)
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
@@ -109,7 +113,7 @@ int eolchar = '\n';
struct line
{
char *text; /* Text of the line. */
int length; /* Length including final newline. */
size_t length; /* Length including final newline. */
char *keybeg; /* Start of first key. */
char *keylim; /* Limit of first key. */
};
@@ -118,29 +122,29 @@ struct line
struct lines
{
struct line *lines; /* Dynamically allocated array of lines. */
int used; /* Number of slots used. */
int alloc; /* Number of slots allocated. */
int limit; /* Max number of slots to allocate. */
size_t used; /* Number of slots used. */
size_t alloc; /* Number of slots allocated. */
size_t limit; /* Max number of slots to allocate. */
};
/* Input buffers. */
struct buffer
{
char *buf; /* Dynamically allocated buffer. */
int used; /* Number of bytes used. */
int alloc; /* Number of bytes allocated. */
int left; /* Number of bytes left from previous reads. */
int newline_free; /* Number of left bytes that are known
size_t used; /* Number of bytes used. */
size_t alloc; /* Number of bytes allocated. */
size_t left; /* Number of bytes left from previous reads. */
size_t newline_free; /* Number of left bytes that are known
to be newline-free. */
};
struct keyfield
{
int sword; /* Zero-origin 'word' to start at. */
int schar; /* Additional characters to skip. */
size_t sword; /* Zero-origin 'word' to start at. */
size_t schar; /* Additional characters to skip. */
int skipsblanks; /* Skip leading white space at start. */
int eword; /* Zero-origin first word after field. */
int echar; /* Additional characters in field. */
size_t eword; /* Zero-origin first word after field. */
size_t echar; /* Additional characters in field. */
int skipeblanks; /* Skip trailing white space at finish. */
int *ignore; /* Boolean array of characters to ignore. */
char *translate; /* Translation applied to characters. */
@@ -214,14 +218,14 @@ static MONTHTAB_CONST struct month monthtab[] =
/* Initial buffer size for in-core sorting. The buffer will grow only
if a line longer than this is seen. */
#define SORTALLOC (8 * 1024 * 1024)
static int const sortalloc = SORTALLOC;
static size_t const sortalloc = SORTALLOC;
/* Initial buffer size for in core merge buffers. Bear in mind that
up to NMERGE * mergealloc bytes may be allocated for merge buffers. */
static int const mergealloc = SORTALLOC / NMERGE / 2;
static size_t const mergealloc = SORTALLOC / NMERGE / 2;
/* Guess of average line length. */
static int const linelength = 30;
static size_t const linelength = 30;
/* Maximum number of elements for the array(s) of struct line's, in bytes. */
#define LINEALLOC (SORTALLOC / 2)
@@ -557,7 +561,7 @@ inittables (void)
/* Initialize BUF, allocating ALLOC bytes initially. */
static void
initbuf (struct buffer *buf, int alloc)
initbuf (struct buffer *buf, size_t alloc)
{
buf->alloc = alloc;
buf->buf = xmalloc (buf->alloc);
@@ -569,7 +573,7 @@ initbuf (struct buffer *buf, int alloc)
file wasn't terminated by a newline, supply one. Return a count
of bytes buffered. */
static int
static size_t
fillbuf (struct buffer *buf, FILE *fp)
{
if (buf->used != buf->left)
@@ -580,10 +584,12 @@ fillbuf (struct buffer *buf, FILE *fp)
while (!feof (fp))
{
int cc;
size_t cc;
if (buf->used == buf->alloc)
{
buf->alloc *= 2;
if (buf->alloc < buf->used)
xalloc_die ();
buf->buf = xrealloc (buf->buf, buf->alloc);
}
cc = fread (buf->buf + buf->used, 1, buf->alloc - buf->used, fp);
@@ -608,6 +614,8 @@ fillbuf (struct buffer *buf, FILE *fp)
if (buf->newline_free != buf->used)
return buf->used;
buf->alloc *= 2;
if (buf->alloc < buf->used)
xalloc_die ();
buf->buf = xrealloc (buf->buf, buf->alloc);
}
buf->buf[buf->used++] = eolchar;
@@ -621,9 +629,11 @@ fillbuf (struct buffer *buf, FILE *fp)
for, ever. */
static void
initlines (struct lines *lines, int alloc, int limit)
initlines (struct lines *lines, size_t alloc, size_t limit)
{
lines->alloc = alloc;
if (SIZE_MAX / sizeof (struct line) < alloc)
xalloc_die ();
lines->lines = (struct line *) xmalloc (lines->alloc * sizeof (struct line));
lines->used = 0;
lines->limit = limit;
@@ -636,7 +646,8 @@ static char *
begfield (const struct line *line, const struct keyfield *key)
{
register char *ptr = line->text, *lim = ptr + line->length - 1;
register int sword = key->sword, schar = key->schar;
register size_t sword = key->sword;
register size_t schar = key->schar;
if (tab)
while (ptr < lim && sword--)
@@ -659,7 +670,7 @@ begfield (const struct line *line, const struct keyfield *key)
while (ptr < lim && blanks[UCHAR (*ptr)])
++ptr;
if (ptr + schar <= lim)
if (schar < lim - ptr)
ptr += schar;
else
ptr = lim;
@@ -674,7 +685,7 @@ static char *
limfield (const struct line *line, const struct keyfield *key)
{
register char *ptr = line->text, *lim = ptr + line->length - 1;
register int eword = key->eword, echar = key->echar;
register size_t eword = key->eword, echar = key->echar;
/* Note: from the POSIX spec:
The leading field separator itself is included in
@@ -692,7 +703,7 @@ limfield (const struct line *line, const struct keyfield *key)
{
while (ptr < lim && *ptr != tab)
++ptr;
if (ptr < lim && (eword || echar > 0))
if (ptr < lim && (eword | echar))
++ptr;
}
else
@@ -761,7 +772,7 @@ limfield (const struct line *line, const struct keyfield *key)
++ptr;
/* Advance PTR by ECHAR (if possible), but no further than LIM. */
if (ptr + echar <= lim)
if (echar < lim - ptr)
ptr += echar;
else
ptr = lim;
@@ -796,6 +807,8 @@ findlines (struct buffer *buf, struct lines *lines)
if (lines->used == lines->alloc)
{
lines->alloc *= 2;
if (SIZE_MAX / sizeof (struct line) < lines->alloc)
xalloc_die ();
lines->lines = (struct line *)
xrealloc ((char *) lines->lines,
lines->alloc * sizeof (struct line));
@@ -808,9 +821,9 @@ findlines (struct buffer *buf, struct lines *lines)
if (key)
{
/* Precompute the position of the first key for efficiency. */
line->keylim = 0 <= key->eword ? limfield (line, key) : ptr;
line->keylim = (key->eword == -1 ? ptr : limfield (line, key));
if (key->sword >= 0)
if (key->sword != -1)
line->keybeg = begfield (line, key);
else
{
@@ -902,7 +915,8 @@ fraccompare (register const char *a, register const char *b)
static int
numcompare (register const char *a, register const char *b)
{
register int tmpa, tmpb, loga, logb, tmp;
register int tmpa, tmpb, tmp;
register size_t loga, logb;
tmpa = *a;
tmpb = *b;
@@ -965,8 +979,8 @@ numcompare (register const char *a, register const char *b)
tmpb = *++b;
while (IS_THOUSANDS_SEP (tmpb));
if (logb - loga != 0)
return logb - loga;
if (loga != logb)
return loga < logb ? 1 : -1;
if (!loga)
return 0;
@@ -1027,8 +1041,8 @@ numcompare (register const char *a, register const char *b)
tmpb = *++b;
while (IS_THOUSANDS_SEP (tmpb));
if (loga - logb != 0)
return loga - logb;
if (loga != logb)
return loga < logb ? -1 : 1;
if (!loga)
return 0;
@@ -1070,10 +1084,11 @@ general_numcompare (const char *sa, const char *sb)
Return 0 if the name in S is not recognized. */
static int
getmonth (const char *s, int len)
getmonth (const char *s, size_t len)
{
char *month;
register int i, lo = 0, hi = MONTHS_PER_YEAR, result;
register size_t i;
register int lo = 0, hi = MONTHS_PER_YEAR, result;
while (len > 0 && blanks[UCHAR (*s)])
{
@@ -1123,7 +1138,8 @@ keycompare (const struct line *a, const struct line *b)
register char *lima = a->keylim;
register char *limb = b->keylim;
int diff, lena, lenb;
int diff;
size_t lena, lenb;
for (;;)
{
@@ -1131,11 +1147,8 @@ keycompare (const struct line *a, const struct line *b)
register int *ignore = key->ignore;
/* Find the lengths. */
lena = lima - texta, lenb = limb - textb;
if (lena < 0)
lena = 0;
if (lenb < 0)
lenb = 0;
lena = lima <= texta ? 0 : lima - texta;
lenb = limb <= textb ? 0 : limb - textb;
if (key->skipeblanks)
{
@@ -1168,7 +1181,7 @@ keycompare (const struct line *a, const struct line *b)
{
char *copy_a = (char *) alloca (lena + 1 + lenb + 1);
char *copy_b = copy_a + lena + 1;
int new_len_a, new_len_b, i;
size_t new_len_a, new_len_b, i;
/* Ignore and/or translate chars before comparing. */
for (new_len_a = new_len_b = i = 0; i < max (lena, lenb); i++)
@@ -1194,7 +1207,7 @@ keycompare (const struct line *a, const struct line *b)
diff = memcoll (copy_a, new_len_a, copy_b, new_len_b);
}
else if (lena == 0)
diff = -lenb;
diff = - NONZERO (lenb);
else if (lenb == 0)
goto greater;
else
@@ -1232,7 +1245,7 @@ keycompare (const struct line *a, const struct line *b)
CMP_WITH_IGNORE (UCHAR (*texta), UCHAR (*textb));
}
else if (lena == 0)
diff = -lenb;
diff = - NONZERO (lenb);
else if (lenb == 0)
goto greater;
else
@@ -1253,7 +1266,7 @@ keycompare (const struct line *a, const struct line *b)
if (diff)
goto not_equal;
}
diff = lena - lenb;
diff = lena < lenb ? -1 : lena != lenb;
}
if (diff)
@@ -1264,12 +1277,12 @@ keycompare (const struct line *a, const struct line *b)
break;
/* Find the beginning and limit of the next field. */
if (key->eword >= 0)
if (key->eword != -1)
lima = limfield (a, key), limb = limfield (b, key);
else
lima = a->text + a->length - 1, limb = b->text + b->length - 1;
if (key->sword >= 0)
if (key->sword != -1)
texta = begfield (a, key), textb = begfield (b, key);
else
{
@@ -1298,7 +1311,8 @@ keycompare (const struct line *a, const struct line *b)
static int
compare (register const struct line *a, register const struct line *b)
{
int diff, alen, blen;
int diff;
size_t alen, blen;
/* First try to compare on the specified keys (if any).
The only two cases with no key at all are unadorned sort,
@@ -1316,23 +1330,23 @@ compare (register const struct line *a, register const struct line *b)
alen = a->length - 1, blen = b->length - 1;
if (alen == 0)
diff = - blen;
diff = - NONZERO (blen);
else if (blen == 0)
diff = alen;
diff = NONZERO (alen);
#ifdef ENABLE_NLS
else if (hard_LC_COLLATE)
diff = memcoll (a->text, alen, b->text, blen);
#endif
else if (! (diff = memcmp (a->text, b->text, min (alen, blen))))
diff = alen - blen;
diff = alen < blen ? -1 : alen != blen;
return reverse ? -diff : diff;
}
/* Check that the lines read from the given FP come in order. Print a
diagnostic (FILE_NAME, line number, contents of line) to stderr and return
the line number of the first out-of-order line (counting from 1) if they
are not in order. Otherwise, print no diagnostic and return zero. */
one if they are not in order. Otherwise, print no diagnostic
and return zero. */
static int
checkfp (FILE *fp, const char *file_name)
@@ -1340,11 +1354,11 @@ checkfp (FILE *fp, const char *file_name)
struct buffer buf; /* Input buffer. */
struct lines lines; /* Lines scanned from the buffer. */
struct line temp; /* Copy of previous line. */
int cc; /* Character count. */
int alloc;
int line_number = 1;
size_t cc; /* Character count. */
size_t alloc;
uintmax_t line_number = 1;
struct line *disorder_line IF_LINT (= NULL);
int disorder_line_number = 0;
uintmax_t disorder_line_number = 0;
struct keyfield *key = keylist;
initbuf (&buf, mergealloc);
@@ -1363,16 +1377,16 @@ checkfp (FILE *fp, const char *file_name)
{
struct line *prev_line; /* Pointer to previous line. */
int cmp; /* Result of calling compare. */
int i;
size_t i;
/* Compare each line in the buffer with its successor. */
for (i = 0; i < lines.used - 1; ++i)
for (i = 1; i < lines.used; ++i)
{
cmp = compare (&lines.lines[i], &lines.lines[i + 1]);
cmp = compare (&lines.lines[i - 1], &lines.lines[i]);
if ((unique && cmp >= 0) || (cmp > 0))
{
disorder_line = &lines.lines[i + 1];
disorder_line_number = line_number + i + 1;
disorder_line = &lines.lines[i];
disorder_line_number = line_number + i;
goto finish;
}
}
@@ -1383,8 +1397,14 @@ checkfp (FILE *fp, const char *file_name)
prev_line = lines.lines + (lines.used - 1);
if (alloc < prev_line->length)
{
while ((alloc *= 2) < prev_line->length)
continue;
do
{
if (alloc * 2 < alloc)
xalloc_die ();
alloc *= 2;
}
while (alloc < prev_line->length);
temp.text = xrealloc (temp.text, alloc);
}
memcpy (temp.text, prev_line->text, prev_line->length);
@@ -1416,8 +1436,9 @@ finish:
if (disorder_line_number)
{
fprintf (stderr, _("%s: %s:%d: disorder: "), program_name, file_name,
disorder_line_number);
char hr_buf[LONGEST_HUMAN_READABLE + 1];
fprintf (stderr, _("%s: %s:%s: disorder: "), program_name, file_name,
human_readable (disorder_line_number, hr_buf, 1, 1));
write_bytes (disorder_line->text, disorder_line->length, stderr,
_("standard error"));
}
@@ -1425,7 +1446,7 @@ finish:
free (buf.buf);
free ((char *) lines.lines);
free (temp.text);
return disorder_line_number;
return NONZERO (disorder_line_number);
}
/* Merge lines from FPS onto OFP. NFPS cannot be greater than NMERGE.
@@ -1439,8 +1460,8 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
struct line saved; /* Saved line storage for unique check. */
struct line const *savedline IF_LINT (= NULL);
/* &saved if there is a saved line. */
int savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
int cur[NMERGE]; /* Current line in each line table. */
size_t savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
size_t cur[NMERGE]; /* Current line in each line table. */
int ord[NMERGE]; /* Table representing a permutation of fps,
such that lines[ord[0]].lines[cur[ord[0]]]
is the smallest line and will be next
@@ -1585,10 +1606,10 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
/* Sort the array LINES with NLINES members, using TEMP for temporary space. */
static void
sortlines (struct line *lines, int nlines, struct line *temp)
sortlines (struct line *lines, size_t nlines, struct line *temp)
{
register struct line *lo, *hi, *t;
register int nlo, nhi;
register size_t nlo, nhi;
if (nlines == 2)
{
@@ -1638,10 +1659,7 @@ check (char **files, int nfiles)
for (i = 0; i < nfiles; ++i)
{
fp = xfopen (files[i], "r");
if (checkfp (fp, files[i]))
{
++disorders;
}
disorders += checkfp (fp, files[i]);
}
return disorders;
}
@@ -1694,8 +1712,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
{
struct buffer buf;
struct lines lines;
struct line *tmp;
int i, ntmp;
struct line *tmp = NULL;
size_t ntmp = 0;
FILE *fp, *tfp;
struct tempnode *node;
int n_temp_files = 0;
@@ -1704,8 +1722,6 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
initbuf (&buf, sortalloc);
initlines (&lines, sortalloc / linelength + 1,
LINEALLOC / sizeof (struct line));
ntmp = lines.alloc;
tmp = (struct line *) xmalloc (ntmp * sizeof (struct line));
while (nfiles--)
{
@@ -1714,6 +1730,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
fp = xfopen (*files++, "r");
while (fillbuf (&buf, fp))
{
size_t i;
if (nfiles && buf.used != buf.alloc && feof (fp))
{
/* End of file, but there is more input and buffer room.
@@ -1726,8 +1744,13 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
findlines (&buf, &lines);
if (ntmp < lines.used)
{
while ((ntmp *= 2) < lines.used)
continue;
if (ntmp == 0)
ntmp = lines.used;
else
while ((ntmp *= 2) < lines.used)
continue;
if (SIZE_MAX / sizeof (struct line) < ntmp)
xalloc_die ();
tmp = (struct line *)
xrealloc ((char *) tmp, ntmp * sizeof (struct line));
}
@@ -1759,8 +1782,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
if (n_temp_files)
{
int i = n_temp_files;
tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *));
i = n_temp_files;
for (node = temphead.next; i > 0; node = node->next)
tempfiles[--i] = node->name;
merge (tempfiles, n_temp_files, ofp, output_file);
@@ -1787,6 +1810,39 @@ badfieldspec (const char *s)
error (SORT_FAILURE, 0, _("invalid field specification `%s'"), s);
}
/* Parse the leading integer in STRING and store the resulting value
(which must fit into size_t) into *VAL. Return the address of the
suffix after the integer. */
static char const *
parse_field_count (char const *string, size_t *val)
{
/* '@' can't possibly be a valid suffix; return &bad_suffix so that
the caller will eventually invoke badfieldspec. */
static char const invalid_suffix = '@';
char *suffix;
uintmax_t n;
switch (xstrtoumax (string, &suffix, 10, &n, ""))
{
case LONGINT_OK:
case LONGINT_INVALID_SUFFIX_CHAR:
*val = n;
if (*val == n)
break;
/* Fall through. */
case LONGINT_OVERFLOW:
error (0, 0, _("count `%.*s' too large"),
(int) (suffix - string), string);
return &invalid_suffix;
case LONGINT_INVALID:
error (0, 0, _("invalid count at start of `%s'"), string);
return &invalid_suffix;
}
return suffix;
}
/* Handle interrupts and hangups. */
static void
@@ -1865,10 +1921,11 @@ int
main (int argc, char **argv)
{
struct keyfield *key = NULL, gkey;
char *s;
int i, t, t2;
char const *s;
int i;
int checkonly = 0, mergeonly = 0, nfiles = 0;
char *minus = "-", *outfile = minus, **files, *tmp;
char *minus = "-", **files, *tmp;
char const *outfile = minus;
FILE *ofp;
#ifdef SA_NOCLDSTOP
struct sigaction oldact, newact;
@@ -1966,18 +2023,10 @@ main (int argc, char **argv)
s = argv[i] + 1;
if (! (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1]))))
badfieldspec (argv[i]);
for (t = 0; ISDIGIT (*s); ++s)
t = 10 * t + *s - '0';
t2 = 0;
s = parse_field_count (s, &key->sword);
if (*s == '.')
for (++s; ISDIGIT (*s); ++s)
t2 = 10 * t2 + *s - '0';
if (t2 || t)
{
key->sword = t;
key->schar = t2;
}
else
s = parse_field_count (s + 1, &key->schar);
if (! (key->sword | key->schar))
key->sword = -1;
s = set_ordering (s, key, bl_start);
if (*s)
@@ -1995,14 +2044,9 @@ main (int argc, char **argv)
key specifiers,\nthe +POS specifier must come first"));
usage (SORT_FAILURE);
}
for (t = 0; ISDIGIT (*s); ++s)
t = t * 10 + *s - '0';
t2 = 0;
s = parse_field_count (s, &key->eword);
if (*s == '.')
for (++s; ISDIGIT (*s); ++s)
t2 = t2 * 10 + *s - '0';
key->eword = t;
key->echar = t2;
s = parse_field_count (s + 1, &key->echar);
s = set_ordering (s, key, bl_end);
if (*s)
badfieldspec (argv[i]);
@@ -2039,17 +2083,14 @@ key specifiers,\nthe +POS specifier must come first"));
/* Get POS1. */
if (!ISDIGIT (*s))
badfieldspec (argv[i]);
for (t = 0; ISDIGIT (*s); ++s)
t = 10 * t + *s - '0';
if (t == 0)
s = parse_field_count (s, &key->sword);
if (! key->sword--)
{
/* Provoke with `sort -k0' */
error (0, 0, _("the starting field number argument \
to the `-k' option must be positive"));
badfieldspec (argv[i]);
}
--t;
t2 = 0;
if (*s == '.')
{
if (!ISDIGIT (s[1]))
@@ -2059,23 +2100,16 @@ to the `-k' option must be positive"));
lacks following character offset"));
badfieldspec (argv[i]);
}
for (++s; ISDIGIT (*s); ++s)
t2 = 10 * t2 + *s - '0';
if (t2 == 0)
s = parse_field_count (s + 1, &key->schar);
if (! key->schar--)
{
/* Provoke with `sort -k1.0' */
error (0, 0, _("starting field character offset \
argument to the `-k' option\nmust be positive"));
badfieldspec (argv[i]);
}
--t2;
}
if (t2 || t)
{
key->sword = t;
key->schar = t2;
}
else
if (! (key->sword | key->schar))
key->sword = -1;
s = set_ordering (s, key, bl_start);
if (*s == 0)
@@ -2097,17 +2131,14 @@ lacks following field spec"));
badfieldspec (argv[i]);
}
/* Get POS2. */
for (t = 0; ISDIGIT (*s); ++s)
t = t * 10 + *s - '0';
if (t == 0)
s = parse_field_count (s, &key->eword);
if (! key->eword--)
{
/* Provoke with `sort -k1,0' */
error (0, 0, _("ending field number argument \
to the `-k' option must be positive"));
badfieldspec (argv[i]);
}
--t;
t2 = 0;
if (*s == '.')
{
if (!ISDIGIT (s[1]))
@@ -2117,16 +2148,13 @@ to the `-k' option must be positive"));
but lacks following character offset"));
badfieldspec (argv[i]);
}
for (++s; ISDIGIT (*s); ++s)
t2 = t2 * 10 + *s - '0';
s = parse_field_count (s + 1, &key->echar);
}
else
{
/* `-k 2,3' is equivalent to `+1 -3'. */
++t;
key->eword++;
}
key->eword = t;
key->echar = t2;
s = set_ordering (s, key, bl_end);
if (*s)
badfieldspec (argv[i]);

View File

@@ -167,6 +167,10 @@ char *alloca ();
# include <sys/exceptn.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#include <ctype.h>
/* Jim Meyering writes:
@@ -519,6 +523,18 @@ enum
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
#endif
#ifndef SIZE_MAX
# define SIZE_MAX TYPE_MAXIMUM (size_t)
#endif
#ifndef OFF_T_MIN
# define OFF_T_MIN TYPE_MINIMUM (off_t)
#endif
#ifndef OFF_T_MAX
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
#endif
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
@@ -531,6 +547,10 @@ enum
# define PID_T_MAX TYPE_MAXIMUM (pid_t)
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
#ifdef lint
# define IF_LINT(Code) Code

View File

@@ -44,14 +44,6 @@
#define AUTHORS \
"Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering"
#ifndef OFF_T_MIN
# define OFF_T_MIN TYPE_MINIMUM (off_t)
#endif
#ifndef OFF_T_MAX
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
#endif
#ifndef ENOSYS
/* Some systems don't have ENOSYS -- this should be a big enough
value that no valid errno value will match it. */
@@ -1145,6 +1137,9 @@ tail_file (struct File_spec *f, off_t n_units)
{
f->fd = -1;
f->errnum = errno;
f->ignore = 0;
f->ino = 0;
f->dev = 0;
}
error (0, errno, "%s", pretty_name (f));
errors = 1;
@@ -1382,8 +1377,8 @@ parse_options (int argc, char **argv,
{
strtol_error s_err;
unsigned long int tmp_ulong;
s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "bkm");
uintmax_t n;
s_err = xstrtoumax (optarg, NULL, 10, &n, "bkm");
if (s_err == LONGINT_INVALID)
{
error (EXIT_FAILURE, 0, "%s: %s", optarg,
@@ -1391,14 +1386,16 @@ parse_options (int argc, char **argv,
? _("invalid number of lines")
: _("invalid number of bytes")));
}
if (s_err != LONGINT_OK || tmp_ulong > OFF_T_MAX)
{
error (EXIT_FAILURE, 0,
_("%s: %s is so large that it is not representable"),
optarg,
c == 'n' ? _("number of lines") : _("number of bytes"));
}
*n_units = (off_t) tmp_ulong;
if (s_err != LONGINT_OK)
error (EXIT_FAILURE, 0,
_("%s: is so large that it is not representable"), optarg);
if (OFF_T_MAX < n)
error (EXIT_FAILURE, 0,
_("%s is larger than the maximum file size on this system"),
optarg);
*n_units = (off_t) n;
}
break;

View File

@@ -9,4 +9,4 @@ TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH \
PROG=dd
TESTS = misc not-rewound skip-seek
TESTS = misc not-rewound skip-seek skip-seek2

View File

@@ -126,7 +126,7 @@ TESTS_ENVIRONMENT = \
PROG=dd
TESTS = misc not-rewound skip-seek
TESTS = misc not-rewound skip-seek skip-seek2
subdir = tests/dd
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h

View File

@@ -34,14 +34,6 @@ my @Tests =
{ERR=> "3+0 records in\n3+0 records out\n"},
{CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
],
[
'2', qw (bs=5 skip=1B seek=2B conv=notrunc count=1 of=@AUX@ < ),
{IN=> '0123456789abcdef'},
{AUX=> 'zyxwvutsrqponmlkji'},
{OUT=> ''},
{ERR=> "1+0 records in\n1+0 records out\n"},
{CMP=> ['zy12345srqponmlkji', {'@AUX@'=> undef}]},
],
[
'3', qw (bs=5 skip=1 seek=1 conv=notrunc count=1 of=@AUX@ < ),
{IN=> '0123456789abcdef'},

40
tests/dd/skip-seek2 Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
# show how to skip an amount that is smaller than the nominal block size.
# There's a more realistic example in the documentation.
if test "$VERBOSE" = yes; then
set -x
dd --version
fi
pwd=`pwd`
tmp=skip-seek.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
(exit 1); exit
fi
fail=0
echo LA:3456789abcdef > in || fail=1
(dd bs=1 skip=3 count=0 && dd bs=5) < in > out 2> /dev/null || fail=1
case `cat out` in
3456789abcdef) ;;
*) fail=1 ;;
esac
echo LA:3456789abcdef > in || fail=1
(dd bs=1 skip=3 count=0 && dd bs=5 count=2) < in > out 2> /dev/null || fail=1
case `cat out` in
3456789abc) ;;
*) fail=1 ;;
esac
(exit $fail); exit

View File

@@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = rt-1 time-1 symlink-slash
TESTS = rt-1 time-1 symlink-slash follow-slink
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \

View File

@@ -118,7 +118,7 @@ l = @l@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = rt-1 time-1 symlink-slash
TESTS = rt-1 time-1 symlink-slash follow-slink
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \

28
tests/ls/follow-slink Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
# make sure ls -L always follows symlinks
if test "$VERBOSE" = yes; then
set -x
ls --version
fi
pwd=`pwd`
tmp=follow-sl.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
ln -s link link || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
(exit 1); exit
fi
fail=0
ls -L link 2> /dev/null && fail=1
(exit $fail); exit

View File

@@ -1,5 +1,6 @@
#!/bin/sh
# make sure --parents works with a trailing slash
# Ensure that mkdir works with arguments specified with and without
# a trailing slash.
if test "$VERBOSE" = yes; then
set -x
@@ -25,4 +26,8 @@ fail=0
mkdir -p dir/ || fail=1
test -d dir || fail=1
# This failed on NetBSD for fileutils-4.0.33.
mkdir d2/ || fail=1
test -d d2 || fail=1
(exit $fail); exit

View File

@@ -9,4 +9,4 @@ TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH \
PROG=tail
TESTS = assert
TESTS = assert assert-2

46
tests/tail-2/assert-2 Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/sh
# This variant of `assert' would get a UMR reliably in 2.0.9.
# Due to a race condition in the test, the `assert' script would get
# the UMR on Solaris only some of the time, and not at all on Linux/GNU.
if test "$VERBOSE" = yes; then
set -x
tail --version
fi
tmp=tail-as2.$$
pwd=`pwd`
trap "cd $pwd; rm -rf $tmp" 0 1 2 3 15
test_failure=0
mkdir $tmp || test_failure=1
cd $tmp || test_failure=1
if test $test_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
ok='ok ok ok'
touch a
tail --follow=name a foo > err 2>&1 &
tail_pid=$!
# Arrange for the tail process to die after 12 seconds.
(sleep 12; kill $tail_pid) &
echo $ok > f
echo sleeping for 7 seconds...
sleep 7
mv f foo
# echo waiting....
wait
case "`cat err`" in
*$ok) fail=0;;
*) fail=1;;
esac
test $fail = 1 && cat err
exit $fail