Commit Graph

83 Commits

Author SHA1 Message Date
Jim Meyering 6bcd4b08ba (main): Call initialize_main. 2003-06-17 18:13:23 +00:00
Jim Meyering dadd6992a2 (elide_tail_lines_pipe): Fix a thinko.
This sort of thing is why it'd be *Really Good* to factor
out the common code used here and in tail.c.
2003-05-21 09:29:50 +00:00
Jim Meyering c86a6cc089 (usage): Document new feature: --bytes=-N and --lines=-N. 2003-05-14 14:43:13 +00:00
Jim Meyering 85ad1d09c1 (AUTHORS): Enclose string in N_(...), now that it includes `and'. 2003-05-14 09:20:32 +00:00
Jim Meyering 5c0abf663a (elide_tail_lines_pipe): Don't apply cast to argument of free. 2003-05-13 14:54:31 +00:00
Jim Meyering 5352c4a62b (elide_tail_lines_pipe): Use `if', not an assert.
Now that assert is no longer used, don't include <assert.h>.
2003-05-13 10:21:13 +00:00
Jim Meyering 8f59417689 Include <assert.h>.
(AUTHORS): Add my name.
(elide_tail_lines_pipe): New function.
2003-05-12 09:36:26 +00:00
Jim Meyering 61ba51a61e Implement support so that `head --lines=-N' works on seekable files.
(enum Copy_fd_status): Define.
(COPY_FD_DIAGNOSE): New macro.
(elide_tail_lines_seekable): New funtion.
(elide_tail_lines_file): Call it here.
2003-05-07 16:21:52 +00:00
Jim Meyering 57c1158f02 Extend head to accept --lines=-N (--bytes=-N) and to print all
but the N lines (bytes) at the end of the file.

Include full-write.h, full-read.h, inttostr.h, quote.h.
Use quote() in diagnostics, rather than literal `' marks.
(copy_fd, elide_tail_bytes_pipe, elide_tail_bytes_file):
New functions.
(elide_tail_lines_pipe, elide_tail_lines_file): New functions.
(head_file): Reorganize so as to call head from only one place.
(main): Likewise, for head_file.
Handle new, undocumented option, --presume-input-pipe.
Handle negative line and byte counts.
2003-05-03 15:10:13 +00:00
Jim Meyering ea544336d7 (head_bytes, head_lines): Adapt to new safe_read ABI. 2002-10-07 05:13:59 +00:00
Jim Meyering 4006f4e672 Change exit (0)' to exit (EXIT_SUCCESS)',
`exit (1)' to `exit (EXIT_FAILURE)', and
`usage (1)' to `usage (EXIT_FAILURE)'.
2002-08-31 08:52:10 +00:00
Jim Meyering 5a731510b2 (usage): Use the PACKAGE_BUGREPORT e-mail address, rather than hard-coding it. 2002-07-02 09:06:33 +00:00
Jim Meyering 8232744d27 Include posixver.h.
(usage): Document only the intersection of the old and new behaviors,
to encourage portability.
(main): Revert to previous behavior, except report
an error and exit if the obsolete syntax is used and if conforming
to the new standard.
2002-02-16 07:39:17 +00:00
Jim Meyering e44fbb95ea (head_lines): If we have read too much data, try
to seek back to the position we would have gotten to had we
been reading one byte at a time.  POSIX currently doesn't
require this, but it's easy to do and some software relies on it.
2002-02-11 11:00:00 +00:00
Jim Meyering bf3a5672fb Add more support for POSIX 1003.1-2001, which requires removal for
support of obsolete "-N" option syntax in expand, head, fold,
split, tail, unexpand, uniq, and which prohibits options with
optional arguments in od and pr.

(usage): Document it.
(main): Check for obsolete options.
(header_mode_option): New constant.
2002-02-02 08:10:04 +00:00
Jim Meyering 3a0a028c8c Reflect renaming to, and new usage of these macros:
HELP_OPTION_DESCRIPTION and VERSION_OPTION_DESCRIPTION.
2001-12-01 17:41:25 +00:00
Jim Meyering afa12bc912 (usage): Use new macros, EMIT_HELP_DESCRIPTION and EMIT_VERSION_DESCRIPTION
instead of hard-coding --help and --version descriptions.
2001-12-01 17:21:56 +00:00
Jim Meyering 909dc8c01d Factor out some common strings to make translation easier.
Split usage strings so that --help and --version descriptions are alone
in their own string.
Likewise for the one that says:
  Mandatory arguments to long options are mandatory for short options too.
