<feed xmlns='http://www.w3.org/2005/Atom'>
<title>coreutils/src/sort.c, branch v8.7</title>
<subtitle>Mirror of https://https.git.savannah.gnu.org/git/coreutils.git/
</subtitle>
<id>https://git.shady.money/coreutils/atom?h=v8.7</id>
<link rel='self' href='https://git.shady.money/coreutils/atom?h=v8.7'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/'/>
<updated>2010-10-14T09:39:14Z</updated>
<entry>
<title>bug#7213: [PATCH] sort: fix buffer overrun on 32-bit hosts when warning re obsolete keys</title>
<updated>2010-10-14T09:39:14Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-10-14T07:12:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=6b9ab1831f7b05883ed1797a5c71cf5c594b6124'/>
<id>urn:sha1:6b9ab1831f7b05883ed1797a5c71cf5c594b6124</id>
<content type='text'>
* src/sort.c (key_warnings): Local buffer should be of size
INT_BUFSIZE_BOUND (uintmax_t), not INT_BUFSIZE_BOUND (sword).
This bug was discovered by running 'make check' on a 32-bit
Solaris 8 sparc host, using Sun cc.  I saw several other instances
of invoking umaxtostr on a buffer declared to be of size
INT_BUFSIZE_BOUND (VAR), and these instances should at some point
be replaced by INT_BUFSIZE_BOUND (uintmax_t) too, as that's a
less error-prone style.
</content>
</entry>
<entry>
<title>sort: fix unportable cast of unsigned char * -&gt; char *</title>
<updated>2010-10-14T05:41:13Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-10-14T03:35:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=34ef0a01f0e1d620dac17d35832449b6880641b0'/>
<id>urn:sha1:34ef0a01f0e1d620dac17d35832449b6880641b0</id>
<content type='text'>
* src/sort.c (fold_toupper): Change this back from char to
unsigned char, fixing a portability issue introduced in commit
59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the
C Standard doesn't let you convert from unsigned char * to char *
without a cast, and the (in theory more portable) style here is to
convert char values, not pointer values.
(getmonth): Convert char to unsigned char when needed for
comparison.
</content>
</entry>
<entry>
<title>sort: destroy spin locks portably</title>
<updated>2010-09-20T22:45:49Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-09-20T22:44:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=9065006ccbe0a94e9536950f389a0cbc3dfb4dda'/>
<id>urn:sha1:9065006ccbe0a94e9536950f389a0cbc3dfb4dda</id>
<content type='text'>
* src/sort.c (sortlines, sort): Use pthread_spin_destroy when a
spin lock is no longer used.  This isn't needed on GNU/Linux or
Solaris, but POSIX says it may free up resources on some platforms.
</content>
</entry>
<entry>
<title>sort, who: prefer free+malloc to realloc when contents are irrelevant</title>
<updated>2010-08-11T03:25:56Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-11T03:25:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=9899e6cd853baf2704fdb52e55270ffbabd37dff'/>
<id>urn:sha1:9899e6cd853baf2704fdb52e55270ffbabd37dff</id>
<content type='text'>
This change was prompted by the previous one: I audited the code
looking for similar examples.  Too bad valgrind doesn't catch this.
* src/sort.c (check, mergefps): xrealloc -&gt; free + xmalloc
* src/who.c (print_user): Likewise.
</content>
</entry>
<entry>
<title>sort: free/xmalloc rather than xrealloc</title>
<updated>2010-08-10T20:49:57Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-10T20:49:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=2050a5913b0ee2e08de22db29340865f7f0ee608'/>
<id>urn:sha1:2050a5913b0ee2e08de22db29340865f7f0ee608</id>
<content type='text'>
* src/sort.c (compare_random): Use free/xmalloc rather than
xrealloc, since the old buffer contents need not be preserved.
Also, don't fail if the guessed-sized malloc fails.  Suggested by
Bruno Haible.
</content>
</entry>
<entry>
<title>sort: avoid gcc warning: explicitly ignore strtold result</title>
<updated>2010-08-10T15:11:15Z</updated>
<author>
<name>Jim Meyering</name>
<email>meyering@redhat.com</email>
</author>
<published>2010-08-10T15:11:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=ec0d6ddb813e95a01421b45f1743713e88175448'/>
<id>urn:sha1:ec0d6ddb813e95a01421b45f1743713e88175448</id>
<content type='text'>
* src/sort.c: Include "ignore-value.h".
(debug_key): Use ignore_value.
</content>
</entry>
<entry>
<title>sort: speed up -R with long lines in hard locales</title>
<updated>2010-08-09T06:15:09Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-09T06:14:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=ad31a59a370e29f38864a747045da10c82d6c912'/>
<id>urn:sha1:ad31a59a370e29f38864a747045da10c82d6c912</id>
<content type='text'>
* src/sort.c (compare_random): Guess that the output will be
3X the input.  This avoids the overhead of calling strxfrm
twice on typical implementations.  Suggested by Bruno Haible.
</content>
</entry>
<entry>
<title>sort: support all combinations of -d, -f, -i, -R, and -V</title>
<updated>2010-08-07T04:30:50Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-07T04:30:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=b877ea4b3ee4c62ab75caedbfdcca4877961aedf'/>
<id>urn:sha1:b877ea4b3ee4c62ab75caedbfdcca4877961aedf</id>
<content type='text'>
* NEWS: Document this.
* src/sort.c (getmonth): Omit LEN arg, as MONTH is now null-terminated.
(compare_random): Don't null-terminate keys, as caller now does that.
(compare_version): Remove.
(debug_key): Null-terminate string for getmonth.
(keycompare): Support combining -R with any of -d, -f, -i, -V.
Also, support combining -V with any of -d, -i.
(check_ordering_compatibility): Allow newly-supported combinations.
* tests/misc/sort (02q, 02r, 02s): New tests, for new combinations.
(incompat2): Now test -nR, since -fR are now compatible.
</content>
</entry>
<entry>
<title>sort: tune and refactor --debug code, and fix minor underlining bug</title>
<updated>2010-08-05T20:28:54Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-05T20:28:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=bdde34f95858e6ec3e6912055da3df0b033a1518'/>
<id>urn:sha1:bdde34f95858e6ec3e6912055da3df0b033a1518</id>
<content type='text'>
Formerly, the 'compare' function and some of its subroutines had a
debugging flag, which caused them to output underlines.  This
change refactors the code so that debugging output is
more-separated from the actual sorting.  In the process, the
change fixes a minor error in the debugging output.  The change
shortens the source code and executable size a tad, and improves
CPU performance by 2.4% on my platform with a simple benchmark (C
locale, line sorting, no debug).

