From 1449bfc5e960a61438c60a67c28da6d7c5bf2c7f Mon Sep 17 00:00:00 2001 From: Berke Kocaoğlu Date: Mon, 11 Oct 2021 06:07:18 +0300 Subject: code-style: fix consistency issues all over the codebase (#94) * remove duplicate comment * remove empty tabs and blank lines * move macros and globals ontop * comment to seprate function implementation * fix alignment * switch to *argv[] similar to other suckless code * kill all empty last lines * append comment to endif * reuse existing ARRLEN macro * comment fall through * use while (true) everywhere Co-authored-by: NRK --- main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f3eeb0a..9fdda54 100644 --- a/main.c +++ b/main.c @@ -34,6 +34,9 @@ #include #include +#define MODMASK(mask) ((mask) & ~ignore_mask) +#define BAR_SEP " " + typedef struct { struct timeval when; bool active; @@ -93,6 +96,9 @@ cursor_t imgcursor[3] = { CURSOR_ARROW, CURSOR_ARROW, CURSOR_ARROW }; +/************************** + function implementations + **************************/ void cleanup(void) { img_close(&img, false); @@ -346,8 +352,6 @@ void bar_put(win_bar_t *bar, const char *fmt, ...) va_end(ap); } -#define BAR_SEP " " - void update_info(void) { unsigned int i, fn, fw; @@ -554,7 +558,7 @@ void run_key_handler(const char *key, unsigned int mask) for (f = i = 0; f < fcnt; i++) { if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) { if (stat(files[i].path, &st) != 0 || - memcmp(&oldst[f].st_mtime, &st.st_mtime, sizeof(st.st_mtime)) != 0) + memcmp(&oldst[f].st_mtime, &st.st_mtime, sizeof(st.st_mtime)) != 0) { if (tns.thumbs != NULL) { tns_unload(&tns, i); @@ -582,8 +586,6 @@ end: redraw(); } -#define MODMASK(mask) ((mask) & ~ignore_mask) - void on_keypress(XKeyEvent *kev) { int i; @@ -607,7 +609,7 @@ void on_keypress(XKeyEvent *kev) handle_key_handler(false); } else if (extprefix) { run_key_handler(XKeysymToString(ksym), kev->state & ~sh); - extprefix = False; + extprefix = false; } else if (key >= '0' && key <= '9') { /* number prefix for commands */ prefix = prefix * 10 + (int) (key - '0'); @@ -675,7 +677,7 @@ void on_buttonpress(XButtonEvent *bev) bool on = !(files[sel].flags & FF_MARK); XEvent e; - for (;;) { + while (true) { if (sel >= 0 && mark_image(sel, on)) redraw(); XMaskEvent(win.env.dpy, @@ -836,7 +838,7 @@ void setup_signal(int sig, void (*handler)(int sig)) error(EXIT_FAILURE, errno, "signal %d", sig); } -int main(int argc, char **argv) +int main(int argc, char *argv[]) { int i, start; size_t n; -- cgit v1.2.3-54-g00ecf