From a363cb9b9111aed22d105adb0e7a8e9caab9bbe3 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 17 Feb 2013 09:01:46 +0100 Subject: Fix braces in if-else statements From the Linux kernel coding guidelines: Do not unnecessarily use braces where a single statement will do. [...] This does not apply if one branch of a conditional statement is a single statement. Use braces in both branches. Signed-off-by: Lukas Fleischer --- src/keys.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/keys.c') diff --git a/src/keys.c b/src/keys.c index 5d53a1e..f4b81c7 100644 --- a/src/keys.c +++ b/src/keys.c @@ -199,11 +199,9 @@ enum key keys_getch(WINDOW * win, int *count, int *reg) ch = wgetch(win); if (ch >= '1' && ch <= '9') { *reg = ch - '1' + 1; - } - else if (ch >= 'a' && ch <= 'z') { + } else if (ch >= 'a' && ch <= 'z') { *reg = ch - 'a' + 10; - } - else if (ch == '_') { + } else if (ch == '_') { *reg = REG_BLACK_HOLE; } ch = wgetch(win); @@ -230,9 +228,9 @@ static void add_key_str(enum key action, int key) int keys_assign_binding(int key, enum key action) { - if (key < 0 || key > MAXKEYVAL || actions[key] != KEY_UNDEF) + if (key < 0 || key > MAXKEYVAL || actions[key] != KEY_UNDEF) { return 1; - else { + } else { actions[key] = action; add_key_str(action, key); } @@ -281,9 +279,9 @@ int keys_str2int(const char *key) if (!key) return -1; - if (strlen(key) == 1) + if (strlen(key) == 1) { return (int)key[0]; - else { + } else { if (key[0] == '^') return CTRL((int)key[1]); else if (!strncmp(key, CONTROL_KEY, sizeof(CONTROL_KEY) - 1)) @@ -390,9 +388,9 @@ static char *keys_format_label(char *key, int keylen) return NULL; memset(fmtkey, 0, sizeof(fmtkey)); - if (len == 0) + if (len == 0) { strncpy(fmtkey, "?", sizeof(fmtkey)); - else if (len <= keylen) { + } else if (len <= keylen) { for (i = 0; i < keylen - len; i++) fmtkey[i] = ' '; strncat(fmtkey, key, keylen); @@ -594,8 +592,9 @@ void keys_fill_missing(void) "\"%s\" was already assigned!"), keydef[i].label, key_ch); p += strlen(key_ch) + 1; - } else + } else { break; + } } } } -- cgit v1.2.3-54-g00ecf