Commit Graph

10621 Commits

Author SHA1 Message Date
Jim Meyering 61829f0638 *** empty log message *** 2001-03-03 19:12:29 +00:00
Jim Meyering 5d34d8c327 (xfopen): Set have_read_stdin to 1 only if file is "-".
Use fopen_safer, not fopen, to avoid subtle bugs when fopen returns
stdin, stdout, or stderr.
(xfclose): stdout is no longer a special case.
(main): Close output file, don't just flush it; there might be
an error on the close.
2001-03-03 19:12:23 +00:00
Jim Meyering 57658678dd (libfetish_a_SOURCES): Add dup-safer.c, fopen-safer.c.
(noinst_HEADERS): Add stdio-safer.h, unistd-safer.h.
2001-03-03 19:06:54 +00:00
Jim Meyering eb64d4a73b *** empty log message *** 2001-03-03 19:06:28 +00:00
Jim Meyering 62eab23e81 from Paul Eggert 2001-03-03 19:05:36 +00:00
Jim Meyering 4518931c29 *** empty log message *** 2001-03-03 18:53:53 +00:00
Jim Meyering cac9a29ad8 (initbuf): If the desired size cannot be
allocated, repeatedly halve it until allocation succeeds.
2001-03-03 18:53:44 +00:00
Jim Meyering f10bbe70a9 (parse_field_count): Comment fix. 2001-03-03 18:40:44 +00:00
Jim Meyering 3c1f856059 . 2001-03-03 18:38:22 +00:00
Jim Meyering 5514c4792b *** empty log message *** 2001-03-03 18:23:37 +00:00
Jim Meyering 25f95ca91e Tune allocation and comparison of nodes
representing temp files.  This improved CPU performance of
'sort -S 1 *.[ch]' by 17% on my host.

(struct tempnode): name member now uses struct hack.
(temphead): Now a pointer, not a structure.  All uses changed.
(create_temp_file): Allocate node using struct hack.
(zaptemp): Free node using struct hack.  Use pointer comparison, not
string comparison.
2001-03-03 18:23:29 +00:00
Jim Meyering cfd53be2c8 (eolchar, trim_trailing_blanks): Now static. 2001-03-02 03:44:49 +00:00
Jim Meyering e3093d28d9 *** empty log message *** 2001-03-02 03:41:50 +00:00
Jim Meyering e0689425b8 *** empty log message *** 2001-03-02 03:14:38 +00:00
Jim Meyering 68de994bf1 (jm_MACROS): Use mkstemp replacement if the system
lacks mkstemp.  Compile our own tempname.c if we compile our own
mkstemp.c, as mkstemp relies on tempname.
2001-03-02 03:14:31 +00:00
Jim Meyering b11665966d from GNU libc 2001-03-02 03:13:34 +00:00
Jim Meyering 01b7b402a3 from GNU libc 2001-03-02 03:12:47 +00:00
Jim Meyering 03285f9da5 *** empty log message *** 2001-03-02 03:10:42 +00:00
Jim Meyering 334ae8d83d . 2001-03-02 03:06:08 +00:00
Jim Meyering 871b2ea818 *** empty log message *** 2001-03-02 02:58:30 +00:00
Jim Meyering 2679dfb639 'sort' race condition fixes.
Defend against a DoS attack where someone else creates a
temporary file with the same name as ours.  Use mkstemp to do
this, supplying our own mkstemp if the system doesn't have one.

Also, fix a race condition during cleanup on hosts without
sigaction.


