Age | Commit message (Collapse) | Author |
|
on two lines, one for `-n STRING' and one for `STRING' so that
help2man properly escapes the `-'. Otherwise, the hyphen is
rendered inappropriately in UTF-8 locales.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closed initially, since some programs don't write to stdout in the
normal course of operation (other than --version and --help), and
we don't want this function to make e.g. `cp 1 2 >&-' fail.
But do fail if it was closed and someone has tried to write to it.
E.g., printf 'foo' >&-
|
|
|
|
|
|
|
|
|
|
|
|
Prune unnecessary accesses to volatile locations, and take some
code out of the critical section that didn't need to be in it.
|
|
|
|
Fix a race condition.
|
|
|
|
(temptail): New variable, so that we can easily append to list.
(create_temp_file): Create new files at end of list, so that
searching the list has O(N**NMERGE) behavior instead of O(N**2).
(zaptemp): Update temptail if needed.
(mergefps, merge): Accept new arg that counts temp files, and keep it
up to date as we create and remove temporaries. This is for
efficiency, so that we don't call zaptemp so often.
All callers changed.
(sort): Don't create array in reverse order, since the list of
temporaries is now in the correct order.
(zaptemp): Protect against race condition: if 'sort' is
interrupted in the middle of zaptemp, it might unlink the
temporary file twice, and the second time this happens the file
might already have been created by some other process.
(create_temp_file): Use offsetof for clarity.
(die): Move it up earlier, to clean up the code a bit.
|
|
|
|
with "+".
|
|
|
|
(skip_to_page, first_page_number, last_page_number, page_number,
first_last_page, print_header):
Use uintmax_t for page numbers.
(first_last_page): Remove unnecessary forward declaration.
Do not modify arg (it is now a const pointer).
Return a true if successful, false (without print a diagnostic)
otherwise.
(main): If +XXX does not specify a valid page range, treat it
as a file name. This follows the response to Open Group XCU ERN 41
<http://www.opengroup.org/sophocles/show_mail.tpl?source=L&listname=austin-group-l&id=7717>,
which says the behavior is allowed.
(skip_to_page): When starting page number exceeds page count,
print both numbers in the diagnostic.
(print_header): Detect page number overflow.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(main) [__APPLE__]: Get the processor type via syscall rather than
hard-coding "powerpc". From toby@opendarwin.org.
|
|
|
|
|
|
|
|
(avoid_trashing_input): New function.
(merge): Avoid some silly merges, e.g., copying a single file to
a temporary file when there are exactly 17 input files to merge.
Take a count of temporary files rather than a max_merge arg.
All uses changed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(close_stdout): Always close stdout. I.e., don't
return early when it seems there's nothing to flush.
Don't include __fpending.h.
|
|
since close_stdout now closes stdout unconditionally.
|
|
|
|
first_same_file, merge, sort, main): Use size_t for indexes into arrays.
This fixes some unlikely havoc-wreaking bugs (e.g., more than INT_MAX
temporary files).
(getmonth, keycompare, compare): Rewrite to avoid need for alloca,
thus avoiding unchecked stack overflow in some cases. As a side
effect this improve the performance of "sort -M" by a factor of 4
on my benchmarks.
|
|
|