Small code cleanups

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-07-18 17:19:37 +02:00
parent 919a40f561
commit 9d8d0c18b0
2 changed files with 16 additions and 20 deletions

View File

@ -1037,8 +1037,7 @@ void custom_config_main(void)
} else { } else {
colorize = 0; colorize = 0;
wins_erase_status_bar(); wins_erase_status_bar();
mvwaddstr(win[STA].p, 0, 0, mvwaddstr(win[STA].p, 0, 0, no_color_support);
no_color_support);
wgetch(win[KEY].p); wgetch(win[KEY].p);
} }
break; break;

View File

@ -1168,13 +1168,14 @@ void io_log_display(struct io_file *log, const char *msg,
RETURN_IF(log == NULL, _("No log file to display!")); RETURN_IF(log == NULL, _("No log file to display!"));
if (ui_mode == UI_CMDLINE) { if (ui_mode == UI_CMDLINE) {
printf("\n%s [y/n] ", msg); printf("\n%s [y/n] ", msg);
if (fgetc(stdin) == 'y') { if (fgetc(stdin) != 'y')
return;
const char *arg[] = { pager, log->name, NULL }; const char *arg[] = { pager, log->name, NULL };
int pid; int pid;
if ((pid = fork_exec(NULL, NULL, pager, arg))) if ((pid = fork_exec(NULL, NULL, pager, arg)))
child_wait(NULL, NULL, pid); child_wait(NULL, NULL, pid);
}
} else { } else {
if (status_ask_bool(msg) == 1) { if (status_ask_bool(msg) == 1) {
const char *arg[] = { pager, log->name, NULL }; const char *arg[] = { pager, log->name, NULL };
@ -1262,12 +1263,12 @@ void io_set_lock(void)
"lock file: \n\"%s\"\n" "lock file: \n\"%s\"\n"
"and restart calcurse.\n"), path_cpid); "and restart calcurse.\n"), path_cpid);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else { }
if (!io_dump_pid(path_cpid)) if (!io_dump_pid(path_cpid))
EXIT(_("FATAL ERROR: could not create %s: %s\n"), EXIT(_("FATAL ERROR: could not create %s: %s\n"),
path_cpid, strerror(errno)); path_cpid, strerror(errno));
} }
}
/* /*
* Create a new file and write the process pid inside (used to create a simple * Create a new file and write the process pid inside (used to create a simple
@ -1319,18 +1320,14 @@ unsigned io_get_pid(char *file)
int io_file_is_empty(char *file) int io_file_is_empty(char *file)
{ {
FILE *fp; FILE *fp;
int ret = -1;
if (file && (fp = fopen(file, "r"))) { if (file && (fp = fopen(file, "r"))) {
if ((fgetc(fp) == '\n' && fgetc(fp) == EOF) || feof(fp)) { ret = (fgetc(fp) == '\n' && fgetc(fp) == EOF) || feof(fp);
fclose(fp); fclose(fp);
return 1;
} else {
fclose(fp);
return 0;
}
} }
return -1; return ret;
} }
/* /*