Commit Graph

20 Commits

Author SHA1 Message Date
FRIGN 48bf88851a Add missing space in error message in cut.c 2015-01-24 23:09:09 +01:00
FRIGN c369844ae2 Refactor cut.1 and cut.c
and reflect recent changes to the role of "delim".
2015-01-24 22:53:37 +01:00
FRIGN 27996f2b86 Fix segmentation fault in cut(1)
Be stricter while resolving escapes in the delimiter-string and
error out when it has length 0 or contains an invalid escape.

Thanks to Hiltjo Posthuma's sharp eagle eyes this bug was spotted.
2015-01-24 21:26:48 +01:00
FRIGN 2277b619be Add support for arbitrary length delimiters in cut(1)
Having multibyte delimiters is not enough. For full flexibility,
the possiblity of cutting input lines with arbitrary length delimiters
is the real deal.
Given this functionality, it only sounds reasonable to also add support
to resolve escapes.
Thanks to Truls Becken for making the suggestion and designing such a
flexible cut(1)-implementation!
2015-01-22 20:27:54 +01:00
FRIGN 3946d1fcc9 Use the EARGF()-macro in cut.c 2015-01-22 16:36:07 +01:00
FRIGN 733b33f1c7 Add UTF-8-delimiter-support to cut(1)
Now you can specify a multibyte-delimiter to cut, which should
definitely be possible for the end-user (Fuck POSIX).
Looking at GNU/coreutils' cut(1)[0], which basically ignores the difference
between characters and bytes, the -n-option and which is bloated as hell,
one has to wonder why they are still default. This is insane!
Things like this personally keep me motivated to make sbase better
every day.

[0]: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/cut.c;hb=HEAD
     NSFW! You have been warned.
2015-01-22 12:32:50 +01:00
FRIGN 76ca226e81 Add mandoc-manpage for cut(1) and clean up code
and mark it as finished in README.
2015-01-18 11:30:31 +01:00
Truls Becken 2433bb78cb cut: clean up file loop 2014-12-18 15:17:48 +00:00
sin 0d7822f866 Don't free the line buffer for each file
There's no point free-ing memory when the kernel can do it for us.
Just reuse the already allocated memory to hold lines.

Thanks Truls Becken for pointing this out.
2014-12-16 19:49:39 +00:00
Evan Gates 84b08427a1 remove agetline 2014-11-18 21:05:28 +00:00
FRIGN e17b9cdd0a Convert codebase to use emalloc.c utility-functions
This also definitely increases readability and makes OOM-conditions
more consistent.
2014-11-16 10:22:39 +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
Hiltjo Posthuma 97ca7c8b6d cut: improvements
- use agetline().
- code style.
- free allocated list.
- don't close stdin if "-" is given.
2014-06-01 18:02:13 +01:00
Hiltjo Posthuma daad071b31 cut, uudecode: free buf after use
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:31 +01: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 486d22fc48 Simplify code in cut(1)
Thanks Roberto and Rob for your input on this.
2013-10-10 23:04:46 +01:00
sin 484d5b4340 Do not rely on `s' being incremented before taking the address of it
The order of evaluation for the arguments of a function is not
defined by the standard.
2013-10-09 16:42:45 +01:00
Truls Becken 576a5ce55e Add cut(1) 2013-10-08 20:41:32 +01:00