| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
print_error() was declared as "void print_error();" but defined with
parameters "const char *error, int help_mode". Declarations without
prototypes are unsupported.
printUsage also gains "void" as its prototype in this commit, just to be
explicit.
|
|
|
|
| |
See feature_test_macros(7)
|
|
|
|
|
|
| |
Some of these types cannot assumed to be unsigned long, etc. Those type
differences cause build failures on OpenBSD. This commit casts them
properly.
|
|
|
|
|
|
|
|
|
| |
success is always set anyway, so moving it up is simply a matter of code
style.
read_file could be uninitalized when used, which leads to UB.
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
|
|
| |
C doesn't initialize uninitalized variables to a "zero value" by
default. if (!lines) lines = 10; wouldn't work if lines contains garbage
values (which it almost always does).
Kinda similar for file.
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
| |
i < 256 && (param[i] = 0) as a loop condition doesn't work because the
value of assignments is the rvalue, which means that the loop will
not run. Initialization using a for loop should be unnecessary anyway.
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
| |
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
| |
file_lines used to be uninitialized, which causes UB whenever
file_lines++ is used; nothing happens before that so it's not even an
edge case.
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
| |
"status" used to be uninitialized when the if (argc == 3 ...) block
is entered. If strlen(argv[2]) is 0, i.e. if argv[2] is an empty string,
undefined behavior occurs.
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
|
| |
Previously, argc is always expected to be 3 (program name, source,
destination), without regard for any arguments. This check was done
before parsing options, so effectively, the usage of any options would
cause the check to fail.
This commit causes argument counting to happen after options parsing.
|
|
|
|
|
|
|
|
|
|
|
|
| |
check that the suffix is non-empty:
If strlen(argv[2]) < 1, the for loop would not run, and the status would
be uninitialized. This commit causes the suffix to be ignored if it is
empty.
print empty line when input name is empty:
If basename(3) receives an empty string or a null pointer, it returns
the string ".", but we want basename(1) to just output an empty line
when the input is empty.
|
|
|
|
| |
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thie solves:
box_tmp/cmp_box.c: In function ‘cmp_main’:
box_tmp/cmp_box.c:41:25: error: comparison is always false due to limited range of data type [-Werror=type-limits]
41 | if (ch1 == EOF || ch2 == EOF) {
| ^~
box_tmp/cmp_box.c:41:39: error: comparison is always false due to limited range of data type [-Werror=type-limits]
41 | if (ch1 == EOF || ch2 == EOF) {
| ^~
cc1: all warnings being treated as errors
make: *** [Makefile:42: box] Error 1
Signed-off-by: Runxi Yu <me@runxiyu.org>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
| |
Reported-by: Leah Rowe <leah@libreboot.org>
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
| |
It's poorly implemented and ugly, it segfaults and doesn't compile with
-Werr. The time is now!
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
| |
Both core/Makefile and extras/Makefile were almost identical. This
commit unifies the identical parts in one file.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
| |
It's useless
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Those bugs were basically introduced by typos...
First bug
---------
`head` was checking if argc was less than 2, which is incorrect because
after getopt() is ran, argc would be equal to 1 if ran this way:
$ head file
As such, it would read standard input, then the file, which is a bug.
Second bug
----------
The file got closed after the first line was read. When trying to read
the (now closed) file it returns a segmentation fault.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX says this:
> Applications using the exec() family of functions to execute
> these utilities shall ensure that the argument passed in arg0
> or argv[0] is '[' when executing the [ utility and has a
> basename of "test" when executing the test utility.
Which basically means (in pseudo-code if you will):
if argv[0] is "[" -> behave like the POSIX [
else -> behave like the POSIX test
[ used to compare with the basename of argv[0], which is
POSIXly incorrect.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
| |
That fixes a bug where [/test always returns 1 when used with
`-L` or `-h`.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
|
| |
wc used to always return 'total %d %d %d %s\n' (in
pseudo-printf here) regardless of if one or multiple
files were specified.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
`cat` used to not concatenate at all when ran like this:
$ cat
It did read standard input, but did not output anything to
standard output. fdopen() was used on STDIN_FILENO when it
shouldn't.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
|
|
| |
-R option.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
| |
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
|