nsxiv3a22e6a
Declare every extern function/variable in `nsxiv.h` (#268)
with a couple exceptions as they cause too many -Wshadow warnings. also moves the `extcmd_t` typedef on top for cosmetic purposes. also enable `-Wmissing-prototypes` in the ci
+53 −48
7 files changed
- M .github/workflows/build.yml +4 −2
- M commands.c +2 −25
- M commands.h +2 −0
- M main.c +10 −15
- M nsxiv.h +33 −0
- M thumbs.c +2 −4
- M window.c +0 −2
| @@ -27,9 +27,10 @@ jobs: | |||
| 27 | 27 | CFLAGS="-std=c99 -Wall -pedantic" | |
| 28 | 28 | # extra flags | |
| 29 | 29 | CFLAGS+=" -O3 -flto" | |
| 30 | − | CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes" | |
| 30 | + | CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith" | |
| 31 | 31 | CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code" | |
| 32 | 32 | CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement" | |
| 33 | + | CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes" | |
| 33 | 34 | # silence | |
| 34 | 35 | CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers" | |
| 35 | 36 | echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=1 | |
| @@ -55,9 +56,10 @@ jobs: | |||
| 55 | 56 | CFLAGS="-std=c99 -Wall -pedantic" | |
| 56 | 57 | # extra flags | |
| 57 | 58 | CFLAGS+=" -O3 -flto" | |
| 58 | − | CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes" | |
| 59 | + | CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith" | |
| 59 | 60 | CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code" | |
| 60 | 61 | CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement" | |
| 62 | + | CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes" | |
| 61 | 63 | # silence | |
| 62 | 64 | CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers" | |
| 63 | 65 | echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=0 | |
| @@ -24,34 +24,11 @@ | |||
| 24 | 24 | #include <unistd.h> | |
| 25 | 25 | #include <sys/wait.h> | |
| 26 | 26 | ||
| 27 | − | void remove_file(int, bool); | |
| 28 | − | void load_image(int); | |
| 29 | − | bool mark_image(int, bool); | |
| 30 | − | void close_info(void); | |
| 31 | − | void open_info(void); | |
| 32 | − | int nav_button(void); | |
| 33 | − | void redraw(void); | |
| 34 | − | void reset_cursor(void); | |
| 35 | − | void animate(void); | |
| 36 | − | void slideshow(void); | |
| 37 | − | void set_timeout(timeout_f, int, bool); | |
| 38 | − | void reset_timeout(timeout_f); | |
| 39 | − | void handle_key_handler(bool); | |
| 40 | − | ||
| 41 | − | extern appmode_t mode; | |
| 27 | + | #include "commands.h" | |
| 28 | + | ||
| 42 | 29 | extern img_t img; | |
| 43 | 30 | extern tns_t tns; | |
| 44 | 31 | extern win_t win; | |
| 45 | − | extern const XButtonEvent *xbutton_ev; | |
| 46 | − | ||
| 47 | − | extern fileinfo_t *files; | |
| 48 | − | extern int filecnt, fileidx; | |
| 49 | − | extern int alternate; | |
| 50 | − | extern int markcnt; | |
| 51 | − | extern int markidx; | |
| 52 | − | ||
| 53 | − | extern int prefix; | |
| 54 | − | extern bool extprefix; | |
| 55 | 32 | ||
| 56 | 33 | bool cg_quit(arg_t status) | |
| 57 | 34 | { | |
| @@ -44,6 +44,7 @@ bool ct_scroll(arg_t); | |||
| 44 | 44 | bool ct_drag_mark_image(arg_t); | |
| 45 | 45 | bool ct_select(arg_t); | |
| 46 | 46 | ||
| 47 | + | #ifdef _MAPPINGS_CONFIG | |
| 47 | 48 | /* global */ | |
| 48 | 49 | #define g_change_gamma { cg_change_gamma, MODE_ALL } | |
| 49 | 50 | #define g_first { cg_first, MODE_ALL } | |
| @@ -88,4 +89,5 @@ bool ct_select(arg_t); | |||
| 88 | 89 | #define t_drag_mark_image { ct_drag_mark_image, MODE_THUMB } | |
| 89 | 90 | #define t_select { ct_select, MODE_THUMB } | |
| 90 | 91 | ||
| 92 | + | #endif /* _MAPPINGS_CONFIG */ | |
| 91 | 93 | #endif /* COMMANDS_H */ | |
| @@ -18,8 +18,8 @@ | |||
| 18 | 18 | */ | |
| 19 | 19 | ||
| 20 | 20 | #include "nsxiv.h" | |
| 21 | − | #include "commands.h" | |
| 22 | 21 | #define _MAPPINGS_CONFIG | |
| 22 | + | #include "commands.h" | |
| 23 | 23 | #include "config.h" | |
| 24 | 24 | ||
| 25 | 25 | #include <stdlib.h> | |
| @@ -45,18 +45,18 @@ typedef struct { | |||
| 45 | 45 | timeout_f handler; | |
| 46 | 46 | } timeout_t; | |
| 47 | 47 | ||
| 48 | − | /* timeout handler functions: */ | |
| 49 | − | void redraw(void); | |
| 50 | − | void reset_cursor(void); | |
| 51 | − | void animate(void); | |
| 52 | − | void slideshow(void); | |
| 53 | − | void clear_resize(void); | |
| 48 | + | typedef struct { | |
| 49 | + | int err; | |
| 50 | + | char *cmd; | |
| 51 | + | } extcmd_t; | |
| 54 | 52 | ||
| 55 | − | appmode_t mode; | |
| 53 | + | /* these are not declared in nsxiv.h, as it causes too many -Wshadow warnings */ | |
| 56 | 54 | arl_t arl; | |
| 57 | 55 | img_t img; | |
| 58 | 56 | tns_t tns; | |
| 59 | 57 | win_t win; | |
| 58 | + | ||
| 59 | + | appmode_t mode; | |
| 60 | 60 | const XButtonEvent *xbutton_ev; | |
| 61 | 61 | ||
| 62 | 62 | fileinfo_t *files; | |
| @@ -70,11 +70,6 @@ static bool extprefix; | |||
| 70 | 70 | ||
| 71 | 71 | static bool resized = false; | |
| 72 | 72 | ||
| 73 | − | typedef struct { | |
| 74 | − | int err; | |
| 75 | − | char *cmd; | |
| 76 | − | } extcmd_t; | |
| 77 | − | ||
| 78 | 73 | static struct { | |
| 79 | 74 | extcmd_t f, ft; | |
| 80 | 75 | int fd; | |
| @@ -527,7 +522,7 @@ void clear_resize(void) | |||
| 527 | 522 | resized = false; | |
| 528 | 523 | } | |
| 529 | 524 | ||
| 530 | − | Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg) | |
| 525 | + | static Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg) | |
| 531 | 526 | { | |
| 532 | 527 | return ev->type == ButtonPress || ev->type == KeyPress; | |
| 533 | 528 | } | |
| @@ -822,7 +817,7 @@ static int fncmp(const void *a, const void *b) | |||
| 822 | 817 | return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name); | |
| 823 | 818 | } | |
| 824 | 819 | ||
| 825 | − | void sigchld(int sig) | |
| 820 | + | static void sigchld(int sig) | |
| 826 | 821 | { | |
| 827 | 822 | while (waitpid(-1, NULL, WNOHANG) > 0); | |
| 828 | 823 | } | |
| @@ -232,6 +232,10 @@ void img_toggle_antialias(img_t*); | |||
| 232 | 232 | bool img_change_gamma(img_t*, int); | |
| 233 | 233 | bool img_frame_navigate(img_t*, int); | |
| 234 | 234 | bool img_frame_animate(img_t*); | |
| 235 | + | Imlib_Image img_open(const fileinfo_t*); | |
| 236 | + | #if HAVE_LIBEXIF | |
| 237 | + | void exif_auto_orientate(const fileinfo_t*); | |
| 238 | + | #endif | |
| 235 | 239 | ||
| 236 | 240 | ||
| 237 | 241 | /* options.c */ | |
| @@ -449,4 +453,33 @@ void win_set_title(win_t*, bool); | |||
| 449 | 453 | void win_set_cursor(win_t*, cursor_t); | |
| 450 | 454 | void win_cursor_pos(win_t*, int*, int*); | |
| 451 | 455 | ||
| 456 | + | /* main.c */ | |
| 457 | + | ||
| 458 | + | /* timeout handler functions: */ | |
| 459 | + | void redraw(void); | |
| 460 | + | void reset_cursor(void); | |
| 461 | + | void animate(void); | |
| 462 | + | void slideshow(void); | |
| 463 | + | void clear_resize(void); | |
| 464 | + | ||
| 465 | + | void remove_file(int, bool); | |
| 466 | + | void set_timeout(timeout_f, int, bool); | |
| 467 | + | void reset_timeout(timeout_f); | |
| 468 | + | size_t get_win_title(unsigned char*, int, bool); | |
| 469 | + | void close_info(void); | |
| 470 | + | void open_info(void); | |
| 471 | + | void load_image(int); | |
| 472 | + | bool mark_image(int, bool); | |
| 473 | + | int nav_button(void); | |
| 474 | + | void handle_key_handler(bool); | |
| 475 | + | ||
| 476 | + | extern appmode_t mode; | |
| 477 | + | extern const XButtonEvent *xbutton_ev; | |
| 478 | + | extern fileinfo_t *files; | |
| 479 | + | extern int filecnt, fileidx; | |
| 480 | + | extern int alternate; | |
| 481 | + | extern int markcnt; | |
| 482 | + | extern int markidx; | |
| 483 | + | extern int prefix; | |
| 484 | + | ||
| 452 | 485 | #endif /* NSXIV_H */ | |
| @@ -31,9 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | 32 | #if HAVE_LIBEXIF | |
| 33 | 33 | #include <libexif/exif-data.h> | |
| 34 | − | void exif_auto_orientate(const fileinfo_t*); | |
| 35 | 34 | #endif | |
| 36 | − | Imlib_Image img_open(const fileinfo_t*); | |
| 37 | 35 | ||
| 38 | 36 | static char *cache_dir; | |
| 39 | 37 | ||
| @@ -143,7 +141,7 @@ void tns_clean_cache(void) | |||
| 143 | 141 | r_closedir(&dir); | |
| 144 | 142 | } | |
| 145 | 143 | ||
| 146 | − | void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *win) | |
| 144 | + | void tns_init(tns_t *tns, fileinfo_t *tns_files, const int *cnt, int *sel, win_t *win) | |
| 147 | 145 | { | |
| 148 | 146 | int len; | |
| 149 | 147 | const char *homedir, *dsuffix = ""; | |
| @@ -152,7 +150,7 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *wi | |||
| 152 | 150 | tns->thumbs = ecalloc(*cnt, sizeof(thumb_t)); | |
| 153 | 151 | else | |
| 154 | 152 | tns->thumbs = NULL; | |
| 155 | − | tns->files = files; | |
| 153 | + | tns->files = tns_files; | |
| 156 | 154 | tns->cnt = cnt; | |
| 157 | 155 | tns->initnext = tns->loadnext = 0; | |
| 158 | 156 | tns->first = tns->end = tns->r_first = tns->r_end = 0; | |
| @@ -30,8 +30,6 @@ | |||
| 30 | 30 | #include <X11/Xatom.h> | |
| 31 | 31 | #include <X11/Xresource.h> | |
| 32 | 32 | ||
| 33 | − | extern size_t get_win_title(unsigned char *, int, bool); | |
| 34 | − | ||
| 35 | 33 | #if HAVE_LIBFONTS | |
| 36 | 34 | #include "utf8.h" | |
| 37 | 35 | static XftFont *font; | |