summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-07-18 17:19:37 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-07-18 17:19:37 +0200
commit9d8d0c18b0329f11990b8e0f2d65424967b6293f (patch)
treedb4423a399d84199d5c69c4692fab8bd2af3eab9 /src
parent919a40f5612b5b2ce91284de337da17d6161edad (diff)
downloadcalcurse-9d8d0c18b0329f11990b8e0f2d65424967b6293f.zip
Small code cleanups
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/custom.c3
-rw-r--r--src/io.c33
2 files changed, 16 insertions, 20 deletions
diff --git a/src/custom.c b/src/custom.c
index 08daa44..b3d5da5 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -1037,8 +1037,7 @@ void custom_config_main(void)
} else {
colorize = 0;
wins_erase_status_bar();
- mvwaddstr(win[STA].p, 0, 0,
- no_color_support);
+ mvwaddstr(win[STA].p, 0, 0, no_color_support);
wgetch(win[KEY].p);
}
break;
diff --git a/src/io.c b/src/io.c
index ba20610..1ac8cd4 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1168,13 +1168,14 @@ void io_log_display(struct io_file *log, const char *msg,
RETURN_IF(log == NULL, _("No log file to display!"));
if (ui_mode == UI_CMDLINE) {
printf("\n%s [y/n] ", msg);
- if (fgetc(stdin) == 'y') {
- const char *arg[] = { pager, log->name, NULL };
- int pid;
+ if (fgetc(stdin) != 'y')
+ return;
- if ((pid = fork_exec(NULL, NULL, pager, arg)))
- child_wait(NULL, NULL, pid);
- }
+ const char *arg[] = { pager, log->name, NULL };
+ int pid;
+
+ if ((pid = fork_exec(NULL, NULL, pager, arg)))
+ child_wait(NULL, NULL, pid);
} else {
if (status_ask_bool(msg) == 1) {
const char *arg[] = { pager, log->name, NULL };
@@ -1262,11 +1263,11 @@ void io_set_lock(void)
"lock file: \n\"%s\"\n"
"and restart calcurse.\n"), path_cpid);
exit(EXIT_FAILURE);
- } else {
- if (!io_dump_pid(path_cpid))
- EXIT(_("FATAL ERROR: could not create %s: %s\n"),
- path_cpid, strerror(errno));
}
+
+ if (!io_dump_pid(path_cpid))
+ EXIT(_("FATAL ERROR: could not create %s: %s\n"),
+ path_cpid, strerror(errno));
}
/*
@@ -1319,18 +1320,14 @@ unsigned io_get_pid(char *file)
int io_file_is_empty(char *file)
{
FILE *fp;
+ int ret = -1;
if (file && (fp = fopen(file, "r"))) {
- if ((fgetc(fp) == '\n' && fgetc(fp) == EOF) || feof(fp)) {
- fclose(fp);
- return 1;
- } else {
- fclose(fp);
- return 0;
- }
+ ret = (fgetc(fp) == '\n' && fgetc(fp) == EOF) || feof(fp);
+ fclose(fp);
}
- return -1;
+ return ret;
}
/*