Commit Graph

1790 Commits

Author SHA1 Message Date
FRIGN
698a14b1da Indent README headings properly 2016-03-10 08:48:09 +00:00
FRIGN
45b42516d4 Support NUL containing lines in head(1)
Very trivial this time.
2016-03-10 08:48:09 +00:00
FRIGN
886fca3fd6 Support NUL containing lines in tail(1)
This was rather simple this time.
2016-03-10 08:48:09 +00:00
FRIGN
0fa5a3e5bb Rename struct linebufline to struct line and add linecmp()
This simplifies the handling in sort(1) and comm(1) quite a bit.
2016-03-10 08:48:09 +00:00
FRIGN
54d3f3b3a5 Rename linecmp and line-structs in join(1) and sort(1)
We will steal the names for the global functions.
2016-03-10 08:48:09 +00:00
FRIGN
d585d4b028 No need for += when res is 0 anyway 2016-03-10 08:48:09 +00:00
FRIGN
eebba22577 Support NUL containing lines in comm(1) 2016-03-10 08:48:09 +00:00
FRIGN
691c54750f Don't mark cols(1) as NUL-compliant as of yet
Thing is, we don't yet have an updated utflen() ready for use. Although
prints the lines completely, it does not add a proper spacing between
each entry. This will be fixed later.
2016-03-10 08:48:09 +00:00
FRIGN
9d120b7b32 Actually move past the field separator
Previously, sort(1) failed on key-based sorting and was caught in an
infinite loop with the c-flag.
2016-03-10 08:48:09 +00:00
FRIGN
0e25f09b56 Remove debug info 2016-03-10 08:48:09 +00:00
FRIGN
19c0ca9830 Properly increment line lenght on edge-case in getlines() 2016-03-10 08:48:09 +00:00
FRIGN
eb9bda8787 Support NUL-containing lines in sort(1)
For sort(1) we need memmem(), which I imported from OpenBSD.
Inside sort(1), the changes involved working with the explicit lengths
given by getlines() earlier and rewriting some of the functions.

Now we can handle NUL-characters in the input just fine.
2016-03-10 08:48:09 +00:00
FRIGN
e4810f1cdb Support NUL-containing lines in cols(1)
This required an architectural change in getlines() by also storing
the line length.
2016-03-10 08:48:09 +00:00
FRIGN
2d7d2261a0 Really force 1 entry per line with -1 in ls(1)
if a filename contains a \n, it would not be limited to one line.
We use the qflag to replace the control characters with '?'s.
2016-03-02 18:44:32 +00:00
FRIGN
97ce9ea586 Fix -s in tr(1)
Forgot that in case there is a second argument given with -s you
probably want to have your characters substituted.
I changed it so that shortly before "deploying" we check if the
"to be written"-Rune is equal to the last Rune, and proceed as
needed.
2016-03-02 09:31:11 +00:00
sin
ea0d16e928 Revert "fix length after '\' getline string termination"
Caused a regression in sed, revert until we investigate further.
2016-03-01 15:24:32 +00:00
Hiltjo Posthuma
fa18379a05 uuencode: style: just use pointer *b
it doesn't make sense to use b[2] here anyway, and it is incorrect (should be b[3]).
2016-03-01 15:24:32 +00:00
Hiltjo Posthuma
a51b01ff90 uudecode: dont return pointer to local variable 2016-03-01 15:24:32 +00:00
Quentin Rameau
d04402b6ea cat: fix u flag
Our libutil concat() always uses a buffer for input wich is obviously
not compatible with unbuffered io. Here is a local uconcat() which
naively copies input to stdout char by char.
2016-03-01 11:14:42 +00:00
Quentin Rameau
3da450e203 printf: replace strtonum with strtol functions in conversions
Use strtol and strtoul respectively for d, i and o, u, x, X conversions.
This way we can convert other bases than 10, which strtonum doesn't
provide.
Also don't exit on conversion error but display a warning, set a return
error code, and continue.
2016-03-01 11:14:42 +00:00
Quentin Rameau
243cdb6669 printf: remove unnecessary string size test 2016-03-01 11:14:42 +00:00
FRIGN
b83916ca27 Add symbol to mark NUL handling in each tool (and where it is missing)
The assumption of NUL-terminated strings is actually quite a good one in
most cases. You don't have to worry about paths, because they may not
contain NUL.
Same applies to arguments passed to you. Unless you have to unescape,
there is no way for you to receive a NUL.

There are two important exceptions though, and it's important that we
address them, or else we get unexpected behaviour:

	1) All tools using unescape() have to be strict about delimlen.
	   Else they end up for instance unescaping
	   	'\\0abc'
	   to
	   	'\0abc',
	   which in C's string-vision is an empty string.

	2) All tools doing line wrenching and putting them out
	   again as lines again.
	   puts() will cut each line containing NULs off at the first
	   occurence.
2016-02-26 09:54:46 +00:00
FRIGN
a88906b423 Rever the strmem() addition and add a TODO element
strmem() was not very well thought out. The thing is the following:
If the string contains a zero character, we want to match it, and not
stop right there in place.

