summaryrefslogtreecommitdiff
path: root/src/sort.c
AgeCommit message (Collapse)Author
2006-11-13* src/sort.c (insertkey): Use xmemdup, rather than xmalloc+assignment.Jim Meyering
From Paul Eggert.
2006-11-13Plug another technically-unimportant leak in sort.Jim Meyering
* src/sort.c (main): Don't allocate memory for each new key here. (insertkey): Allocate memory for each key here, instead. (key_init): Rename from new_key. Don't allocate.
2006-11-13* src/sort.c (main): Plug a tiny memory leak.Jim Meyering
Move declaration of local "minus" down to be nearer point of use.
2006-10-09* src/sort.c (usage): Mention again that sort fields are origin 1.Paul Eggert
2006-08-08Use new random-number interface rather than rand-isaac.c.Paul Eggert
Don't include rand-isaac.c; include randint.h and randread.h instead. (RANDOM_SOURCE_OPTION): New enum. (long_opts, usage, main): New option --random-source. Include md5.h, randread.h, xmemxfrm.h. (longopts, usage, main): Remove undocumented --seed option; it's now replaced by --random-source. (rand_state, get_hash): Remove. (randread_source): New static var. (random_state, cmp_hashes, compare_random): New functions; they guarantee no collisions in the random hash function. (keycompare): Use compare_random for -R; don't fall back on comparing via memcoll, since compare_random does the right thing.
2006-07-09(inittables): Use toupper rather thanPaul Eggert
islower followed by toupper; it's simpler and typically faster now that we assume at least C89 semantics. Similarly for tolower.
2006-06-28* src/sort.c (main): Support obsolete usages like "sort +1 -2" even whenPaul Eggert
conforming to POSIX 1003.1-2001, since this is a pure extension to POSIX.
2006-05-25(usage): Remove mention of --seed.Paul Eggert
2005-12-14(incompatible_options): New function.Paul Eggert
(check_ordering_compatibility, main): Use it. (main): Check for -c and -o. Don't bother with a usage message for "sort -c a b", for consistency with other error diagnostics.
2005-12-14(check_ordering_compatibility): New function.Paul Eggert
(main): Use it.
2005-12-12Include rand-isaac.c rather than rand-isaac.h.Paul Eggert
Don't include md5.h; it wasn't needed. (struct keyfield): Rename random_hash to random, for consistency with the other member names. All uses changed. (usage): Tweak wording to mention STRING for --seed option. (short_options): Rorder for consistency with other programs. (rand_state): Now a struct, not a pointer to one. All uses changed. (HASH_WORDS, HASH_SIZE): Remove. (get_hash): Remove comments around resbuf size, since we can assume C89. Use a "more-kosher" (but slower) approach of invoking isaac_refill. (keycompare): Adjust to the new get_hash. Add a FIXME. (badfieldspec): Omit recently-introduced comment; it isn't needed. (main): Don't set need_random simply because gkey has it set; that doesn't necessarily mean we'll need random numbers. Redo seeding to match new get_hash approach.
2005-12-10(get_hash): Change position of `*' in parameter type to conform with convention.Jim Meyering
(main): Split a long line so it fits in 80 columns.
2005-12-10(keycompare): Remove stray SPACE before TAB that wasJim Meyering
causing `make distcheck' to fail.
2005-12-10(short_options, long_options, WORDS, keycompare, main):Paul Eggert
(usage): Add options --random-sort and --seed to implement a random shuffle. Include md5.h and rand-isaac.h. (get_hash): New function. (rand_state): New var. (HASH_WORDS, HASH_SIZE): New macros.
2005-12-09(usage): Mention white space vs -b and -t options.Jim Meyering
From The Wanderer.
2005-10-07(sortlines_temp): Redo previous change, since I'm no longer confidentPaul Eggert
that the m4/stdbool.m4 patch suffices.
2005-10-06(sortlines_temp): Undo previous change, sincePaul Eggert
today's change to m4/stdbool.m4 should catch it.
2005-10-05Add a comment to go with the last change.Jim Meyering
2005-10-05(sortlines_temp): Declare temporary as `int' ratherJim Meyering
than `bool' to work around AIX 5.3 compiler bug in 64-bit mode.
2005-09-01Clarify comment about size bounds.Paul Eggert
2005-08-18(usage) [-b,-t]: Ensure that there are at least twoJim Meyering
spaces between each option and the corresponding description -- this lets help2man format entries properly. Reported by Edward Welbourne.
2005-08-17(usage): Fix typo s/POS 2/POS2/.Jim Meyering
2005-08-12Cosmetic: use X2NREALLOC (only two arguments) rather than x2nrealloc (with ↵Jim Meyering
three).
2005-07-09Don't include stdio.h; no longer needed.Paul Eggert
2005-07-03Include stdio--.h rather than stdio-safer.h.Paul Eggert
Include stdlib--.h. Do not include unistd-safer.h. (create_temp_file): Don't call fd_safer; no longer needed now that we include *--.h files. (xfopen): Don't call fopen_safer, for similar reasons.
2005-06-29(fillbuf): Use X2REALLOC rather than x2realloc.Jim Meyering
2005-06-28split long line in copyright commentJim Meyering
2005-06-28(fillbuf): Use x2realloc on 1-byte base types, not x2nrealloc.Jim Meyering
2005-06-16Don't embed `this'-style quotes in format strings.Jim Meyering
Rather than this: error (..., "...`%s'...", arg); do this: error (..., "...%s...", quote (arg));
2005-06-02(usage): Put `Ordering options:' line where it belongs.Jim Meyering
2005-06-02Don't use "path" or "filename".Paul Eggert
2005-05-27Refactor so that others can use large-integerPaul Eggert
comparison functions. Include "strnumcmp.h". (NEGATION_SIGN, NUMERIC_ZERO, fraccompare): Remove; moved to strnumcmp. (decimal_point): Now int, to simplify converison overhead with new API. All uses changed. (thousands_sep): Now -1 if there isn't one, as per new API. All uses changed. (numcompare): Move contents to strnumcmp module, except for skipping blanks.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-12Assume `free (NULL)' works.Jim Meyering
2005-04-26Remove posixver.h and its uses.Paul Eggert
(short_options): New constant, which always supports -y arg. (COMMON_SHORT_OPTIONS): Remove.
2005-04-11Include unistd-safer.h.Paul Eggert
(create_temp_file): Use fd_safer. (xfclose): Don't assume fileno (stdin) == STDIN_FILENO, etc.
2005-04-09(SA_NOCLDSTOP): Define to 0 if not defined.Paul Eggert
All uses changed. (siginterrupt) [! HAVE_SIGINTERRUPT]: New macro. (main) [! SA_NOCLDSTOP]: Use it.
2005-03-28(long_options, mergefps): Use NULL, not `0'.Jim Meyering
2005-03-06Remove `register' keyword.Jim Meyering
2005-02-14(mergefps): Use binary search rather than linear onePaul Eggert
when comparing new line to lines already in main memory.
2004-12-02(C_DECIMAL_POINT): Remove. Use changed to '.'.Paul Eggert
Assume setlocale exists. (thousands_sep): Renamed from th_sep. (IS_THOUSANDS_SEP): Remove. All uses replaced by comparisons. (NONZERO): Parenthesize use of arg. (numcompare): Avoid duplicate loads. Use ISDIGIT as boolean, for consistency. Avoid unnecessary negation by reversing fraccompare args. (main): Rewrite localeconv call to match seq.c.
2004-11-14(zaptemp): Mark new diagnostic for translation.Jim Meyering
2004-11-13(zaptemp): Warn if a temporary file is not removed.Paul Eggert
Prune unnecessary accesses to volatile locations, and take some code out of the critical section that didn't need to be in it.
2004-11-13Make the newly-introduced critical section a bit smaller.Paul Eggert
2004-11-13Avoid O(N**2) behavior when there are many temporary files.Paul Eggert
(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.
2004-11-07(merge): Remove declarations of now-unused variables.Jim Meyering
2004-11-06(first_same_file): Remove. Move most of the code to....Paul Eggert
(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.
2004-11-06(xfclose): Don't close stdout here (just flush it),Jim Meyering
since close_stdout now closes stdout unconditionally.
2004-11-05(inittables, sort_buffer_size, getmonth, mergefps,Paul Eggert
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.