summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-02-17 09:01:46 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2013-02-17 09:19:04 +0100
commita363cb9b9111aed22d105adb0e7a8e9caab9bbe3 (patch)
treeb0be8fac73932dcde5b40d6f8cee777f501d869c
parent8e16853201f8a608905cacbf1c7e4fb8ac7e568e (diff)
downloadcalcurse-a363cb9b9111aed22d105adb0e7a8e9caab9bbe3.zip
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 <calcurse@cryptocrack.de>
-rw-r--r--src/apoint.c8
-rw-r--r--src/args.c9
-rw-r--r--src/calcurse.c10
-rw-r--r--src/config.c37
-rw-r--r--src/custom.c17
-rw-r--r--src/day.c9
-rw-r--r--src/getstring.c6
-rw-r--r--src/ical.c40
-rw-r--r--src/io.c29
-rw-r--r--src/keys.c21
-rw-r--r--src/llist.c12
-rw-r--r--src/note.c4
-rw-r--r--src/notify.c17
-rw-r--r--src/recur.c9
-rw-r--r--src/sha1.c3
-rw-r--r--src/ui-calendar.c11
-rw-r--r--src/ui-todo.c4
-rw-r--r--src/utf8.c3
-rw-r--r--src/utils.c51
-rw-r--r--src/wins.c4
20 files changed, 172 insertions, 132 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 820b7ca..889c371 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -117,16 +117,16 @@ void apoint_sec2str(struct apoint *o, long day, char *start, char *end)
struct tm lt;
time_t t;
- if (o->start < day)
+ if (o->start < day) {
strncpy(start, "..:..", 6);
- else {
+ } else {
t = o->start;
localtime_r(&t, &lt);
snprintf(start, HRMIN_SIZE, "%02u:%02u", lt.tm_hour, lt.tm_min);
}
- if (o->start + o->dur > day + DAYINSEC)
+ if (o->start + o->dur > day + DAYINSEC) {
strncpy(end, "..:..", 6);
- else {
+ } else {
t = o->start + o->dur;
localtime_r(&t, &lt);
snprintf(end, HRMIN_SIZE, "%02u:%02u", lt.tm_hour, lt.tm_min);
diff --git a/src/args.c b/src/args.c
index 12d33c5..8687130 100644
--- a/src/args.c
+++ b/src/args.c
@@ -561,8 +561,9 @@ int parse_args(int argc, char **argv)
usage_try();
return EXIT_FAILURE;
}
- } else
+ } else {
tnum = -1;
+ }
break;
case 'v':
vflag = 1;
@@ -572,11 +573,11 @@ int parse_args(int argc, char **argv)
multiple_flag++;
load_data++;
if (optarg != NULL) {
- if (strcmp(optarg, "ical") == 0)
+ if (strcmp(optarg, "ical") == 0) {
xfmt = IO_EXPORT_ICAL;
- else if (strcmp(optarg, "pcal") == 0)
+ } else if (strcmp(optarg, "pcal") == 0) {
xfmt = IO_EXPORT_PCAL;
- else {
+ } else {
fputs(_("Argument for '-x' should be either "
"'ical' or 'pcal'\n"), stderr);
usage();
diff --git a/src/calcurse.c b/src/calcurse.c
index 6fd2ecb..59f912e 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -256,8 +256,9 @@ static inline void key_edit_note(void)
if (wins_slctd() == APP && ui_day_hilt() != 0) {
day_edit_note(day_get_item(ui_day_hilt()), conf.editor);
inday = do_storage(0);
- } else if (wins_slctd() == TOD && ui_todo_hilt() != 0)
+ } else if (wins_slctd() == TOD && ui_todo_hilt() != 0) {
todo_edit_note(todo_get_item(ui_todo_hilt()), conf.editor);
+ }
wins_update(FLAG_ALL);
}
@@ -465,14 +466,15 @@ static inline void key_generic_quit(void)
note_gc();
if (conf.confirm_quit) {
- if (status_ask_bool(_("Do you really want to quit ?")) == 1)
+ if (status_ask_bool(_("Do you really want to quit ?")) == 1) {
exit_calcurse(EXIT_SUCCESS);
- else {
+ } else {
wins_erase_status_bar();
wins_update(FLAG_STA);
}
- } else
+ } else {
exit_calcurse(EXIT_SUCCESS);
+ }
}
/*
diff --git a/src/config.c b/src/config.c
index 72ce7fa..083b9cf 100644
--- a/src/config.c
+++ b/src/config.c
@@ -275,8 +275,9 @@ static int config_parse_input_datefmt(void *dummy, const char *val)
if (conf.input_datefmt <= 0 || conf.input_datefmt > DATE_FORMATS)
conf.input_datefmt = 1;
return 1;
- } else
+ } else {
return 0;
+ }
}
/* Set a configuration variable. */
@@ -359,16 +360,16 @@ static void config_color_theme_name(char *theme_name)
"white"
};
- if (!colorize)
+ if (!colorize) {
strncpy(theme_name, "none", BUFSIZ);
- else {
+ } else {
pair_content(COLR_CUSTOM, &color[0], &color[1]);
for (i = 0; i < NBCOLORS; i++) {
- if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
+ if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT)) {
color_name[i] = default_color;
- else if (color[i] >= 0 && color[i] <= MAXCOLORS)
+ } else if (color[i] >= 0 && color[i] <= MAXCOLORS) {
color_name[i] = name[color[i]];
- else {
+ } else {
EXIT(_("unknown color"));
/* NOTREACHED */
}
@@ -453,8 +454,9 @@ config_serialize_conf(char *buf, const char *key,
if (status)
status->done[i] = 1;
return 1;
- } else
+ } else {
return 0;
+ }
}
}
@@ -489,8 +491,7 @@ config_file_walk(config_fn_walk_cb_t fn_cb,
if (value) {
*value = '\0';
value++;
- }
- else {
+ } else {
EXIT(_("invalid configuration directive: \"%s\""), e_conf);
}
@@ -538,12 +539,13 @@ static int config_load_cb(const char *key, const char *value, void *dummy)
{
int result = config_set_conf(key, value);
- if (result < 0)
+ if (result < 0) {
EXIT(_("configuration variable unknown: \"%s\""), key);
- /* NOTREACHED */
- else if (result == 0)
+ /* NOTREACHED */
+ } else if (result == 0) {
EXIT(_("wrong configuration variable format for \"%s\""), key);
- /* NOTREACHED */
+ /* NOTREACHED */
+ }
return 1;
}
@@ -560,12 +562,13 @@ static int config_save_cb(const char *key, const char *value, void *status)
int result =
config_serialize_conf(buf, key, (struct config_save_status *)status);
- if (result < 0)
+ if (result < 0) {
EXIT(_("configuration variable unknown: \"%s\""), key);
- /* NOTREACHED */
- else if (result == 0)
+ /* NOTREACHED */
+ } else if (result == 0) {
EXIT(_("wrong configuration variable format for \"%s\""), key);
- /* NOTREACHED */
+ /* NOTREACHED */
+ }
fputs(key, ((struct config_save_status *)status)->fp);
fputc('=', ((struct config_save_status *)status)->fp);
diff --git a/src/custom.c b/src/custom.c
index 45cd07a..6f573c5 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -455,19 +455,21 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
/* Retrieve the actual color theme. */
pair_content(COLR_CUSTOM, &colr_fore, &colr_back);
- if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
+ if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT)) {
*mark_fore = NBUSERCOLORS;
- else
+ } else {
for (i = 0; i < NBUSERCOLORS + 1; i++)
if (colr_fore == colr[i])
*mark_fore = i;
+ }
- if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
+ if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT)) {
*mark_back = SIZE - 1;
- else
+ } else {
for (i = 0; i < NBUSERCOLORS + 1; i++)
if (colr_back == colr[NBUSERCOLORS + 1 + i])
*mark_back = NBUSERCOLORS + 1 + i;
+ }
}
}
@@ -976,8 +978,9 @@ void custom_keys_config(void)
LINESPERKEY);
wins_scrollwin_display(&kwin);
continue;
- } else
+ } else {
not_recognized = 0;
+ }
/* Is the binding used by this action already? If so, just end the reassignment */
if (selrow == keys_get_action(keyval)) {
@@ -1041,9 +1044,9 @@ void custom_config_main(void)
switch (ch) {
case 'C':
case 'c':
- if (has_colors())
+ if (has_colors()) {
custom_color_config();
- else {
+ } else {
colorize = 0;
wins_erase_status_bar();
mvwaddstr(win[STA].p, 0, 0, no_color_support);
diff --git a/src/day.c b/src/day.c
index 2e3b4bf..35e17d6 100644
--- a/src/day.c
+++ b/src/day.c
@@ -72,10 +72,11 @@ static int day_cmp_start(struct day_item *a, struct day_item *b)
return 0;
else
return -1;
- } else if (b->type <= EVNT)
+ } else if (b->type <= EVNT) {
return 1;
- else
+ } else {
return a->start < b->start ? -1 : (a->start == b->start ? 0 : 1);
+ }
}
/* Add an item to the current day list. */
@@ -446,9 +447,9 @@ display_item(struct day_item *day, int incolor, int width, int y, int x)
ch_note = day_item_get_note(day) ? '>' : ' ';
if (incolor == 0)
custom_apply_attr(win, ATTR_HIGHEST);
- if (utf8_strwidth(mesg) < width)
+ if (utf8_strwidth(mesg) < width) {
mvwprintw(win, y, x, " %c%c%s", ch_recur, ch_note, mesg);
- else {
+ } else {
for (i = 0; mesg[i] && width > 0; i++) {
if (!UTF8_ISCONT(mesg[i]))
width -= utf8_width(&mesg[i]);
diff --git a/src/getstring.c b/src/getstring.c
index 3b7224d..aedd842 100644
--- a/src/getstring.c
+++ b/src/getstring.c
@@ -193,8 +193,9 @@ enum getstr getstring(WINDOW * win, char *str, int l, int x, int y)
if (st.pos > 0) {
st.pos--;
getstr_del_char(&st);
- } else
+ } else {
bell();
+ }
break;
case CTRL('D'): /* delete next character */
if (st.pos < st.len)
@@ -212,8 +213,9 @@ enum getstr getstring(WINDOW * win, char *str, int l, int x, int y)
st.pos--;
getstr_del_char(&st);
}
- } else
+ } else {
bell();
+ }
break;
case CTRL('K'): /* delete to end-of-line */
st.s[st.ci[st.pos].offset] = 0;
diff --git a/src/ical.c b/src/ical.c
index b716c8d..bd53a0c 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -114,8 +114,9 @@ static void ical_export_recur_events(FILE * stream)
if (rev->rpt->until != 0) {
date_sec2date_fmt(rev->rpt->until, ICALDATEFMT, ical_date);
fprintf(stream, ";UNTIL=%s\n", ical_date);
- } else
+ } else {
fputc('\n', stream);
+ }
if (LLIST_FIRST(&rev->exc)) {
fputs("EXDATE:", stream);
@@ -172,8 +173,9 @@ static void ical_export_recur_apoints(FILE * stream)
if (rapt->rpt->until != 0) {
date_sec2date_fmt(rapt->rpt->until + HOURINSEC, ICALDATEFMT, ical_date);
fprintf(stream, ";UNTIL=%s\n", ical_date);
- } else
+ } else {
fputc('\n', stream);
+ }
if (LLIST_FIRST(&rapt->exc)) {
fputs("EXDATE:", stream);
@@ -481,9 +483,9 @@ static long ical_durtime2long(char *timestr)
long timelong;
char *p;
- if ((p = strchr(timestr, 'T')) == NULL)
+ if ((p = strchr(timestr, 'T')) == NULL) {
timelong = 0;
- else {
+ } else {
int nbmatch;
struct {
unsigned hour, min, sec;
@@ -535,18 +537,18 @@ static long ical_dur2long(char *durstr)
} date;
memset(&date, 0, sizeof date);
- if ((p = strchr(durstr, 'P')) == NULL)
+ if ((p = strchr(durstr, 'P')) == NULL) {
durlong = NOTFOUND;
- else {
+ } else {
p++;
if (*p == '-')
return NOTFOUND;
else if (*p == '+')
p++;
- if (*p == 'T') /* dur-time */
+ if (*p == 'T') { /* dur-time */
durlong = ical_durtime2long(p);
- else if (strchr(p, 'W')) { /* dur-week */
+ } else if (strchr(p, 'W')) { /* dur-week */
if (sscanf(p, "%u", &date.week) == 1)
durlong = date.week * WEEKINDAYS * DAYINSEC;
else
@@ -556,10 +558,12 @@ static long ical_dur2long(char *durstr)
if (sscanf(p, "%uD", &date.day) == 1) {
durlong = date.day * DAYINSEC;
durlong += ical_durtime2long(p);
- } else
+ } else {
durlong = NOTFOUND;
- } else
+ }
+ } else {
durlong = NOTFOUND;
+ }
}
}
return durlong;
@@ -663,15 +667,15 @@ static ical_rpt_t *ical_read_rrule(FILE * log, char *rrulestr,
mem_free(rpt);
return NULL;
} else {
- if (strncmp(freqstr, daily, sizeof(daily) - 1) == 0)
+ if (strncmp(freqstr, daily, sizeof(daily) - 1) == 0) {
rpt->type = RECUR_DAILY;
- else if (strncmp(freqstr, weekly, sizeof(weekly) - 1) == 0)
+ } else if (strncmp(freqstr, weekly, sizeof(weekly) - 1) == 0) {
rpt->type = RECUR_WEEKLY;
- else if (strncmp(freqstr, monthly, sizeof(monthly) - 1) == 0)
+ } else if (strncmp(freqstr, monthly, sizeof(monthly) - 1) == 0) {
rpt->type = RECUR_MONTHLY;
- else if (strncmp(freqstr, yearly, sizeof(yearly) - 1) == 0)
+ } else if (strncmp(freqstr, yearly, sizeof(yearly) - 1) == 0) {
rpt->type = RECUR_YEARLY;
- else {
+ } else {
ical_log(log, ICAL_VEVENT, itemline,
_("recurrence frequence not recognized."));
(*noskipped)++;
@@ -706,8 +710,9 @@ static ical_rpt_t *ical_read_rrule(FILE * log, char *rrulestr,
} else {
rpt->count = cnt;
}
- } else
+ } else {
rpt->until = 0;
+ }
}
if ((p = strstr(rrulestr, interv)) != NULL) {
@@ -810,8 +815,9 @@ static char *ical_read_summary(char *line)
p++;
summary = ical_unformat_line(p);
return summary;
- } else
+ } else {
return NULL;
+ }
}
static void
diff --git a/src/io.c b/src/io.c
index 144ef67..c1b3631 100644
--- a/src/io.c
+++ b/src/io.c
@@ -531,8 +531,9 @@ void io_load_app(void)
} else if (c == '}') {
while ((c = getc(data_file)) == ' ') ;
ungetc(c, data_file);
- } else
+ } else {
io_load_error(path_apts, line, _("syntax error in item repetition"));
+ }
} else if (c == '!') { /* endless item with exceptions */
ungetc(c, data_file);
recur_exc_scan(&exc, data_file);
@@ -544,8 +545,9 @@ void io_load_app(void)
_("wrong format in the appointment or event"));
/* NOTREACHED */
}
- } else
+ } else {
ungetc(c, data_file);
+ }
/* Check if a note is attached to the item. */
c = getc(data_file);
@@ -571,8 +573,9 @@ void io_load_app(void)
state = 0L;
while ((c = getc(data_file)) == ' ') ;
ungetc(c, data_file);
- } else
+ } else {
io_load_error(path_apts, line, _("syntax error in item repetition"));
+ }
if (is_recursive) {
recur_apoint_scan(data_file, start, end,
type, freq, until, notep, &exc, state);
@@ -610,9 +613,9 @@ void io_load_todo(void)
for (;;) {
line++;
c = getc(data_file);
- if (c == EOF)
+ if (c == EOF) {
break;
- else if (c == '[') { /* new style with id */
+ } else if (c == '[') { /* new style with id */
if (fscanf(data_file, " %d ", &id) != 1 || getc(data_file) != ']')
io_load_error(path_todo, line, _("syntax error in item identifier"));
while ((c = getc(data_file)) == ' ') ;
@@ -623,9 +626,9 @@ void io_load_todo(void)
}
/* Now read the attached note, if any. */
c = getc(data_file);
- if (c == '>')
+ if (c == '>') {
note_read(note, data_file);
- else {
+ } else {
note[0] = '\0';
ungetc(c, data_file);
}
@@ -772,8 +775,9 @@ void io_load_keys(const char *pager)
(void)snprintf(already_assigned, BUFSIZ,
_("\"%s\" assigned multiple times!"), key_ch);
io_log_print(log, line, already_assigned);
- } else
+ } else {
assigned++;
+ }
}
p += strlen(key_ch) + 1;
} else {
@@ -826,8 +830,7 @@ unsigned io_file_exist(const char *file)
if (file && (fd = fopen(file, "r")) != NULL) {
fclose(fd);
return 1;
- }
- else {
+ } else {
return 0;
}
}
@@ -1163,8 +1166,9 @@ void io_set_lock(void)
fclose(lock);
if (kill(pid, 0) != 0 && errno == ESRCH)
lock = NULL;
- } else
+ } else {
fclose(lock);
+ }
}
if (lock != NULL) {
@@ -1264,8 +1268,9 @@ int io_file_cp(const char *src, const char *dst)
if (bytes_read > 0) {
if (fwrite(buffer, 1, bytes_read, fp_dst) != bytes_read)
return 0;
- } else
+ } else {
return 0;
+ }
}
fclose(fp_dst);
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;
+ }
}
}
}
diff --git a/src/llist.c b/src/llist.c
index 54f1e79..97e57f2 100644
--- a/src/llist.c
+++ b/src/llist.c
@@ -140,9 +140,9 @@ void llist_add(llist_t * l, void *data)
o->data = data;
o->next = NULL;
- if (!l->head)
+ if (!l->head) {
l->head = l->tail = o;
- else {
+ } else {
l->tail->next = o;
l->tail = o;
}
@@ -161,9 +161,9 @@ void llist_add_sorted(llist_t * l, void *data, llist_fn_cmp_t fn_cmp)
o->data = data;
o->next = NULL;
- if (!l->head)
+ if (!l->head) {
l->head = l->tail = o;
- else if (fn_cmp(o->data, l->tail->data) >= 0) {
+ } else if (fn_cmp(o->data, l->tail->data) >= 0) {
l->tail->next = o;
l->tail = o;
} else if (fn_cmp(o->data, l->head->data) < 0) {
@@ -186,9 +186,9 @@ void llist_remove(llist_t * l, llist_item_t * i)
{
llist_item_t *j = NULL;
- if (l->head && i == l->head)
+ if (l->head && i == l->head) {
l->head = i->next;
- else {
+ } else {
for (j = l->head; j && j->next != i; j = j->next) ;
}
diff --git a/src/note.c b/src/note.c
index 9508ea5..e8c9fb0 100644
--- a/src/note.c
+++ b/src/note.c
@@ -94,9 +94,9 @@ void edit_note(char **note, const char *editor)
wins_launch_external(tmppath, editor);
- if (io_file_is_empty(tmppath) > 0)
+ if (io_file_is_empty(tmppath) > 0) {
erase_note(note);
- else if ((fp = fopen(tmppath, "r"))) {
+ } else if ((fp = fopen(tmppath, "r"))) {
sha1_stream(fp, sha1);
fclose(fp);
*note = sha1;
diff --git a/src/notify.c b/src/notify.c
index cb56e8c..36aad5a 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -140,9 +140,9 @@ static void extract_aptsfile(void)
char *file;
file = strrchr(path_apts, '/');
- if (!file)
+ if (!file) {
notify.apts_file = path_apts;
- else {
+ } else {
notify.apts_file = file;
notify.apts_file++;
}
@@ -455,8 +455,9 @@ void notify_check_added(char *mesg, long start, char state)
update_notify = 1;
} else if (start < notify_app.time && start >= current_time) {
update_notify = 1;
- } else if (start == notify_app.time && state != notify_app.state)
+ } else if (start == notify_app.time && state != notify_app.state) {
update_notify = 1;
+ }
if (update_notify) {
notify_update_app(start, state, mesg);
@@ -482,8 +483,9 @@ void notify_check_repeated(struct recur_apoint *i)
update_notify = 1;
} else if (real_app_time < notify_app.time && real_app_time >= current_time) {
update_notify = 1;
- } else if (real_app_time == notify_app.time && i->state != notify_app.state)
+ } else if (real_app_time == notify_app.time && i->state != notify_app.state) {
update_notify = 1;
+ }
}
if (update_notify) {
notify_update_app(real_app_time, i->state, i->mesg);
@@ -548,9 +550,9 @@ print_option(WINDOW * win, unsigned x, unsigned y, char *name,
maxlen = MAXCOL - x_opt - 2;
custom_apply_attr(win, ATTR_HIGHEST);
- if (len < maxlen)
+ if (len < maxlen) {
mvwaddstr(win, y, x_opt, valstr);
- else {
+ } else {
char buf[BUFSIZ];
strncpy(buf, valstr, maxlen - 1);
@@ -558,8 +560,9 @@ print_option(WINDOW * win, unsigned x, unsigned y, char *name,
mvwprintw(win, y, x_opt, "%s...", buf);
}
custom_remove_attr(win, ATTR_HIGHEST);
- } else
+ } else {
print_bool_option_incolor(win, valbool, y, x_opt);
+ }
mvwaddstr(win, y + 1, x, desc);
}
diff --git a/src/recur.c b/src/recur.c
index e9312e7..6a3a902 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -203,8 +203,9 @@ struct recur_apoint *recur_apoint_new(char *mesg, char *note, long start,
if (except) {
exc_dup(&rapt->exc, except);
free_exc_list(except);
- } else
+ } else {
LLIST_INIT(&rapt->exc);
+ }
LLIST_TS_LOCK(&recur_alist_p);
LLIST_TS_ADD_SORTED(&recur_alist_p, rapt, recur_apoint_cmp_start);
@@ -231,8 +232,9 @@ struct recur_event *recur_event_new(char *mesg, char *note, long day, int id,
if (except) {
exc_dup(&rev->exc, except);
free_exc_list(except);
- } else
+ } else {
LLIST_INIT(&rev->exc);
+ }
LLIST_ADD_SORTED(&recur_elist, rev, recur_event_cmp_day);
@@ -627,8 +629,9 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
}
return 1;
- } else
+ } else {
return 0;
+ }
}
unsigned
diff --git a/src/sha1.c b/src/sha1.c
index 0388e3c..ad68bd3 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -197,8 +197,9 @@ void sha1_update(sha1_ctx_t * ctx, const uint8_t * data, unsigned int len)
for (; i + 63 < len; i += 64)
sha1_transform(ctx->state, &data[i]);
j = 0;
- } else
+ } else {
i = 0;
+ }
memcpy(&ctx->buffer[j], &data[i], len - i);
}
diff --git a/src/ui-calendar.c b/src/ui-calendar.c
index f9749c8..a312a99 100644
--- a/src/ui-calendar.c
+++ b/src/ui-calendar.c
@@ -260,9 +260,9 @@ static int date_change(struct tm *date, int delta_month, int delta_day)
t.tm_mon += delta_month;
t.tm_mday += delta_day;
- if (mktime(&t) == -1)
+ if (mktime(&t) == -1) {
return 1;
- else {
+ } else {
*date = t;
return 0;
}
@@ -338,8 +338,7 @@ draw_monthly_view(struct window *cwin, struct date *current_day,
/* check if the day contains an event or an appointment */
if (monthly_view_cache_valid) {
item_this_day = monthly_view_cache[c_day - 1];
- }
- else {
+ } else {
item_this_day = monthly_view_cache[c_day - 1] =
day_check_if_item(check_day);
}
@@ -625,9 +624,9 @@ void ui_calendar_change_day(int datefmt)
while (wrong_day) {
snprintf(outstr, BUFSIZ, request_date, DATEFMT_DESC(datefmt));
status_mesg(outstr, "");
- if (getstring(win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC)
+ if (getstring(win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC) {
return;
- else {
+ } else {
if (strlen(selected_day) == 0) {
wrong_day = 0;
ui_calendar_goto_today();
diff --git a/src/ui-todo.c b/src/ui-todo.c
index d034881..baecff8 100644
--- a/src/ui-todo.c
+++ b/src/ui-todo.c
@@ -227,9 +227,9 @@ display_todo_item(int incolor, char *msg, int prio, int note, int width, int y,
if (incolor == 0)
custom_apply_attr(w, ATTR_HIGHEST);
- if (utf8_strwidth(msg) < width)
+ if (utf8_strwidth(msg) < width) {
mvwprintw(w, y, x, "%s%c %s", priostr, ch_note, msg);
- else {
+ } else {
for (i = 0; msg[i] && width > 0; i++) {
if (!UTF8_ISCONT(msg[i]))
width -= utf8_width(&msg[i]);
diff --git a/src/utf8.c b/src/utf8.c
index 6ec8eca..64b59d1 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -313,8 +313,9 @@ int utf8_width(char *s)
return utf8_widthtab[cur].width;
else
low = cur + 1;
- } else
+ } else {
high = cur - 1;
+ }
}
while (low <= high);
diff --git a/src/utils.c b/src/utils.c
index c20e767..b7dbf42 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -77,8 +77,9 @@ void exit_calcurse(int status)
endwin();
ui_mode = UI_CMDLINE;
was_interactive = 1;
- } else
+ } else {
was_interactive = 0;
+ }
ui_calendar_stop_date_thread();
io_stop_psave_thread();
@@ -379,9 +380,9 @@ char *date_sec2date_str(long sec, const char *datefmt)
struct tm lt;
char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
- if (sec == 0)
- strncpy(datestr, "0", BUFSIZ);
- else {
+ if (sec == 0) {
+ strncpy(datestr, "0", BUFSIZ)
+ } else {
localtime_r((time_t *)&sec, &lt);
strftime(datestr, BUFSIZ, datefmt, &lt);
}
@@ -574,8 +575,9 @@ print_bool_option_incolor(WINDOW * win, unsigned option, int pos_y, int pos_x)
} else if (option == 0) {
color = ATTR_FALSE;
option_value = _("no");
- } else
+ } else {
EXIT(_("option not defined"));
+ }
custom_apply_attr(win, color);
mvwaddstr(win, pos_y, pos_x, option_value);
@@ -660,10 +662,11 @@ parse_date(const char *date_string, enum datefmt datefmt, int *year,
if (*p == sep) {
if ((++n) > 2)
return 0;
- } else if ((*p >= '0') && (*p <= '9'))
+ } else if ((*p >= '0') && (*p <= '9')) {
in[n] = in[n] * 10 + (int)(*p - '0');
- else
+ } else {
return 0;
+ }
}
if ((!slctd_date && n < 2) || in[n] == 0)
@@ -741,8 +744,9 @@ int parse_time(const char *string, unsigned *hour, unsigned *minute)
if ((n == 0) && (p == (string + 2)) && *(p + 1))
n++;
in[n] = in[n] * 10 + (int)(*p - '0');
- } else
+ } else {
return 0;
+ }
}
if (n != 1 || in[0] >= DAYINHOURS || in[1] >= HOURINMIN)
@@ -804,8 +808,9 @@ int parse_duration(const char *string, unsigned *duration)
} else if (*p == 'm') {
dur += in;
state = STATE_DONE;
- } else
+ } else {
return 0;
+ }
break;
case STATE_DDHHMM_HH:
if (*p == 'h') {
@@ -814,15 +819,17 @@ int parse_duration(const char *string, unsigned *duration)
} else if (*p == 'm') {
dur += in;
state = STATE_DONE;
- } else
+ } else {
return 0;
+ }
break;
case STATE_DDHHMM_MM:
if (*p == 'm') {
dur += in;
state = STATE_DONE;
- } else
+ } else {
return 0;
+ }
break;
case STATE_HHMM_MM:
return 0;
@@ -1015,8 +1022,9 @@ static void print_notefile(FILE * out, const char *filename, int nbtab)
for (i = 0; i < nbtab; i++)
linestarter[i] = '\t';
linestarter[nbtab] = '\0';
- } else
+ } else {
linestarter[0] = '\0';
+ }
snprintf(path_to_notefile, BUFSIZ, "%s/%s", path_notes, filename);
notefile = fopen(path_to_notefile, "r");
@@ -1168,9 +1176,9 @@ static void print_date(long date, long day, const char *extformat)
{
char buf[BUFSIZ];
- if (!strcmp(extformat, "epoch"))
+ if (!strcmp(extformat, "epoch")) {
printf("%ld", date);
- else {
+ } else {
time_t t = date;
struct tm lt;
@@ -1227,10 +1235,11 @@ void print_apoint(const char *format, long day, struct apoint *apt)
putchar('?');
break;
}
- } else if (*p == '\\')
+ } else if (*p == '\\') {
p += print_escape(p);
- else
+ } else {
putchar(*p);
+ }
}
}
@@ -1263,10 +1272,11 @@ void print_event(const char *format, long day, struct event *ev)
putchar('?');
break;
}
- } else if (*p == '\\')
+ } else if (*p == '\\') {
p += print_escape(p);
- else
+ } else {
putchar(*p);
+ }
}
}
@@ -1328,9 +1338,10 @@ void print_todo(const char *format, struct todo *todo)
putchar('?');
break;
}
- } else if (*p == '\\')
+ } else if (*p == '\\') {
p += print_escape(p);
- else
+ } else {
putchar(*p);
+ }
}
}
diff --git a/src/wins.c b/src/wins.c
index d8f1f45..1267552 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -175,9 +175,9 @@ void wins_set_layout(int nb)
/* Get the current side bar width. */
unsigned wins_sbar_width(void)
{
- if (sbarwidth_perc > SBARMAXWIDTHPERC)
+ if (sbarwidth_perc > SBARMAXWIDTHPERC) {
return col * SBARMAXWIDTHPERC / 100;
- else {
+ } else {
unsigned sbarwidth = (unsigned)(col * sbarwidth_perc / 100);
return (sbarwidth < SBARMINWIDTH) ? SBARMINWIDTH : sbarwidth;
}