diff options
Diffstat (limited to 'src/custom.c')
-rw-r--r-- | src/custom.c | 460 |
1 files changed, 256 insertions, 204 deletions
diff --git a/src/custom.c b/src/custom.c index 1f75978..5700640 100644 --- a/src/custom.c +++ b/src/custom.c @@ -37,13 +37,14 @@ #include <string.h> #include <stdlib.h> #include <math.h> +#include <ctype.h> #include "calcurse.h" /* Available configuration variables. */ enum conf_var { - CUSTOM_CONF_NOVARIABLE, CUSTOM_CONF_AUTOSAVE, + CUSTOM_CONF_AUTOGC, CUSTOM_CONF_PERIODICSAVE, CUSTOM_CONF_CONFIRMQUIT, CUSTOM_CONF_CONFIRMDELETE, @@ -59,11 +60,43 @@ enum conf_var { CUSTOM_CONF_NOTIFYBARCLOCK, CUSTOM_CONF_NOTIFYBARWARNING, CUSTOM_CONF_NOTIFYBARCOMMAND, + CUSTOM_CONF_NOTIFYALL, CUSTOM_CONF_OUTPUTDATEFMT, CUSTOM_CONF_INPUTDATEFMT, CUSTOM_CONF_DMON_ENABLE, CUSTOM_CONF_DMON_LOG, - CUSTOM_CONF_VARIABLES + CUSTOM_CONF_INVALID +}; + +struct conf_varname { + enum conf_var var; + const char *name; +}; + +static struct conf_varname conf_varmap[] = +{ + { CUSTOM_CONF_AUTOSAVE, "auto_save" }, + { CUSTOM_CONF_AUTOGC, "auto_gc" }, + { CUSTOM_CONF_PERIODICSAVE, "periodic_save" }, + { CUSTOM_CONF_CONFIRMQUIT, "confirm_quit" }, + { CUSTOM_CONF_CONFIRMDELETE, "confirm_delete" }, + { CUSTOM_CONF_SKIPSYSTEMDIALOGS, "skip_system_dialogs" }, + { CUSTOM_CONF_SKIPPROGRESSBAR, "skip_progress_bar" }, + { CUSTOM_CONF_CALENDAR_DEFAULTVIEW, "calendar_default_view" }, + { CUSTOM_CONF_WEEKBEGINSONMONDAY, "week_begins_on_monday" }, + { CUSTOM_CONF_COLORTHEME, "color-theme" }, + { CUSTOM_CONF_LAYOUT, "layout" }, + { CUSTOM_CONF_SBAR_WIDTH, "side-bar_width" }, + { CUSTOM_CONF_NOTIFYBARSHOW, "notify-bar_show" }, + { CUSTOM_CONF_NOTIFYBARDATE, "notify-bar_date" }, + { CUSTOM_CONF_NOTIFYBARCLOCK, "notify-bar_clock" }, + { CUSTOM_CONF_NOTIFYBARWARNING, "notify-bar_warning" }, + { CUSTOM_CONF_NOTIFYBARCOMMAND, "notify-bar_command" }, + { CUSTOM_CONF_NOTIFYALL, "notify-all" }, + { CUSTOM_CONF_OUTPUTDATEFMT, "output_datefmt" }, + { CUSTOM_CONF_INPUTDATEFMT, "input_datefmt" }, + { CUSTOM_CONF_DMON_ENABLE, "notify-daemon_enable" }, + { CUSTOM_CONF_DMON_LOG, "notify-daemon_log" } }; struct attribute { @@ -73,18 +106,39 @@ struct attribute { static struct attribute attr; -static unsigned -fill_config_var (char *string) +static int +conf_parse_bool (unsigned *dest, char *val) { - if (strncmp (string, "yes", 3) == 0) - return 1; - else if (strncmp (string, "no", 2) == 0) + if (strncmp (val, "yes", 4) == 0) + *dest = 1; + else if (strncmp (val, "no", 3) == 0) + *dest = 0; + else return 0; + + return 1; +} + +static int +conf_parse_unsigned (unsigned *dest, char *val) +{ + if (is_all_digit (val)) + *dest = atoi (val); else - { - EXIT (_("wrong configuration variable format.")); - return 0; - } + return 0; + + return 1; +} + +static int +conf_parse_int (int *dest, char *val) +{ + if ((*val == '+' || *val == '-' || isdigit (*val)) && is_all_digit (val + 1)) + *dest = atoi (val); + else + return 0; + + return 1; } /* @@ -92,8 +146,8 @@ fill_config_var (char *string) * Need to handle calcurse versions prior to 1.8, where colors where handled * differently (number between 1 and 8). */ -static void -custom_load_color (char *color, int background) +static int +conf_parse_color (char *val) { #define AWAITED_COLORS 2 @@ -101,15 +155,12 @@ custom_load_color (char *color, int background) char c[AWAITED_COLORS][BUFSIZ]; int colr[AWAITED_COLORS]; - len = strlen (color); + len = strlen (val); if (len > 1) { /* New version configuration */ - if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS) - { - EXIT (_("missing colors in config file")); - /* NOTREACHED */ - } + if (sscanf (val, "%s on %s", c[0], c[1]) != AWAITED_COLORS) + return 0; for (i = 0; i < AWAITED_COLORS; i++) { @@ -132,17 +183,17 @@ custom_load_color (char *color, int background) else if (!strncmp (c[i], "default", 7)) colr[i] = background; else - { - EXIT (_("wrong color name")); - /* NOTREACHED */ - } + return 0; } init_pair (COLR_CUSTOM, colr[0], colr[1]); } - else if (len > 0 && len < 2) + else if (len == 1) { /* Old version configuration */ - color_num = atoi (color); + if (isdigit (*val)) + color_num = atoi (val); + else + return 0; switch (color_num) { @@ -174,15 +225,13 @@ custom_load_color (char *color, int background) init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE); break; default: - EXIT (_("wrong color number")); - /* NOTREACHED */ + return 0; } } else - { - EXIT (_("wrong configuration variable format")); - /* NOTREACHED */ - } + return 0; + + return 1; } /* @@ -233,15 +282,107 @@ custom_remove_attr (WINDOW *win, int attr_num) wattroff (win, attr.nocolor[attr_num]); } +/* Set a configuration variable. */ +static int +custom_set_conf (struct conf *conf, enum conf_var var, char *val) +{ + unsigned tmp; + + switch (var) + { + case CUSTOM_CONF_AUTOSAVE: + return conf_parse_bool (&conf->auto_save, val); + break; + case CUSTOM_CONF_AUTOGC: + return conf_parse_bool (&conf->auto_gc, val); + break; + case CUSTOM_CONF_PERIODICSAVE: + return conf_parse_unsigned (&conf->periodic_save, val); + break; + case CUSTOM_CONF_CONFIRMQUIT: + return conf_parse_bool (&conf->confirm_quit, val); + break; + case CUSTOM_CONF_CONFIRMDELETE: + return conf_parse_bool (&conf->confirm_delete, val); + break; + case CUSTOM_CONF_SKIPSYSTEMDIALOGS: + return conf_parse_bool (&conf->skip_system_dialogs, val); + break; + case CUSTOM_CONF_SKIPPROGRESSBAR: + return conf_parse_bool (&conf->skip_progress_bar, val); + break; + case CUSTOM_CONF_CALENDAR_DEFAULTVIEW: + calendar_set_view (atoi (val)); + break; + case CUSTOM_CONF_WEEKBEGINSONMONDAY: + return conf_parse_bool (&tmp, val); + if (tmp) + calendar_set_first_day_of_week (MONDAY); + else + calendar_set_first_day_of_week (SUNDAY); + break; + case CUSTOM_CONF_COLORTHEME: + return conf_parse_color (val); + break; + case CUSTOM_CONF_LAYOUT: + wins_set_layout (atoi (val)); + break; + case CUSTOM_CONF_SBAR_WIDTH: + wins_set_sbar_width (atoi (val)); + break; + case CUSTOM_CONF_NOTIFYBARSHOW: + return conf_parse_bool (&nbar.show, val); + break; + case CUSTOM_CONF_NOTIFYBARDATE: + strncpy (nbar.datefmt, val, strlen (val) + 1); + break; + case CUSTOM_CONF_NOTIFYBARCLOCK: + strncpy (nbar.timefmt, val, strlen (val) + 1); + break; + case CUSTOM_CONF_NOTIFYBARWARNING: + return conf_parse_int (&nbar.cntdwn, val); + break; + case CUSTOM_CONF_NOTIFYBARCOMMAND: + strncpy (nbar.cmd, val, strlen (val) + 1); + break; + case CUSTOM_CONF_NOTIFYALL: + return conf_parse_bool(&nbar.notify_all, val); + break; + case CUSTOM_CONF_OUTPUTDATEFMT: + if (val[0] != '\0') + strncpy (conf->output_datefmt, val, strlen (val) + 1); + break; + case CUSTOM_CONF_INPUTDATEFMT: + return conf_parse_int (&conf->input_datefmt, val); + if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) + conf->input_datefmt = 1; + break; + case CUSTOM_CONF_DMON_ENABLE: + return conf_parse_bool (&dmon.enable, val); + break; + case CUSTOM_CONF_DMON_LOG: + return conf_parse_bool (&dmon.log, val); + break; + default: + return 0; + break; + } + + return 1; +} + /* Load the user configuration. */ void -custom_load_conf (struct conf *conf, int background) +custom_load_conf (struct conf *conf) { FILE *data_file; char *mesg_line1 = _("Failed to open config file"); char *mesg_line2 = _("Press [ENTER] to continue"); char buf[BUFSIZ], e_conf[BUFSIZ]; + int i; + char *name; enum conf_var var; + char *val; data_file = fopen (path_conf, "r"); if (data_file == NULL) @@ -249,156 +390,57 @@ custom_load_conf (struct conf *conf, int background) status_mesg (mesg_line1, mesg_line2); wnoutrefresh (win[STA].p); wins_doupdate (); - (void)keys_getch (win[STA].p); + keys_getch (win[STA].p, NULL); } - var = CUSTOM_CONF_NOVARIABLE; + pthread_mutex_lock (&nbar.mutex); for (;;) { if (fgets (buf, sizeof buf, data_file) == NULL) + break; + io_extract_data (e_conf, buf, sizeof buf); + + if (*e_conf == '\0') + continue; + + name = e_conf; + val = strchr (e_conf, '='); + if (val) { - break; + *val = '\0'; + val++; } - io_extract_data (e_conf, buf, sizeof buf); - switch (var) + var = CUSTOM_CONF_INVALID; + for (i = 0; i < sizeof (conf_varmap) / sizeof (struct conf_varname); i++) { - case CUSTOM_CONF_NOVARIABLE: - break; - case CUSTOM_CONF_AUTOSAVE: - conf->auto_save = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_PERIODICSAVE: - if (atoi (e_conf) < 0) - conf->periodic_save = 0; - else - conf->periodic_save = atoi (e_conf); - var = 0; - break; - case CUSTOM_CONF_CONFIRMQUIT: - conf->confirm_quit = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_CONFIRMDELETE: - conf->confirm_delete = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_SKIPSYSTEMDIALOGS: - conf->skip_system_dialogs = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_SKIPPROGRESSBAR: - conf->skip_progress_bar = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_CALENDAR_DEFAULTVIEW: - calendar_set_view (atoi (e_conf)); - var = 0; - break; - case CUSTOM_CONF_WEEKBEGINSONMONDAY: - if (fill_config_var (e_conf)) - calendar_set_first_day_of_week (MONDAY); - else - calendar_set_first_day_of_week (SUNDAY); - var = 0; - break; - case CUSTOM_CONF_COLORTHEME: - custom_load_color (e_conf, background); - var = 0; - break; - case CUSTOM_CONF_LAYOUT: - wins_set_layout (atoi (e_conf)); - var = 0; - break; - case CUSTOM_CONF_SBAR_WIDTH: - wins_set_sbar_width (atoi (e_conf)); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARSHOW: - nbar.show = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARDATE: - (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARCLOCK: - (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARWARNING: - nbar.cntdwn = atoi (e_conf); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARCOMMAND: - (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_OUTPUTDATEFMT: - if (e_conf[0] != '\0') - (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_INPUTDATEFMT: - conf->input_datefmt = atoi (e_conf); - if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) - conf->input_datefmt = 1; - var = 0; - break; - case CUSTOM_CONF_DMON_ENABLE: - dmon.enable = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_DMON_LOG: - dmon.log = fill_config_var (e_conf); - var = 0; - break; - default: - EXIT (_("configuration variable unknown")); + if (strncmp (name, conf_varmap[i].name, BUFSIZ) == 0) + { + var = conf_varmap[i].var; + break; + } + } + + if (var == CUSTOM_CONF_INVALID) + { + EXIT (_("configuration variable unknown: \"%s\""), name); /* NOTREACHED */ } - if (strncmp (e_conf, "auto_save=", 10) == 0) - var = CUSTOM_CONF_AUTOSAVE; - else if (strncmp (e_conf, "periodic_save=", 14) == 0) - var = CUSTOM_CONF_PERIODICSAVE; - else if (strncmp (e_conf, "confirm_quit=", 13) == 0) - var = CUSTOM_CONF_CONFIRMQUIT; - else if (strncmp (e_conf, "confirm_delete=", 15) == 0) - var = CUSTOM_CONF_CONFIRMDELETE; - else if (strncmp (e_conf, "skip_system_dialogs=", 20) == 0) - var = CUSTOM_CONF_SKIPSYSTEMDIALOGS; - else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0) - var = CUSTOM_CONF_SKIPPROGRESSBAR; - else if (strncmp (e_conf, "calendar_default_view=", 22) == 0) - var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW; - else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0) - var = CUSTOM_CONF_WEEKBEGINSONMONDAY; - else if (strncmp (e_conf, "color-theme=", 12) == 0) - var = CUSTOM_CONF_COLORTHEME; - else if (strncmp (e_conf, "layout=", 7) == 0) - var = CUSTOM_CONF_LAYOUT; - else if (strncmp (e_conf, "side-bar_width=", 15) == 0) - var = CUSTOM_CONF_SBAR_WIDTH; - else if (strncmp (e_conf, "notify-bar_show=", 16) == 0) - var = CUSTOM_CONF_NOTIFYBARSHOW; - else if (strncmp (e_conf, "notify-bar_date=", 16) == 0) - var = CUSTOM_CONF_NOTIFYBARDATE; - else if (strncmp (e_conf, "notify-bar_clock=", 17) == 0) - var = CUSTOM_CONF_NOTIFYBARCLOCK; - else if (strncmp (e_conf, "notify-bar_warning=", 19) == 0) - var = CUSTOM_CONF_NOTIFYBARWARNING; - else if (strncmp (e_conf, "notify-bar_command=", 19) == 0) - var = CUSTOM_CONF_NOTIFYBARCOMMAND; - else if (strncmp (e_conf, "output_datefmt=", 15) == 0) - var = CUSTOM_CONF_OUTPUTDATEFMT; - else if (strncmp (e_conf, "input_datefmt=", 14) == 0) - var = CUSTOM_CONF_INPUTDATEFMT; - else if (strncmp (e_conf, "notify-daemon_enable=", 21) == 0) - var = CUSTOM_CONF_DMON_ENABLE; - else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0) - var = CUSTOM_CONF_DMON_LOG; + if (val && (*val == '\0' || *val == '\n')) + { + /* Backward compatibility mode. */ + if (fgets (buf, sizeof buf, data_file) == NULL) + break; + io_extract_data (e_conf, buf, sizeof buf); + val = e_conf; + } + + if (!val || !custom_set_conf (conf, var, val)) + { + EXIT (_("wrong configuration variable format for \"%s\""), name); + /* NOTREACHED */ + } } file_close (data_file, __FILE_POS__); pthread_mutex_unlock (&nbar.mutex); @@ -530,14 +572,14 @@ custom_layout_config (void) " 'a' -> appointment panel\n\n" " 't' -> todo panel\n\n"); - conf_win.p = (WINDOW *)0; - (void)snprintf (label, BUFSIZ, _("layout configuration")); + conf_win.p = NULL; + strncpy (label, _("layout configuration"), BUFSIZ); custom_confwin_init (&conf_win, label); cursor = mark = wins_layout () - 1; display_layout_config (&conf_win, mark, cursor); clear (); - while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) + while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT) { need_reset = 0; switch (ch) @@ -621,7 +663,7 @@ custom_sidebar_config (void) keys_display_bindings_bar (win[STA].p, binding, 0, binding_size); wins_doupdate (); - while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) + while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT) { switch (ch) { @@ -654,8 +696,8 @@ custom_sidebar_config (void) else { wins_reinit_panels (); - wins_update_border (); - wins_update_panels (); + wins_update_border (FLAG_ALL); + wins_update_panels (FLAG_ALL); keys_display_bindings_bar (win[STA].p, binding, 0, binding_size); wins_doupdate (); } @@ -681,7 +723,7 @@ custom_confwin_init (struct window *confwin, char *label) { erase_window_part (confwin->p, confwin->x, confwin->y, confwin->x + confwin->w, confwin->y + confwin->h); - (void)delwin (confwin->p); + delwin (confwin->p); } wins_get_config (); @@ -851,7 +893,7 @@ custom_color_config (void) char label[BUFSIZ]; conf_win.p = 0; - (void)snprintf (label, BUFSIZ, _("color theme")); + strncpy (label, _("color theme"), BUFSIZ); custom_confwin_init (&conf_win, label); mark_fore = NBUSERCOLORS; mark_back = SIZE - 1; @@ -860,7 +902,7 @@ custom_color_config (void) display_color_config (&conf_win, &mark_fore, &mark_back, cursor, theme_changed); clear (); - while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) + while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT) { need_reset = 0; theme_changed = 0; @@ -953,7 +995,7 @@ custom_color_theme_name (char *theme_name) }; if (!colorize) - (void)snprintf (theme_name, BUFSIZ, "0"); + strncpy (theme_name, "0", BUFSIZ); else { pair_content (COLR_CUSTOM, &color[0], &color[1]); @@ -969,8 +1011,7 @@ custom_color_theme_name (char *theme_name) /* NOTREACHED */ } } - (void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0], - color_name[1]); + snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0], color_name[1]); } } @@ -980,6 +1021,7 @@ print_general_options (WINDOW *win, struct conf *conf) { enum { AUTO_SAVE, + AUTO_GC, PERIODIC_SAVE, CONFIRM_QUIT, CONFIRM_DELETE, @@ -995,6 +1037,7 @@ print_general_options (WINDOW *win, struct conf *conf) int y; char *opt[NB_OPTIONS] = { _("auto_save = "), + _("auto_gc = "), _("periodic_save = "), _("confirm_quit = "), _("confirm_delete = "), @@ -1012,7 +1055,13 @@ print_general_options (WINDOW *win, struct conf *conf) mvwprintw (win, y + 1, XPOS, _("(if set to YES, automatic save is done when quitting)")); y += YOFF; - mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]); + mvwprintw (win, y, XPOS, "[2] %s ", opt[AUTO_GC]); + print_bool_option_incolor (win, conf->auto_gc, y, + XPOS + 4 + strlen (opt[AUTO_GC])); + mvwprintw (win, y + 1, XPOS, + _("(run the garbage collector when quitting)")); + y += YOFF; + mvwprintw (win, y, XPOS, "[3] %s ", opt[PERIODIC_SAVE]); custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, y, XPOS + 4 + strlen (opt[PERIODIC_SAVE]), "%d", conf->periodic_save); @@ -1021,41 +1070,41 @@ print_general_options (WINDOW *win, struct conf *conf) _("(if not null, automatically save data every 'periodic_save' " "minutes)")); y += YOFF; - mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]); + mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_QUIT]); print_bool_option_incolor (win, conf->confirm_quit, y, XPOS + 4 + strlen (opt[CONFIRM_QUIT])); mvwprintw (win, y + 1, XPOS, _("(if set to YES, confirmation is required before quitting)")); y += YOFF; - mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]); + mvwprintw (win, y, XPOS, "[5] %s ", opt[CONFIRM_DELETE]); print_bool_option_incolor (win, conf->confirm_delete, y, XPOS + 4 + strlen (opt[CONFIRM_DELETE])); mvwprintw (win, y + 1, XPOS, _("(if set to YES, confirmation is required " "before deleting an event)")); y += YOFF; - mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]); + mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_SYSTEM_DIAGS]); print_bool_option_incolor (win, conf->skip_system_dialogs, y, XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS])); mvwprintw (win, y + 1, XPOS, _("(if set to YES, messages about loaded " "and saved data will not be displayed)")); y += YOFF; - mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]); + mvwprintw (win, y, XPOS, "[7] %s ", opt[SKIP_PROGRESS_BAR]); print_bool_option_incolor (win, conf->skip_progress_bar, y, XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR])); mvwprintw (win, y + 1, XPOS, _("(if set to YES, progress bar will not be displayed " "when saving data)")); y += YOFF; - mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]); + mvwprintw (win, y, XPOS, "[8] %s ", opt[WEEK_BEGINS_MONDAY]); print_bool_option_incolor (win, calendar_week_begins_on_monday (), y, XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY])); mvwprintw (win, y + 1, XPOS, _("(if set to YES, monday is the first day of the week, " "else it is sunday)")); y += YOFF; - mvwprintw (win, y, XPOS, "[8] %s ", opt[OUTPUT_DATE_FMT]); + mvwprintw (win, y, XPOS, "[9] %s ", opt[OUTPUT_DATE_FMT]); custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, y, XPOS + 4 + strlen (opt[OUTPUT_DATE_FMT]), "%s", conf->output_datefmt); @@ -1063,7 +1112,7 @@ print_general_options (WINDOW *win, struct conf *conf) mvwprintw (win, y + 1, XPOS, _("(Format of the date to be displayed in non-interactive mode)")); y += YOFF; - mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]); + mvwprintw (win, y, XPOS, "[0] %s ", opt[INPUT_DATE_FMT]); custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, y, XPOS + 4 + strlen (opt[INPUT_DATE_FMT]), "%d", conf->input_datefmt); @@ -1110,7 +1159,7 @@ custom_general_config (struct conf *conf) clear (); custom_set_swsiz (&cwin); - (void)snprintf (cwin.label, BUFSIZ, _("general options")); + strncpy (cwin.label, _("general options"), BUFSIZ); wins_scrollwin_init (&cwin); wins_show (cwin.win.p, cwin.label); status_mesg (number_str, keys); @@ -1134,6 +1183,9 @@ custom_general_config (struct conf *conf) conf->auto_save = !conf->auto_save; break; case '2': + conf->auto_gc = !conf->auto_gc; + break; + case '3': status_mesg (periodic_save_str, ""); if (updatestring (win[STA].p, &buf, 0, 1) == 0) { @@ -1147,32 +1199,32 @@ custom_general_config (struct conf *conf) } status_mesg (number_str, keys); break; - case '3': + case '4': conf->confirm_quit = !conf->confirm_quit; break; - case '4': + case '5': conf->confirm_delete = !conf->confirm_delete; break; - case '5': + case '6': conf->skip_system_dialogs = !conf->skip_system_dialogs; break; - case '6': + case '7': conf->skip_progress_bar = !conf->skip_progress_bar; break; - case '7': + case '8': calendar_change_first_day_of_week (); break; - case '8': + case '9': status_mesg (output_datefmt_str, ""); - (void)strncpy (buf, conf->output_datefmt, - strlen (conf->output_datefmt) + 1); + strncpy (buf, conf->output_datefmt, + strlen (conf->output_datefmt) + 1); if (updatestring (win[STA].p, &buf, 0, 1) == 0) { - (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1); + strncpy (conf->output_datefmt, buf, strlen (buf) + 1); } status_mesg (number_str, keys); break; - case '9': + case '0': status_mesg (input_datefmt_str, ""); if (updatestring (win[STA].p, &buf, 0, 1) == 0) { @@ -1240,7 +1292,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff) int nbkeys; nbkeys = keys_action_count_keys (action); - (void)snprintf (actionstr, BUFSIZ, "%s", keys_get_label (action)); + snprintf (actionstr, BUFSIZ, "%s", keys_get_label (action)); if (action == selected_row) custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, y, XPOS, "%s ", actionstr); @@ -1312,7 +1364,7 @@ custom_keys_config (void) clear (); custom_set_swsiz (&kwin); nbdisplayed = (kwin.win.h - LABELLINES) / LINESPERKEY; - (void)snprintf (kwin.label, BUFSIZ, _("keys configuration")); + strncpy (kwin.label, _("keys configuration"), BUFSIZ); wins_scrollwin_init (&kwin); wins_show (kwin.win.p, kwin.label); custom_keys_config_bar (); @@ -1326,7 +1378,7 @@ custom_keys_config (void) { int ch; - ch = keys_getch (win[STA].p); + ch = keys_getch (win[STA].p, NULL); switch (ch) { case KEY_MOVE_UP: |