(NAME_MAX_IN_DIR): Remove.
(sigprocmask, sigset_t): New macros, defined only on older hosts.
(caught_signals): New var.
(xtmpfopen, tempname): Removed.
(create_temp_file): New function, combining the functions of the old
xtmpfopen and tempname.  All callers changed.
Use mkstemp to create the file.
(sighandler): On hosts without sigaction, ignore signals while
cleaning up, instead of letting them interrupt cleanup.
(main): Initialize caught_signals.  On hosts with sigaction, block all
caught signals while handling one.  Remove duplicate code.
2001-03-02 02:58:23 +00:00
Jim Meyering 3a960cb7e4 *** empty log message *** 2001-03-01 05:33:25 +00:00
Jim Meyering f5cf8b6039 (jm_AC_DOS): Remove extra backslashes, now that
AH_VERBATIM really does output its argument verbatim.
2001-03-01 05:33:18 +00:00
Jim Meyering 675a66a029 *** empty log message *** 2001-02-25 07:55:33 +00:00
Jim Meyering ffd0a44de4 Fix typo: '-d=1may' -> '-d 1may'.
Fix and clarify time zone usage in 'date' examples.
2001-02-25 07:55:27 +00:00
Jim Meyering 2a9477bd95 *** empty log message *** 2001-02-23 08:52:27 +00:00
Jim Meyering 5f001b35ed (keycompare): Move declarations of locals, lena and lenb,
into the inner scope where they are used.
2001-02-22 15:11:08 +00:00
Jim Meyering 241297f40e (main): Remove assignment-in-if-expression.
In fact, remove t_errno altogether.
2001-02-21 10:56:06 +00:00
Jim Meyering df373089ee *** empty log message *** 2001-02-21 10:50:07 +00:00
Jim Meyering 2a08e10112 Add two tests of existing behavior -- both will
have to be changed (soon after release), once ls is fixed.
2001-02-21 10:49:58 +00:00
Jim Meyering d015986221 . 2001-02-20 23:04:45 +00:00
Jim Meyering 4fda5e9381 test for existing behavior 2001-02-20 23:00:33 +00:00
Jim Meyering 6f1ffe444c . 2001-02-20 22:58:44 +00:00
Jim Meyering 9f0b79a1ba *** empty log message *** 2001-02-20 22:58:16 +00:00
Jim Meyering cf4686a06a (FULL_TIME_OPTION): Renamed from FULL_TIME, for
consistency with the other enum values.
2001-02-20 22:53:38 +00:00
Jim Meyering ccbe301659 (SI_OPTION): New enum value.
(long_options): Use it instead of 'H' for --si.
(decode_switches): Warn that -H will change soon.
(usage): Likewise.
2001-02-20 22:52:31 +00:00
Jim Meyering 6af107568c revert last change, until after release 2001-02-20 22:48:39 +00:00
Jim Meyering 890e2a5a58 *** empty log message *** 2001-02-20 22:48:18 +00:00
Jim Meyering 56bcd15a9c revert last change, until after the release 2001-02-20 22:48:00 +00:00
Jim Meyering 05c801ff0c ls -Fd symlink-to-directory' would print a trailing /'
Now it prints a trailing `@'.

(gobble_file): Don't clobber lstat stats of command line
arguments when using -d and -F (--directory and --classify) options.
2001-02-20 08:16:47 +00:00
Jim Meyering c74553f398 *** empty log message *** 2001-02-19 08:53:37 +00:00
Jim Meyering d4142ec88e (AUTHORS): Add Paul Eggert. 2001-02-19 08:53:24 +00:00
Jim Meyering 80016947b7 *** empty log message *** 2001-02-19 08:52:58 +00:00
Jim Meyering 5af9b0048f Fix a race condition: freed storage accessed during a signal handler.
(struct tempnode.next): Now volatile.
(zaptemp): Free the file name after removing it from the temp list,
not before, because a signal can arrive between the two actions
and cleanup () traverses the list.
2001-02-19 08:52:53 +00:00
Jim Meyering 9758a4d87a *** empty log message *** 2001-02-19 08:51:00 +00:00
Jim Meyering 3e593e8a31 (jm_CHECK_ALL_HEADERS): Check for sys/resource.h. 2001-02-19 08:50:54 +00:00
Jim Meyering b0abc5579f *** empty log message *** 2001-02-19 08:50:18 +00:00
Jim Meyering 55d155dbbe Check for input size, and do not overallocate memory.
Also check for memory quotas.

Revamp storage management so that line tables and character data are
taken from the same buffer.  Line tables are now in reverse order,
since they grow down while the character data grow up.

(<sys/resource.h>): Include if HAVE_SYS_RESOURCE_H.
(struct rlimit, getrlimit): Define a replacement if RLIMIT_DATA
is not defined.
(RLIMIT_AS): Define to RLIMIT_DATA if not defined.
(struct lines): Remove.
(struct buffer): New members nlines, line_bytes, eof.
Remove member newline_free; no longer needed, since the code no longer
runs out of line table space.
(SORTALLOC_MIN, SORTALLOC_DEFAULT_MIN): Remove.
(sort_size): Renamed from sortalloc; now applies to the sum of the
character data and the line table, not just the character data.
(MIN_SORT_SIZE, INPUT_FILE_SIZE_GUESS): New macros.
(linelength): remove.
(specify_sort_size): Don't worry about the distinction between the
character data and the line table; that is now the caller's
responsibility.
(default_sort_size): Return the value, instead of being executed for
side effect.  Return half of available memory, or 1/16 of total memory,
whichever is greater; except do not exceed 1/2 of quota.
(sort_buffer_size): New function.
(initbuf): New arg LINE_BYTES.  Ensure that the line array is properly
aligned.  Initialize the new set of struct buffer members.
(buffer_linelim): New function.
(fillbuf): Return int, not size_t, since the callers merely care
whether the result is nonzero.  New arg FILE so that error messages
can report the file name.  Keep track of eof.  Initialize the line
table too, taking its memory from the input buffer's memory; this
subsumes the old findlines function and removes the need for worrying
about running out of line table entries.
(checkfp, mergefps, sortlines, merge, sort): Adjust to the new storage
management regime, in particular the fact that line tables are now
filled in by fillbuf and are in reverse order.
(checkfp): Now takes char *, not const char *, since subroutines
require that now.  Rewrite to avoid lint and duplicate code.
If line length alloc calculation overflows,
simply allocate enough memory to hold the line.
(mergefps): New arg FILES, used for buffer size calculation and error
messages.  Rewrite to avoid lint.  Do not loop if savealloc*2
overflows.
(mergefps, merge): Zap temporary files eagerly rather than lazily;
this is needed because we now pass FILES to mergefps.
(sortlines): Args now point at end of arrays, not at beginnings.
(sort): Do not allocate temporary line array for sortlines;
instead, take the space from the same buffer.
(main): Adjust to sort_size and default_sort_size changes.
2001-02-19 08:50:12 +00:00
Jim Meyering 9de8c30c25 *** empty log message *** 2001-02-19 08:46:00 +00:00
Jim Meyering e4db8d3b54 (wc): Rename innermost `buf' to avoid shadowing warning.
(wc): Rename local `wc' to avoid shadowing function name.
2001-02-19 08:42:25 +00:00