* src/sort.c (long_double, strtold): Move back to prelude, since
they're now used by multiple functions again.
(unit_order): Move to file scope, since it's now used by two functions.
(find_unit_order, human_numcompare, numcompare, general_numcompare):
Remove endptr parameter.  All callers changed.
(human_numcompare): Args are now const pointers.
(getmonth): Endptr is now non-const.
(key_numeric): Move up, since it's needed earlier.
(debug_key): Take a line and a key as argument, instead of having
the caller figure out where the field is.
(debug_line): New function.
(keycompare, compare): Omit debug parameter; debug output now done
elsewhere.  All callers changed.
(write_line): Renamed from write_bytes; all callers changed.
Use debug_line (not 'compare') to output debug info.
Use a slightly faster check for whether output file is stdout.
(check): Don't do debugging output; it's not that useful here,
and it confuses the code.
(main): Check for incompatibility between -c and --debug.
Use standard diagnostic for incompatible options.
* tests/misc/sort-debug-keys: Fix test case: "--Mi-1" is not
a number, so its first character should not be underlined when
debugging a numeric sort.
</content>
</entry>
<entry>
<title>sort: -R now uses less memory on long lines with internal NULs</title>
<updated>2010-08-04T23:10:59Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2010-08-04T23:10:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=2b49b140cc13cf36ec5ee5acaca5ac7bfeed6366'/>
<id>urn:sha1:2b49b140cc13cf36ec5ee5acaca5ac7bfeed6366</id>
<content type='text'>
* lib/Makefile.am (libcoreutils_a_SOURCES): Remove xmemxfrm.c,
xmemxfrm.h.
* lib/memxfrm.c, lib/memxfrm.h, lib/xmemxfrm.c, lib/xmemxfrm.h: Remove.
* m4/memxfrm.m4: Likewise.
* m4/prereq.m4 (gl_PREREQ): Remove gl_MEMXFRM.
* po/POTFILES.in: Remove lib/xmemxfrm.c.
* src/sort.c: Don't include xmemxfrm.h.
(cmp_hashes): Remove.
(xstrxfrm): New function.
(compare_random): If a line contains NULs, don't create a big
buffer that contains the strxfrm output of each string in the line.
Instead, accumulate checksums and differences as we go, so that
at any one time we have to store at most the output of a single
strxfrm call when processing the line.  This removes the need for
an memxfrm function.
</content>
</entry>
</feed>
