Commit Graph

47 Commits

Author SHA1 Message Date
FRIGN
df8529f0a1 Fix syntax error in sort(1)
Somehow went unnoticed...
2015-03-23 20:30:07 +01:00
FRIGN
49e27c1b0c Add -m and -o flags to sort(1)
Sort comes pretty much automatically, as no script relies on the
undefined behaviour of the input _not_ being sorted, we might as well
sort the sorted input already.
The only downside is memory usage, which can be an issue for large
files.
The o-flag was trivial to implement.
2015-03-22 23:39:48 +01:00
Hiltjo Posthuma
ad6776e9a1 grep, kill, renice, sort: style: put main at bottom 2015-03-08 12:51:33 +01:00
Hiltjo Posthuma
31f0624f3d code-style: minor cleanup and nitpicking 2015-02-20 13:29:38 +01:00
FRIGN
31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
Jakob Kramer
0fcad66c75 make use of en*alloc functions 2015-02-11 01:17:21 +00:00
Jakob Kramer
4769b47dd7 Use size_t for number of lines in linebuf
.nlines and .capacity are used as array indices and
should therefore be of type size_t.
2015-01-31 22:49:43 +00:00
Jakob Kramer
572ad27110 sort: support sorting decimal numbers correctly
sorry not to have used strtold from the beginning
2015-01-31 19:19:55 +00:00
sin
153b8428b1 Nuke another freelist() 2014-12-16 21:02:03 +00:00
Michael Forney
cb427d553a sort: Implement -c and -C flags 2014-11-23 19:42:14 +00:00
FRIGN
1436518f9d Use < 0 instead of == -1 2014-11-19 20:09:29 +00:00
FRIGN
7fc5856e64 Tweak NULL-pointer checks
Use !p and p when comparing pointers as opposed to explicit
checks against NULL.  This is generally easier to read.
2014-11-14 10:54:30 +00:00
FRIGN
ec8246bbc6 Un-boolify sbase
It actually makes the binaries smaller, the code easier to read
(gems like "val == true", "val == false" are gone) and actually
predictable in the sense of that we actually know what we're
working with (one bitwise operator was quite adventurous and
should now be fixed).

This is also more consistent with the other suckless projects
around which don't use boolean types.
2014-11-14 10:54:20 +00:00
FRIGN
eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin
0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
sin
b712ef44ad Fix warning 'array subscript of type char' 2014-09-02 13:32:32 +01:00
Jakob Kramer
7d1fd2621e add -t flag to sort 2014-06-02 13:35:59 +01:00
Jakob Kramer
9366f48b1f sort: simplify linecmp, rename curr => tail 2014-05-06 18:01:44 +01:00
Jakob Kramer
6f7e9a5078 sort: add support for "per-keydef" flags 2014-05-06 16:21:50 +01:00
Jakob Kramer
109e8963f5 sort: ignore trailing newline while sorting 2014-05-06 16:21:45 +01:00
Jakob Kramer
0723c8d32e sort: work with signed integers as well 2014-05-06 16:21:39 +01:00
Jakob Kramer
814b04e710 sort: document -b 2014-05-04 00:16:24 +01:00
Jakob Kramer
a2da9edb99 sort: simplify skip_columns 2014-05-04 00:15:57 +01:00
Jakob Kramer
d965985a52 sort: add -b flag; don't use it as default 2014-05-04 00:15:46 +01:00
Jakob Kramer
a62a2197a8 sort: don't evaluate if clause
this fixes that you could specify a key
definition like "-k 1.2.3", which is incorrect.
2014-05-04 00:15:33 +01:00
Jakob Kramer
e535e8d88a sort: replace loop with MIN() 2014-05-04 00:15:23 +01:00
Jakob Kramer
56e1616486 sort: remove 'rest' variable 2014-05-04 00:15:10 +01:00
Jakob Kramer
56b9a26de9 sort: don't repeat skipping columns logic 2014-05-04 00:14:58 +01:00
Jakob Kramer
c4e5354a32 sort: linebuf is no global 2014-05-04 00:14:19 +01:00
Jakob Kramer
0bc6b1377b sort: readability; check strndup return value 2014-04-30 15:17:01 +01:00
Hiltjo Posthuma
a1b62b2282 sort: style, explicitly state type
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-23 15:25:21 +01:00
sin
1d5663672e Minor style changes to sort 2014-04-18 17:24:59 +01:00
Jakob Kramer
98a12cc146 sort: add -k, fix -u
Options  that are  specific to  a  single  key  definition are not
supported (e.g. "sort -k 2,3n -k 4,4").  Should you try to specify
such definitions, sort will  return with EXIT_FAILURE and an error
message.   Instead, all key definitions exclusively use the global
settings.

It always behaves like -b was set.
2014-04-18 13:43:32 +01:00
sin
544857623b Add -n support to sort(1) 2013-12-12 13:10:59 +00:00
sin
b8edf3b4ee Add weprintf() and replace fprintf(stderr, ...) calls
There is still some programs left to be updated for this.

Many of these programs would stop on the first file that they
could not open.
2013-11-13 11:41:43 +00:00
sin
b5a511dacf Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1
Fixed for consistency purposes.
2013-10-07 16:44:22 +01:00
stateless
7216a53a7e Remove unnecessary exit(1) in usage()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-19 19:58:19 +02:00
Christoph Lohmann
4d38f60685 Eliminating the getopt disgrace. 2013-06-14 20:20:47 +02:00
Robert Ransom
07b702d9a1 sort: Librarify getlines() 2012-05-21 21:09:38 +00:00
Robert Ransom
6a86755fee sort: Expand linebuf.lines by more than one pointer-size at a time 2012-05-21 20:27:03 +00:00
Robert Ransom
e9d6735a9d sort: Move lines and nlines globals into a struct 2012-05-21 20:09:44 +00:00
Robert Ransom
7565af0e31 sort: Return 2 on usage error 2012-05-20 14:38:52 +00:00
Connor Lane Smith
d7f9bda740 cc -Wextra 2011-06-21 05:05:37 +01:00
Connor Lane Smith
9ef61c39e9 sort: fix 2011-06-04 12:27:44 +01:00
Connor Lane Smith
d90ced2047 consistent error check 2011-06-04 12:20:41 +01:00
Connor Lane Smith
16a0ee098c sort -u 2011-06-02 13:09:30 +01:00
Connor Lane Smith
9f9ea07e6c add sort 2011-06-02 13:03:34 +01:00