2001-11-23 19:58:23 +00:00
Jim Meyering 7d24fad90d (usage): Split --help output into smaller pieces.
Use fputs, not printf.
2001-11-11 13:56:07 +00:00
Jim Meyering ff4121e50e (usage): Say that
``Mandatory arguments to long options are mandatory for short options too.\n\''
2001-11-04 09:43:16 +00:00
Jim Meyering 58b5f108f2 Give an accurate diagnostic when `head --bytes=30M' fails.
(string_to_integer): Check explicitly for overflow,
and lump everything else together as `invalid'.
2001-10-27 14:24:42 +00:00
Jim Meyering 215ba7757e (head_bytes): Read no more than the specified number of bytes. 2001-08-18 10:10:56 +00:00
Jim Meyering 0ae67ef6a8 (head): Call write_header here.
(head_file): ... not here.
2000-08-07 13:27:24 +00:00
Jim Meyering 449fa131d6 (head_file): Use STDIN_FILENO in place of `0'.
(main): Likewise.
2000-05-24 07:10:12 +00:00
Jim Meyering 24f2bd8c9f Arrange to call close_stdout upon exit. Don't close stdout explicitly. 2000-05-20 22:06:38 +00:00
Jim Meyering b0fd0aa567 (string_to_integer): Restrict base to 10. 2000-05-12 20:30:22 +00:00
Jim Meyering cef6937705 Include new "xstrtol.h", not "xstrtoul.h".
Change all U_LONG_LONG to uintmax_t.
(head_lines): Move a couple dcls into an inner scope.
(string_to_integer): Rename from string_to_ull.
1999-04-24 12:33:25 +00:00
Jim Meyering d815c152df Standardize --help and --version processing. 1999-04-04 15:44:26 +00:00
Jim Meyering c21cecaea8 Use AUTHORS in place of string in parse_long_options call. 1999-04-03 05:26:48 +00:00
Jim Meyering 1d47220ab2 Insert AUTHORS definition. 1999-04-03 05:22:05 +00:00
Jim Meyering cf691ec714 Use PROGRAM_NAME in place of string in parse_long_options call. 1999-04-03 05:20:06 +00:00
Jim Meyering 7c2d5de6c7 define PROGRAM_NAME 1999-04-03 05:01:48 +00:00
Jim Meyering 88cbad9817 Include long-options.h
[long_options]: Remove the "help" and "version" entries.
Remove declarations of show_help and show_version.
(main): Use parse_long_options, including author name(s).
Remove the show_version and show_help blocks.
1999-03-04 05:36:10 +00:00
Jim Meyering 7568de8654 update copyright dates 1999-02-16 04:20:43 +00:00
Jim Meyering 9fec9172be Don't prototype usage as static. 1999-01-14 18:25:16 +00:00
Jim Meyering 9eedfd2482 (head_bytes, head_lines) [O_BINARY]: Use binary I/O. 1999-01-01 22:28:40 +00:00
Jim Meyering 6880f434c0 update bug-reporting address 1998-09-19 17:24:05 +00:00
Jim Meyering 257c5c4737 revert back to using lower case _unlocked wrapper names 1998-06-29 15:57:45 +00:00
Jim Meyering dd9470cb58 Change all uses of unlocked-wrapped functions to their upper case wrapper names. 1998-06-29 02:11:07 +00:00
Jim Meyering d4257e63c7 Use STREQ rather than strcmp 1998-04-12 09:27:45 +00:00
Jim Meyering b388203a65 Include safe-read.h instead of merely declaring safe_read. 1998-04-11 18:24:09 +00:00
Jim Meyering 3f3f566627 update bug-reporting address 1997-10-07 23:55:52 +00:00
Jim Meyering 25ec733e8d Include xstrtoul.h.
Remove global variable, unit_size.
(atou): Remove now-unused function.
(parse_unit): Likewise.
(string_to_ull): New function.
(head): Take new parameter, count_lines.  Use it instead of unit_size.
Update callers.
(head_file): Likewise.
(main): Use string_to_ull, not atou/parse_unit.
1997-07-13 21:59:34 +00:00
Jim Meyering dbc538f92b update copyrights for 1997 1997-02-09 04:46:02 +00:00
Jim Meyering e077b7593b bracket bug address with <> and append a period 1997-02-01 04:24:58 +00:00
Jim Meyering c2d2dec516 Compare getopt_long return value against -1, not EOF. Use NULL, not '(int *) 0' as last parameter in getopt_long call. 1997-02-01 02:00:04 +00:00
Jim Meyering a8bcd782c4 update for changed xstrtou?l 1997-01-25 06:21:24 +00:00
Jim Meyering 5582e6dad3 change bug-reporting address 1996-11-03 03:16:27 +00:00
Jim Meyering b8e689dc67 change bug-reporting address 1996-11-02 20:44:15 +00:00
Jim Meyering 630b771f1b (main): update --version output again 1996-10-04 04:25:46 +00:00