A line longer than 2G might overflow the size_t containing the buffer
length on 32-bit platform. Fix is to use reallocarray with second
parameter twice the size of the element to double the buffer size, since
it will error out if there was an overflow.
Previously command-not-found(1) encoded all its suggestions in code.
This changes it to use a data table to make it easier to understand and
to modify with new suggestions.
b commonly corresponds to Page Up, and f is added to match.
j and k for lines, ^F and ^B for pages, and g and G for home/end are from vi.
C-n and C-p for lines and C-v and M-v for pages are from Emacs.
< and > for home/end allow using Emacs M-< and M->, tho they are from less(1).
POSIX allows <fcntl.h> to include <sys/stat.h>, but doesn't require it.
There's little reason to do that, since they are separate headers, and
<fcntl.h> just needs the mode_t constants. Fix the code accidentally
relying on <fcntl.h> including <sys/stat.h>. The mode_t constants are now
provided in their own kernel header <sortix/mode.h>.
Additionally fix <sys/stat.h> pulling in all of <sys/types.h>, which is not
allowed by POSIX, which only requires a few types to be declared. Fix the
code accidentally relying on <sys/stat.h> including <sys/types.h>.
Finally fix <dirent.h> pulling in <stdint.h> through <sortix/dirent.h>.
The <sortix/__/dt.h> and <sortix/__/stat.h> headers are no longer required
and their contents have been merged into <sortix/__/dirent.h>.
Fix -C disabling checking rather than checking quietly.
Fix sort(1) exiting 1 on certain errors, as POSIX requires sort(1) to only
exit if the input wasn't sorted when -c.
Fix -o opening the output file for truncation before all the input has been
read, as POSIX requires allowing -o to be an input file.
POSIX requires sort(1) to handle input errors by either erroring with no
output, or by erroring and sorting the input read so far. Change the current
behavior of continuing to the next file to simply failing hard on the first
input error.
Don't increment the last line number on the end of the standard input.
Report -c/-C as incompatible with -o.
Exit unsuccessfully on any output errors.
Update to current coding conventions and add documentation while here.
The commit 0def94568a switched to the box
drawing light vertical (U+2502) character, but did not fix the now wrong
assumption that the line drawing character encoded to a single byte.