summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options.c8
-rw-r--r--util.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/options.c b/options.c
index 8e8baa7..c94c9be 100644
--- a/options.c
+++ b/options.c
@@ -98,9 +98,6 @@ void parse_options(int argc, char **argv)
static opt_t _options;
options = &_options;
- progname = strrchr(argv[0], '/');
- progname = progname ? progname + 1 : argv[0];
-
_options.from_stdin = false;
_options.to_stdout = false;
_options.using_null = false;
@@ -125,6 +122,11 @@ void parse_options(int argc, char **argv)
_options.clean_cache = false;
_options.private_mode = false;
+ if (argc > 0) {
+ s = strrchr(argv[0], '/');
+ progname = s != NULL && s[1] != '\0' ? s + 1 : argv[0];
+ }
+
optparse_init(&op, argv);
while ((opt = optparse_long(&op, longopts, NULL)) != -1) {
for (n = 0; n < (int)ARRLEN(longopts); ++n) { /* clang-tidy finds some non-sensical branch and thinks optarg == NULL is possible */
diff --git a/util.c b/util.c
index f03fe23..8b164ed 100644
--- a/util.c
+++ b/util.c
@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include <unistd.h>
-const char *progname;
+const char *progname = "nsxiv";
void* emalloc(size_t size)
{