currently the error messages have the shortopt hardcoded in them, even
when the user actually entered a longopt:
$ ./nsxiv --framerate v
nsxiv: Invalid argument for option -A: v
and as far as I see, there's no way to *reliably* tell weather we're
processing a longopt or a shortopt. perhaps we can do some shenanigangs
with `optind` but that seems finicky at best.
and it seems like other coreutils which support longopt has similar issues:
$ xargs --max-procs=z
xargs: invalid number "z" for -P option
utils like `grep` and `head` seems to work-around it by not mentioning the flag:
$ head --lines=z
head: invalid number of lines: ‘z’
$ grep --max-count=l
grep: invalid max count
this patch does the same thing as `grep/head` and omits the flag from
the error message.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/368
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/371
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
strtol() returns a `long`, but we're storing the result in an `int`
which might end up getting truncated. change `n` to `long` and guard
against >INT_MAX arguments in cases where it matters.
use a float for storing argument of `-S`
change `opt.slideshow` to `unsigned` similar to `img.ss.delay`
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/367
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
simply running nsxiv with `--anti-alias` will enable anti-aliasing, and
running it with `--anti-alias=no` will disable it.
the cli flag will overwrite the config.h default.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/349
handle a rare, but possible case of argc being 0, in which case argv[0]
would be null.
note that both POSIX and ISO C standard allow argc to be 0 and in
practice this can be triggered via calling `exec(3)` family of functions
with NULL as the first `argv`.
Uses [optparse] to add support for long-opts. optparse is posix
compliant with getopt(3) and thus would be backwards compatible.
It does not have any dependency (not even the c standard library!) and
is C89 compatible and thus fits our current code-style.
[optparse]: https://github.com/skeeto/optparse
Note that we're using a couple `pragma`-s to silence some harmless
warnings. This should be portable because these pragma-s don't change the
behavior of the program. Furthermore, C standard mandates that unknown
pragma's should be ignored by the compiler and thus would not result in
build failure on compilers which do not recognize them.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/328
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/332
Reviewed-by: eylles <eylles@noreply.codeberg.org>
* includes are sorted alphabetically
* their grouping and layout is the following:
- nsxiv.h will be the first include
- followed by any internal headers (e.g "commands.h" "config.h")
- followed by system headers (<stdlib.h> etc)
- followed by third party headers (X.h libwebp etc)
* also add `llvm-include-order` check to clang-tidy so that it can catch
unsorted includes during CI.
* rm unused include <sys/types.h>
* move <sys/time.h> to main.c, it's the only file that needs it.
* move TV_* macros to main.c
* let *.c files explicitly include what they need instead of including
them at nsxiv.h
the goal here to mark functions and variables not used outside the
translation unit as static. main reason for this is cleanliness. however
as a side-effect this can help compilers optimize better as it now has
guarantee that a certain function won't be called outside of that
translation unit.
one other side-effect of this is that accessing these vars/function from
config.h is now different.
if one wants to access a static var/func from different translation unit
in config.h, he would have to create a wrapper function under the right
ifdef. for static functions one would also need to forward declare it.
here's a dummy example of accessing the function `run_key_handler` from
config.h under _MAPPINGS_CONFIG
```
static void run_key_handler(const char *, unsigned);
bool send_with_ctrl(arg_t key) {
run_key_handler(XKeysymToString(key), ControlMask);
return false;
}
```
with this change `-0` is turned into a more generic switch which can be
used to send NULL-separated file-list to the key-handler as well.
this also means `-0` no longer implicitly enables `-o`
Closes: https://github.com/nsxiv/nsxiv/issues/140
* tns_clean_cache: remove unused function arg
* remove malloc casting
* improve consistency
use sizeof(T) at the end
* avoid comparing integers of different signedness
* use Window type for embed and parent
* remove unnecessary comparisons
* remove cpp style comments
* improve consistency: remove comma from the end of enumerator list
* Removed useless _IMAGE_CONFIG defines
* consistency: use the same order as snprintf
* Resolve c89 warnings
Co-authored-by: uidops <uidops@protonmail.com>
Co-authored-by: Arthur Williams <taaparthur@gmail.com>
* add -0 for outputting null-terminated list
this doesn't add much, if any, additional complexity to the codebase and
can be quite handy for scripting purposes.
Closes: https://github.com/nsxiv/nsxiv/issues/67
* Fix typo
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
VERSION string between releases is last release suffixed with '+'.
Additionally, use output of git-describe instead of VERSION string, if it is
not empty.
- Functions warn() and die() replaced by GNU-like error(3) function
- Register cleanup() with atexit(3)
- Functions called by cleanup() are marked with CLEANUP and are not allowed to
call exit(3)
- Scale mode is not reset to default value upon image loading anymore
- New default key binding to change mode to scale-down
- Removed scale mode setting from config.h
- Removed -d command line option, as this is now the default at startup