The "real" solution is to use memmem() where needed and replace all
functions that assume zero-terminated-strings from standard input, which
could lead to early string-breakoffs.
This requires a strict tracking of string lengths.
2016-02-26 09:54:46 +00:00
FRIGN
3396088666 Implement strmem() and use it in join(1)
We want our delimiters to also contain 0 characters and have them
handled gracefully.
To accomplish this, I wrote a function strmem(), which looks for a
certain, arbitrarily long memory subset in a given string.
memmem() is a GNU extension and forces you to call strlen every time.
2016-02-26 09:54:46 +00:00
Hiltjo Posthuma
e8eeb19fcd fix length after '\' getline string termination 2016-02-26 09:54:46 +00:00
Hiltjo Posthuma
58257275f0 tsort.1: use mandoc literal block for example 2016-02-26 09:54:46 +00:00
sin
9a2b8d3531 tsort style fixes
getline() cannot return 0 so no need to guard against that.
2016-02-24 15:57:33 +00:00
FRIGN
102baab4c4 Use en* instead of e* function family in tsort(1)
The wtf macros overwrote the semantics, for more clarity this
has been fixed.
2016-02-24 15:28:01 +00:00
FRIGN
50b30bbd69 Remove wtf 2016-02-24 15:21:05 +00:00
FRIGN
79e8e330cb Fix wc(1) output for large files
Previously, we used the System V output format:
	"%7d%7d%7d %s\n"
The problem here is, that if any number has more than six digits, the
result looks like one big number, as we don't mandate spaces.

POSIX says the output format should rather be
	"%d %d %d %s\n"
but in this case we wouldn't get consistent results.

To serve both camps, I changed it to the following:
	"%6d %6d %6d %s\n"
This won't change the output for normal values, but also
prevent the output of large files to be ambiguous.
2016-02-24 14:45:20 +00:00
Mattias Andrée
a392cd475e add sha512-224sum (SHA512/224) and sha512-256sum (SHA512/256)
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-02-24 10:40:57 +00:00
Mattias Andrée
ae1da536bb add sha224sum and sha384sum
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-02-24 10:15:16 +00:00
FRIGN
6adb9b8ccd Fix compilation error 2016-02-21 08:52:48 +00:00
FRIGN
0d97bd3f57 Change the note in printf.1 on octal escapes 2016-02-21 08:52:48 +00:00
FRIGN
70adb1252d Do a range check on the resulting octal 2016-02-21 08:52:48 +00:00
FRIGN
bbe10559e6 Remove the octal note in printf.1 2016-02-21 08:52:48 +00:00
FRIGN
41a600e1b8 Allow \0ooo octal escapes
Yeah well, the old topic. POSIX allows \0123 and \123 octals in
different tools, in printf, depending on %b or other things.
We'll just keep it simple and just allow 4 digits. the 0 does not make
a difference anyway.
2016-02-21 08:52:48 +00:00
Lucas Gabriel Vuotto
bbacab561c arg.h: fixed argv checks order
This prevents accessing to a potentially out-of-bounds memory section.

Signed-off-by: Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
2016-02-20 08:23:57 +00:00
Quentin Rameau
ee8701d501 ls: check for the index size before using it in visit()
Thanks to k0ga for noticing it!
2016-02-18 14:18:49 +00:00
Quentin Rameau
1024369f2d ls: make the opendir() warning message more consistent
Print the total file path in the warning message.
2016-02-18 14:17:21 +00:00
Quentin Rameau
ac05587385 ls: set a return error code when skipping an already visited path. 2016-02-18 14:17:21 +00:00
Quentin Rameau
340b163563 ls: do not exit when a directory isn't accessible
Just print a warning and process next item instead,
and return 1 to report this error.
2016-02-18 11:31:58 +00:00
sin
764efb7e54 Add missing .El to xinstall.1 2016-02-18 10:56:42 +00:00
Quentin Rameau
bd88854850 install: treat target as file by default instead of dir
When using 'install foo bar', bar should be treated as a file copy of
foo, not a directory to be created and into which install foo.
2016-02-18 10:48:16 +00:00
pekka.jylha.ollila@gmail.com
bb83eade39 Fix showing directories when -R flag is set in ls(1)
Here's a better version of the patch.
When the R flag is used with a single directory, the given directory name is
omitted. With multiple directories each directory name is listed.
Directories that start with './' and '../' are now also printed.
2016-02-17 19:49:07 +00:00
Eivind Uggedal
b97839751b install: only create parent dirs to dest given -D
Given the following commands:

    touch 1.txt; install -D 1.txt d/2.txt
    find d

The result without this fix:

    d
    d/2.txt
    d/2.txt/1.txt

The result with this patch applied:

    d
    d/2.txt
2016-02-17 08:59:19 +00:00
Mattias Andrée
4f701bcd8a tsort: clean up
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-02-17 08:56:54 +00:00
sin
1f6f1a8f4b Forgot to bump date for sort(1) manpage 2016-02-17 08:43:15 +00:00
sin
65159194fb Mark sort(1) as POSIX compliant 2016-02-17 08:39:11 +00:00
sin
1e81e214d6 tsort: Minor style fix 2016-02-17 08:28:32 +00:00