Jim Meyering [Sun, 30 Jul 1995 05:02:37 +0000 (05:02 +0000)]
(check): Print `disorder on...' message on standard error, not stdout.
This is a minor concession to POSIX which says `no output shall be produced'.
(main): Fix -k so it works. -k 2,3 was being treated like -k 2.
Reported by Marcus Daniels <marcus@sysc.pdx.edu>.
Jim Meyering [Thu, 27 Jul 1995 03:56:35 +0000 (03:56 +0000)]
(tail_bytes) [from_start]: For regular files, seek
relative to the initial input file pointer position, not
necessarily from the beginning of the file.
[!from_start]: Don't back up past the initial position of the
input file pointer.
(tail_lines): Call file_lines only if FD refers to a regular file
with its file pointer positioned at beginning of file. Otherwise,
call pipe_lines. This is a kludge. Once there's a decent test
suite, fix this properly.
Before, (echo 1; echo 2) > k; sh -c 'read x; tail' < k
would output both lines of the input file even though the first had
already been read. Reported by John Roll (john@panic.harvard.edu).
Jim Meyering [Thu, 27 Jul 1995 03:45:11 +0000 (03:45 +0000)]
(have_read_stdin): New global variable.
(md5_file, md5_check): Set it.
(main): Use it.
[OPENOPTS]: Depend explicitly on BINARY.
(md5_file): Take a new parameter, MD5_RESULT, and no longer
generate output.
(md5_check): Invoke md5_file instead of calling fopen directly.
When giving a diagnostic for a line with invalid format, also report
the line number.
(main): Generate output after a successful md5_file call.
[in many places]: Upon detection of an error, rather than exiting
immediately, issue a diagnostic, note that an error occurred and
exit later.
Jim Meyering [Fri, 21 Jul 1995 06:18:58 +0000 (06:18 +0000)]
(md5_file): New function -- extracted from main.
(main): Call the new function instead of doing all that in an if stmt.
Always use "%s" format rather than raw filename as format argument
in printf-style functions like error. Otherwise, filenames containing
e.g. `%s' lose.
Remove all traces of `old format'. There is only one format now.
The compatible one.
Jim Meyering [Fri, 21 Jul 1995 04:45:40 +0000 (04:45 +0000)]
Use EXIT_FAILURE and EXIT_SUCCESS.
(main): Report an error if md5_stream fails. Otherwise, running
`md5sum dir-on-mounted-filesystem' always reported the checksum
for an empty file. Now it gets the `is a directory' error.
Greg McGary reported that the released version got stuck in an
infinite loop with such arguments.
Jim Meyering [Sun, 16 Jul 1995 05:47:55 +0000 (05:47 +0000)]
Add #else block after #ifdef VMS.
(main): Rename local variable.
Add FIXME: allow newlines in filenames.
Detect and report failed fclose calls on stdout and checkfile_stream.
Jim Meyering [Sun, 16 Jul 1995 05:39:09 +0000 (05:39 +0000)]
(build_spec_list): Declare CLOSING_DELIM_IDX and CLOSING_BRACKET_IDX to
be of type size_t, not int.
(main): Declare NR and CHARS_READ to be of type long, not int.
Jim Meyering [Wed, 12 Jul 1995 03:13:40 +0000 (03:13 +0000)]
(unqote): Comment out unreachable break stmts.
(append_range): Declare FIRST and LAST parameters to be unsigned int,
not size_t.
(find_closing_delim): Clean up interface, separating boolean success
indicator and index.
(find_bracketed_repeat): Likewise.
(build_spec_list): Adapt to use new interfaces.
Jim Meyering [Wed, 12 Jul 1995 02:59:44 +0000 (02:59 +0000)]
(tail): Explicitly cast to long the N_UNITS argumennt in
call to tail_lines. Otherwise, NetBSD lost because N_UNITS (of type
off_t, a 64-bit type on NetBSD) wasn't converted to the target type,
long. Reported by Dan Hagerty (hag@gnu.ai.it.edu).
Jim Meyering [Sun, 9 Jul 1995 16:42:31 +0000 (16:42 +0000)]
(main): When using obsolescent +pos -pos syntax, allow
omission of field spec only when character offset is specified.
Otherwise, -. +. would be accepted.
Jim Meyering [Sun, 9 Jul 1995 02:25:11 +0000 (02:25 +0000)]
(main): Allow field spec, M, to be omitted in +M.N or -M.N
position specification. Omitting M is equivalent to specifying `0'
for M. From Rick Sladkey (jrs@world.std.com).
Jim Meyering [Fri, 7 Jul 1995 04:46:03 +0000 (04:46 +0000)]
(dump): Correct loop-termination criterion.
Before, running `printf 1234| ./od --width=4 --read-bytes=4'
printed output for 8 bytes -- the last four were garbage.
This happened only when the dump limit, N, was specified (with
--read-bytes=N) and N was a multiple of bytes_per_block
(usually 16, but 4 in this example). From Andreas Schwab.
Jim Meyering [Mon, 3 Jul 1995 03:10:59 +0000 (03:10 +0000)]
(split_3): Rewrite to parse Plumb/Lankester format as well.
(main): Write (de facto) standard Plumb/Lankester format.
New option: --quiet.
Check option no longer takes an argument.
When checking, exit status reflects success.
Jim Meyering [Sun, 25 Jun 1995 01:44:35 +0000 (01:44 +0000)]
(parse_group): Use xstrtoul instead of isnumber; the latter would
silently overflow, accepting a group id larger than INT_MAX.
(isnumber): Remove now-unused static function.
(change_file_group) [MAXUID]: Give a more descriptive message
when numeric group id is larger than MAXUID.
Jim Meyering [Sat, 24 Jun 1995 21:07:55 +0000 (21:07 +0000)]
(read_input): Rename paramater MAX to MAX_N_BYTES. To avoid potential
conflict with max macro from some system's header files and bad pre-ANSI
compilers.
Jim Meyering [Thu, 22 Jun 1995 03:59:55 +0000 (03:59 +0000)]
[word]: Redefine. Otherwise, systems (Unicos for one) with
headers that define `word' to be a type get syntax errors because
of the variable by the same name.
Jim Meyering [Tue, 20 Jun 1995 12:00:55 +0000 (12:00 +0000)]
(md5_file): Initialize two elements of LEN portably,
rather than with ANSI aggregate initialization. Reported by
Edzer Pebesma <Edzer.Pebesma@rivm.nl>.
Jim Meyering [Sun, 18 Jun 1995 14:21:50 +0000 (14:21 +0000)]
(process_buffer): Copy values from struct into
individual local variables before performing computation on them,
then copy results back into returned struct. Solely for better
optimization by compilers that can't keep struct members in
registers. From Ulrich Drepper.
Jim Meyering [Fri, 16 Jun 1995 03:14:19 +0000 (03:14 +0000)]
Remove unnecessary uses of `defined' in #if* tests.
Don't use #elif. Some older compilers don't grok it.
(split_3): New function to parse out sum, flag, and filename
when reading check file.
(hex_digits): Remove length parameter since string parameter is
now nul-terminated.
(main): Don't allocate separate arrays for filename and sum
when checking. Get pointers into line buffer with split_3 instead
of using sscanf.
Jim Meyering [Thu, 15 Jun 1995 03:15:37 +0000 (03:15 +0000)]
Don't use #elif. Some old C compilers don't recognize it.
(hex_digits): New function.
(result): Give ctx parameter the `const' attribute.
(usage): Rewrite to make it clearer that there are three modes.
(main): Process all options before generating any output.
In particular, collect all --string options rather than operating
on them as they are encountered.
Allow --check=-. Before it tried to open the file named `-'.
Detect bogus input when --check'ing: non-hex, non-[tb] flag.
Map to lower case all hex digits read from check file.
Jim Meyering [Wed, 14 Jun 1995 02:23:48 +0000 (02:23 +0000)]
[NDEBUG]: Define it to disable assertions.
(is_char_class_member): Set a variable in each branch of switch stmt
and return that value after the switch (rather than returning directly
from every branch).
(unquote): More int->size_t changes.
(build_spec_list): More int->size_t changes.
Be very careful about comparison now that variables are unsigned:
Use i + 2 < len rather than i < len - 2. The latter failed for len < 2.