summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2021-11-20 04:51:49 +0100
committerGitHub <noreply@github.com>2021-11-20 04:51:49 +0100
commitc6275374b03ac4526a46f255f33ae2f81003d52b (patch)
treeabe2682ade25671054b5981bf81f7e1b67158129 /options.c
parent43fcd2e02e113a55f673f266ad28b53858500022 (diff)
downloadnsxiv-c6275374b03ac4526a46f255f33ae2f81003d52b.tar.zst
mark functions and vars as static (#146)
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; } ```
Diffstat (limited to 'options.c')
-rw-r--r--options.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/options.c b/options.c
index 2d313de..a065be8 100644
--- a/options.c
+++ b/options.c
@@ -26,8 +26,7 @@
#include <string.h>
#include <unistd.h>
-opt_t _options;
-const opt_t *options = (const opt_t*) &_options;
+const opt_t *options;
void print_usage(void)
{
@@ -36,7 +35,7 @@ void print_usage(void)
"[-z ZOOM] FILES...\n");
}
-void print_version(void)
+static void print_version(void)
{
puts("nsxiv " VERSION);
}
@@ -46,6 +45,8 @@ void parse_options(int argc, char **argv)
int n, opt;
char *end, *s;
const char *scalemodes = "dfFwh";
+ static opt_t _options;
+ options = &_options;
progname = strrchr(argv[0], '/');
progname = progname ? progname + 1 : argv[0];