Declare several parameters/variables constant
Add the "const" keyword to parameters and variables that are never modified. Most of these were spotted by "-Wwrite-strings". We cast the second parameter to execvp() explicitly as it expects a "char *const[]" where it should expect a "const char *const[]" (according to the documentation, this is due to compatibility reasons). This should be changed once we come up with a better solution. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
a20f36c5de
commit
6da787a5cc
13
src/args.c
13
src/args.c
@ -480,8 +480,9 @@ display_app (struct tm *t, int numdays, int add_line, const char *fmt_apt,
|
|||||||
* days.
|
* days.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
date_arg (char *ddate, int add_line, const char *fmt_apt, const char *fmt_rapt,
|
date_arg (const char *ddate, int add_line, const char *fmt_apt,
|
||||||
const char *fmt_ev, const char *fmt_rev, regex_t *regex)
|
const char *fmt_rapt, const char *fmt_ev, const char *fmt_rev,
|
||||||
|
regex_t *regex)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct date day;
|
struct date day;
|
||||||
@ -544,7 +545,7 @@ date_arg (char *ddate, int add_line, const char *fmt_apt, const char *fmt_rapt,
|
|||||||
* Many thanks to Erik Saule for providing this function.
|
* Many thanks to Erik Saule for providing this function.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
date_arg_extended (char *startday, char *range, int add_line,
|
date_arg_extended (const char *startday, const char *range, int add_line,
|
||||||
const char *fmt_apt, const char *fmt_rapt,
|
const char *fmt_apt, const char *fmt_rapt,
|
||||||
const char *fmt_ev, const char *fmt_rev, regex_t *regex)
|
const char *fmt_ev, const char *fmt_rev, regex_t *regex)
|
||||||
{
|
{
|
||||||
@ -633,8 +634,8 @@ parse_args (int argc, char **argv)
|
|||||||
const char *fmt_todo = "%p. %m\n";
|
const char *fmt_todo = "%p. %m\n";
|
||||||
|
|
||||||
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
|
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
|
||||||
char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
|
const char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
|
||||||
char *datadir = NULL, *ifile = NULL;
|
const char *datadir = NULL, *ifile = NULL;
|
||||||
regex_t reg, *preg = NULL;
|
regex_t reg, *preg = NULL;
|
||||||
|
|
||||||
/* Long options only */
|
/* Long options only */
|
||||||
@ -644,7 +645,7 @@ parse_args (int argc, char **argv)
|
|||||||
STATUS_OPT = CHAR_MAX + 1
|
STATUS_OPT = CHAR_MAX + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *optstr = "ghvnNax::t::d:c:r::s::S:D:i:";
|
static const char *optstr = "ghvnNax::t::d:c:r::s::S:D:i:";
|
||||||
|
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{"appointment", no_argument, NULL, 'a'},
|
{"appointment", no_argument, NULL, 'a'},
|
||||||
|
103
src/calcurse.h
103
src/calcurse.h
@ -228,17 +228,17 @@
|
|||||||
|
|
||||||
/* General configuration variables. */
|
/* General configuration variables. */
|
||||||
struct conf {
|
struct conf {
|
||||||
unsigned auto_save;
|
unsigned auto_save;
|
||||||
unsigned auto_gc;
|
unsigned auto_gc;
|
||||||
unsigned periodic_save;
|
unsigned periodic_save;
|
||||||
unsigned confirm_quit;
|
unsigned confirm_quit;
|
||||||
unsigned confirm_delete;
|
unsigned confirm_delete;
|
||||||
unsigned system_dialogs;
|
unsigned system_dialogs;
|
||||||
unsigned progress_bar;
|
unsigned progress_bar;
|
||||||
char *editor;
|
const char *editor;
|
||||||
char *pager;
|
const char *pager;
|
||||||
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
||||||
int input_datefmt; /* format for reading date */
|
int input_datefmt; /* format for reading date */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Daemon-related configuration. */
|
/* Daemon-related configuration. */
|
||||||
@ -482,7 +482,7 @@ struct nbar {
|
|||||||
char datefmt[BUFSIZ]; /* format for displaying date */
|
char datefmt[BUFSIZ]; /* format for displaying date */
|
||||||
char timefmt[BUFSIZ]; /* format for displaying time */
|
char timefmt[BUFSIZ]; /* format for displaying time */
|
||||||
char cmd[BUFSIZ]; /* notification command */
|
char cmd[BUFSIZ]; /* notification command */
|
||||||
char *shell; /* user shell to launch notif. cmd */
|
const char *shell; /* user shell to launch notif. cmd */
|
||||||
unsigned notify_all; /* notify all appointments */
|
unsigned notify_all; /* notify all appointments */
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
};
|
};
|
||||||
@ -618,7 +618,7 @@ void calendar_change_day (int);
|
|||||||
void calendar_move (enum move, int);
|
void calendar_move (enum move, int);
|
||||||
long calendar_start_of_year (void);
|
long calendar_start_of_year (void);
|
||||||
long calendar_end_of_year (void);
|
long calendar_end_of_year (void);
|
||||||
char *calendar_get_pom (time_t);
|
const char *calendar_get_pom (time_t);
|
||||||
|
|
||||||
/* config.c */
|
/* config.c */
|
||||||
|
|
||||||
@ -654,8 +654,8 @@ int day_cut_item (long, int);
|
|||||||
int day_paste_item (long, int);
|
int day_paste_item (long, int);
|
||||||
struct day_item *day_get_item (int);
|
struct day_item *day_get_item (int);
|
||||||
int day_item_nb (long, int, int);
|
int day_item_nb (long, int, int);
|
||||||
void day_edit_note (char *);
|
void day_edit_note (const char *);
|
||||||
void day_view_note (char *);
|
void day_view_note (const char *);
|
||||||
void day_pipe_item (void);
|
void day_pipe_item (void);
|
||||||
|
|
||||||
/* dmon.c */
|
/* dmon.c */
|
||||||
@ -690,7 +690,7 @@ void ical_export_data (FILE *);
|
|||||||
|
|
||||||
/* io.c */
|
/* io.c */
|
||||||
unsigned io_fprintln (const char *, const char *, ...);
|
unsigned io_fprintln (const char *, const char *, ...);
|
||||||
void io_init (char *, char *);
|
void io_init (const char *, const char *);
|
||||||
void io_extract_data (char *, const char *, int);
|
void io_extract_data (char *, const char *, int);
|
||||||
unsigned io_save_apts (void);
|
unsigned io_save_apts (void);
|
||||||
unsigned io_save_todo (void);
|
unsigned io_save_todo (void);
|
||||||
@ -698,7 +698,7 @@ unsigned io_save_keys (void);
|
|||||||
void io_save_cal (enum save_display);
|
void io_save_cal (enum save_display);
|
||||||
void io_load_app (void);
|
void io_load_app (void);
|
||||||
void io_load_todo (void);
|
void io_load_todo (void);
|
||||||
void io_load_keys (char *);
|
void io_load_keys (const char *);
|
||||||
void io_check_dir (char *, int *);
|
void io_check_dir (char *, int *);
|
||||||
unsigned io_file_exist (char *);
|
unsigned io_file_exist (char *);
|
||||||
void io_check_file (char *, int *);
|
void io_check_file (char *, int *);
|
||||||
@ -706,10 +706,10 @@ int io_check_data_files (void);
|
|||||||
void io_startup_screen (int);
|
void io_startup_screen (int);
|
||||||
void io_export_data (enum export_type);
|
void io_export_data (enum export_type);
|
||||||
void io_export_bar (void);
|
void io_export_bar (void);
|
||||||
void io_import_data (enum import_type, char *);
|
void io_import_data (enum import_type, const char *);
|
||||||
struct io_file *io_log_init (void);
|
struct io_file *io_log_init (void);
|
||||||
void io_log_print (struct io_file *, int, const char *);
|
void io_log_print (struct io_file *, int, const char *);
|
||||||
void io_log_display (struct io_file *, const char *, char *);
|
void io_log_display (struct io_file *, const char *, const char *);
|
||||||
void io_log_free (struct io_file *);
|
void io_log_free (struct io_file *);
|
||||||
void io_start_psave_thread (void);
|
void io_start_psave_thread (void);
|
||||||
void io_stop_psave_thread (void);
|
void io_stop_psave_thread (void);
|
||||||
@ -720,26 +720,26 @@ int io_file_is_empty (char *);
|
|||||||
int io_file_cp (const char *, const char *);
|
int io_file_cp (const char *, const char *);
|
||||||
|
|
||||||
/* keys.c */
|
/* keys.c */
|
||||||
void keys_init (void);
|
void keys_init (void);
|
||||||
void keys_free (void);
|
void keys_free (void);
|
||||||
void keys_dump_defaults (char *);
|
void keys_dump_defaults (char *);
|
||||||
char *keys_get_label (enum key);
|
const char *keys_get_label (enum key);
|
||||||
enum key keys_get_action (int);
|
enum key keys_get_action (int);
|
||||||
enum key keys_getch (WINDOW *win, int *);
|
enum key keys_getch (WINDOW *win, int *);
|
||||||
int keys_assign_binding (int, enum key);
|
int keys_assign_binding (int, enum key);
|
||||||
void keys_remove_binding (int, enum key);
|
void keys_remove_binding (int, enum key);
|
||||||
int keys_str2int (char *);
|
int keys_str2int (const char *);
|
||||||
char *keys_int2str (int);
|
const char *keys_int2str (int);
|
||||||
int keys_action_count_keys (enum key);
|
int keys_action_count_keys (enum key);
|
||||||
char *keys_action_firstkey (enum key);
|
const char *keys_action_firstkey (enum key);
|
||||||
char *keys_action_nkey (enum key, int);
|
const char *keys_action_nkey (enum key, int);
|
||||||
char *keys_action_allkeys (enum key);
|
char *keys_action_allkeys (enum key);
|
||||||
void keys_display_bindings_bar (WINDOW *, struct binding *[], int, int,
|
void keys_display_bindings_bar (WINDOW *, struct binding *[], int, int,
|
||||||
int, struct binding *);
|
int, struct binding *);
|
||||||
void keys_popup_info (enum key);
|
void keys_popup_info (enum key);
|
||||||
void keys_save_bindings (FILE *);
|
void keys_save_bindings (FILE *);
|
||||||
int keys_check_missing_bindings (void);
|
int keys_check_missing_bindings (void);
|
||||||
void keys_fill_missing (void);
|
void keys_fill_missing (void);
|
||||||
|
|
||||||
/* mem.c */
|
/* mem.c */
|
||||||
void *xmalloc (size_t);
|
void *xmalloc (size_t);
|
||||||
@ -776,8 +776,8 @@ void mem_stats (void);
|
|||||||
|
|
||||||
/* note.c */
|
/* note.c */
|
||||||
char *generate_note (const char *);
|
char *generate_note (const char *);
|
||||||
void edit_note (char **, char *);
|
void edit_note (char **, const char *);
|
||||||
void view_note (char *, char *);
|
void view_note (const char *, const char *);
|
||||||
void erase_note (char **);
|
void erase_note (char **);
|
||||||
void note_read (char *, FILE *);
|
void note_read (char *, FILE *);
|
||||||
void note_gc (void);
|
void note_gc (void);
|
||||||
@ -879,8 +879,8 @@ void todo_delete (void);
|
|||||||
void todo_chg_priority (int);
|
void todo_chg_priority (int);
|
||||||
void todo_edit_item (void);
|
void todo_edit_item (void);
|
||||||
void todo_update_panel (int);
|
void todo_update_panel (int);
|
||||||
void todo_edit_note (char *);
|
void todo_edit_note (const char *);
|
||||||
void todo_view_note (char *);
|
void todo_view_note (const char *);
|
||||||
void todo_pipe_item (void);
|
void todo_pipe_item (void);
|
||||||
void todo_init_list (void);
|
void todo_init_list (void);
|
||||||
void todo_free_list (void);
|
void todo_free_list (void);
|
||||||
@ -897,21 +897,22 @@ void warnbox (const char *);
|
|||||||
void status_mesg (const char *, const char *);
|
void status_mesg (const char *, const char *);
|
||||||
void status_mesg_yesno (const char *);
|
void status_mesg_yesno (const char *);
|
||||||
void erase_window_part (WINDOW *, int, int, int, int);
|
void erase_window_part (WINDOW *, int, int, int, int);
|
||||||
WINDOW *popup (int, int, int, int, char *, char *, int);
|
WINDOW *popup (int, int, int, int, const char *, const char *, int);
|
||||||
void print_in_middle (WINDOW *, int, int, int, const char *);
|
void print_in_middle (WINDOW *, int, int, int, const char *);
|
||||||
int is_all_digit (const char *);
|
int is_all_digit (const char *);
|
||||||
long get_item_time (long);
|
long get_item_time (long);
|
||||||
int get_item_hour (long);
|
int get_item_hour (long);
|
||||||
int get_item_min (long);
|
int get_item_min (long);
|
||||||
long date2sec (struct date, unsigned, unsigned);
|
long date2sec (struct date, unsigned, unsigned);
|
||||||
char *date_sec2date_str (long, char *);
|
char *date_sec2date_str (long, const char *);
|
||||||
void date_sec2date_fmt (long, const char *, char *);
|
void date_sec2date_fmt (long, const char *, char *);
|
||||||
long date_sec_change (long, int, int);
|
long date_sec_change (long, int, int);
|
||||||
long update_time_in_date (long, unsigned, unsigned);
|
long update_time_in_date (long, unsigned, unsigned);
|
||||||
long get_sec_date (struct date);
|
long get_sec_date (struct date);
|
||||||
long min2sec (unsigned);
|
long min2sec (unsigned);
|
||||||
void draw_scrollbar (WINDOW *, int, int, int, int, int, unsigned);
|
void draw_scrollbar (WINDOW *, int, int, int, int, int, unsigned);
|
||||||
void item_in_popup (char *, char *, char *, char *);
|
void item_in_popup (const char *, const char *, const char *,
|
||||||
|
const char *);
|
||||||
long get_today (void);
|
long get_today (void);
|
||||||
long now (void);
|
long now (void);
|
||||||
char *nowstr (void);
|
char *nowstr (void);
|
||||||
@ -926,8 +927,8 @@ int parse_duration (const char *, unsigned *);
|
|||||||
void str_toupper (char *);
|
void str_toupper (char *);
|
||||||
void file_close (FILE *, const char *);
|
void file_close (FILE *, const char *);
|
||||||
void psleep (unsigned);
|
void psleep (unsigned);
|
||||||
int fork_exec (int *, int *, const char *, char *const *);
|
int fork_exec (int *, int *, const char *, const char *const *);
|
||||||
int shell_exec (int *, int *, char *);
|
int shell_exec (int *, int *, const char *);
|
||||||
int child_wait (int *, int *, int);
|
int child_wait (int *, int *, int);
|
||||||
void press_any_key (void);
|
void press_any_key (void);
|
||||||
void print_apoint (const char *, long, struct apoint *);
|
void print_apoint (const char *, long, struct apoint *);
|
||||||
@ -945,8 +946,8 @@ extern int foreground, background;
|
|||||||
extern enum ui_mode ui_mode;
|
extern enum ui_mode ui_mode;
|
||||||
extern int read_only;
|
extern int read_only;
|
||||||
extern int days[12];
|
extern int days[12];
|
||||||
extern char *monthnames[12];
|
extern const char *monthnames[12];
|
||||||
extern char *daynames[8];
|
extern const char *daynames[8];
|
||||||
extern char path_dir[BUFSIZ];
|
extern char path_dir[BUFSIZ];
|
||||||
extern char path_todo[BUFSIZ];
|
extern char path_todo[BUFSIZ];
|
||||||
extern char path_apts[BUFSIZ];
|
extern char path_apts[BUFSIZ];
|
||||||
@ -994,7 +995,7 @@ void wins_update (int);
|
|||||||
void wins_reset (void);
|
void wins_reset (void);
|
||||||
void wins_prepare_external (void);
|
void wins_prepare_external (void);
|
||||||
void wins_unprepare_external (void);
|
void wins_unprepare_external (void);
|
||||||
void wins_launch_external (char *, char *);
|
void wins_launch_external (const char *, const char *);
|
||||||
void wins_status_bar (void);
|
void wins_status_bar (void);
|
||||||
void wins_erase_status_bar (void);
|
void wins_erase_status_bar (void);
|
||||||
void wins_other_status_page (int);
|
void wins_other_status_page (int);
|
||||||
|
@ -632,7 +632,7 @@ calendar_change_day (int datefmt)
|
|||||||
_("The day you entered is not valid "
|
_("The day you entered is not valid "
|
||||||
"(should be between 01/01/1902 and 12/31/2037)");
|
"(should be between 01/01/1902 and 12/31/2037)");
|
||||||
const char *mesg_line2 = _("Press [ENTER] to continue");
|
const char *mesg_line2 = _("Press [ENTER] to continue");
|
||||||
char *request_date = "Enter the day to go to [ENTER for today] : %s";
|
const char *request_date = "Enter the day to go to [ENTER for today] : %s";
|
||||||
|
|
||||||
while (wrong_day)
|
while (wrong_day)
|
||||||
{
|
{
|
||||||
@ -910,10 +910,10 @@ pom (time_t tmpt)
|
|||||||
* Careful: date is the selected day in calendar at 00:00, so it represents
|
* Careful: date is the selected day in calendar at 00:00, so it represents
|
||||||
* the phase of the moon for previous day.
|
* the phase of the moon for previous day.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
calendar_get_pom (time_t date)
|
calendar_get_pom (time_t date)
|
||||||
{
|
{
|
||||||
char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
|
const char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
|
||||||
enum pom phase = NO_POM;
|
enum pom phase = NO_POM;
|
||||||
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
|
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
|
||||||
const double half = 50.0;
|
const double half = 50.0;
|
||||||
|
@ -337,9 +337,9 @@ config_color_theme_name (char *theme_name)
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
short color[NBCOLORS];
|
short color[NBCOLORS];
|
||||||
char *color_name[NBCOLORS];
|
const char *color_name[NBCOLORS];
|
||||||
char *default_color = "default";
|
const char *default_color = "default";
|
||||||
char *name[MAXCOLORS] = {
|
const char *name[MAXCOLORS] = {
|
||||||
"black",
|
"black",
|
||||||
"red",
|
"red",
|
||||||
"green",
|
"green",
|
||||||
|
14
src/custom.c
14
src/custom.c
@ -157,7 +157,7 @@ display_layout_config (struct window *lwin, int mark, int cursor)
|
|||||||
#define MARK 88
|
#define MARK 88
|
||||||
#define LAYOUTH 5
|
#define LAYOUTH 5
|
||||||
#define LAYOUTW 9
|
#define LAYOUTW 9
|
||||||
char *box = "[ ]";
|
const char *box = "[ ]";
|
||||||
const int BOXSIZ = strlen (box);
|
const int BOXSIZ = strlen (box);
|
||||||
const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL;
|
const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL;
|
||||||
const int COLSIZ = LAYOUTW + BOXSIZ + 1;
|
const int COLSIZ = LAYOUTW + BOXSIZ + 1;
|
||||||
@ -167,7 +167,7 @@ display_layout_config (struct window *lwin, int mark, int cursor)
|
|||||||
const int YOFST = (lwin->h - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2;
|
const int YOFST = (lwin->h - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2;
|
||||||
enum {YPOS, XPOS, NBPOS};
|
enum {YPOS, XPOS, NBPOS};
|
||||||
int pos[NBLAYOUTS][NBPOS];
|
int pos[NBLAYOUTS][NBPOS];
|
||||||
char *layouts[LAYOUTH][NBLAYOUTS] = {
|
const char *layouts[LAYOUTH][NBLAYOUTS] = {
|
||||||
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"},
|
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"},
|
||||||
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |", "| | a |", "| c | |", "| a | |"},
|
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |", "| | a |", "| c | |", "| a | |"},
|
||||||
{"| a +---+", "| a +---+", "+---+ a |", "|---+ a |", "| t +---+", "| t +---+", "+---+ t |", "+---+ t |"},
|
{"| a +---+", "| a +---+", "+---+ a |", "|---+ a |", "| t +---+", "| t +---+", "+---+ t |", "+---+ t |"},
|
||||||
@ -434,8 +434,8 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
|
|||||||
const char *fore_txt = _("Foreground");
|
const char *fore_txt = _("Foreground");
|
||||||
const char *back_txt = _("Background");
|
const char *back_txt = _("Background");
|
||||||
const char *default_txt = _("(terminal's default)");
|
const char *default_txt = _("(terminal's default)");
|
||||||
char *bar = " ";
|
const char *bar = " ";
|
||||||
char *box = "[ ]";
|
const char *box = "[ ]";
|
||||||
const unsigned Y = 3;
|
const unsigned Y = 3;
|
||||||
const unsigned XOFST = 5;
|
const unsigned XOFST = 5;
|
||||||
const unsigned YSPC = (cwin->h - 8) / (NBUSERCOLORS + 1);
|
const unsigned YSPC = (cwin->h - 8) / (NBUSERCOLORS + 1);
|
||||||
@ -869,7 +869,7 @@ custom_general_config (void)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_key_incolor (WINDOW *win, char *option, int pos_y, int pos_x)
|
print_key_incolor (WINDOW *win, const char *option, int pos_y, int pos_x)
|
||||||
{
|
{
|
||||||
const int color = ATTR_HIGHEST;
|
const int color = ATTR_HIGHEST;
|
||||||
|
|
||||||
@ -907,7 +907,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
|
|||||||
{
|
{
|
||||||
if (action == selected_row)
|
if (action == selected_row)
|
||||||
{
|
{
|
||||||
char *key;
|
const char *key;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
pos = KEYPOS;
|
pos = KEYPOS;
|
||||||
@ -959,7 +959,7 @@ custom_keys_config (void)
|
|||||||
struct scrollwin kwin;
|
struct scrollwin kwin;
|
||||||
int selrow, selelm, firstrow, lastrow, nbrowelm, nbdisplayed;
|
int selrow, selelm, firstrow, lastrow, nbrowelm, nbdisplayed;
|
||||||
int keyval, used, not_recognized;
|
int keyval, used, not_recognized;
|
||||||
char *keystr;
|
const char *keystr;
|
||||||
WINDOW *grabwin;
|
WINDOW *grabwin;
|
||||||
const int LINESPERKEY = 2;
|
const int LINESPERKEY = 2;
|
||||||
const int LABELLINES = 3;
|
const int LABELLINES = 3;
|
||||||
|
@ -705,7 +705,7 @@ update_rept (struct rpt **rpt, const long start)
|
|||||||
const char *msg_wrong_freq = _("The frequence you entered is not valid.");
|
const char *msg_wrong_freq = _("The frequence you entered is not valid.");
|
||||||
const char *msg_wrong_time = _("Invalid time: start time must be before end time!");
|
const char *msg_wrong_time = _("Invalid time: start time must be before end time!");
|
||||||
const char *msg_wrong_date = _("The entered date is not valid.");
|
const char *msg_wrong_date = _("The entered date is not valid.");
|
||||||
char *msg_fmts =
|
const char *msg_fmts =
|
||||||
"Possible formats are [%s] or '0' for an endless repetetition";
|
"Possible formats are [%s] or '0' for an endless repetetition";
|
||||||
const char *msg_enter = _("Press [Enter] to continue");
|
const char *msg_enter = _("Press [Enter] to continue");
|
||||||
|
|
||||||
@ -1092,7 +1092,7 @@ day_item_nb (long date, int day_num, int type)
|
|||||||
|
|
||||||
/* Attach a note to an appointment or event. */
|
/* Attach a note to an appointment or event. */
|
||||||
void
|
void
|
||||||
day_edit_note (char *editor)
|
day_edit_note (const char *editor)
|
||||||
{
|
{
|
||||||
struct day_item *p;
|
struct day_item *p;
|
||||||
struct recur_apoint *ra;
|
struct recur_apoint *ra;
|
||||||
@ -1130,7 +1130,7 @@ day_edit_note (char *editor)
|
|||||||
|
|
||||||
/* View a note previously attached to an appointment or event */
|
/* View a note previously attached to an appointment or event */
|
||||||
void
|
void
|
||||||
day_view_note (char *pager)
|
day_view_note (const char *pager)
|
||||||
{
|
{
|
||||||
struct day_item *p = day_get_item (apoint_hilt ());
|
struct day_item *p = day_get_item (apoint_hilt ());
|
||||||
view_note (p->note, pager);
|
view_note (p->note, pager);
|
||||||
|
@ -100,7 +100,7 @@ static int
|
|||||||
help_write_pad (struct window *win, char *title, char *text, enum key action)
|
help_write_pad (struct window *win, char *title, char *text, enum key action)
|
||||||
{
|
{
|
||||||
int colnum, rownum;
|
int colnum, rownum;
|
||||||
char *bindings_title = "key bindings: %s";
|
const char *bindings_title = "key bindings: %s";
|
||||||
char *bindings;
|
char *bindings;
|
||||||
|
|
||||||
colnum = 0;
|
colnum = 0;
|
||||||
|
@ -118,7 +118,7 @@ uint32_t \
|
|||||||
name##_HTABLE_FIND_BKT(struct name *head, struct type *elm) \
|
name##_HTABLE_FIND_BKT(struct name *head, struct type *elm) \
|
||||||
{ \
|
{ \
|
||||||
uint32_t __bkt; \
|
uint32_t __bkt; \
|
||||||
char *__key; \
|
const char *__key; \
|
||||||
int __len; \
|
int __len; \
|
||||||
\
|
\
|
||||||
(key) (elm, &__key, &__len); \
|
(key) (elm, &__key, &__len); \
|
||||||
|
@ -68,7 +68,7 @@ static void ical_export_apoints (FILE *);
|
|||||||
static void ical_export_todo (FILE *);
|
static void ical_export_todo (FILE *);
|
||||||
static void ical_export_footer (FILE *);
|
static void ical_export_footer (FILE *);
|
||||||
|
|
||||||
static char *ical_recur_type[RECUR_TYPES] =
|
static const char *ical_recur_type[RECUR_TYPES] =
|
||||||
{ "", "DAILY", "WEEKLY", "MONTHLY", "YEARLY" };
|
{ "", "DAILY", "WEEKLY", "MONTHLY", "YEARLY" };
|
||||||
|
|
||||||
/* iCal alarm notification. */
|
/* iCal alarm notification. */
|
||||||
|
27
src/io.c
27
src/io.c
@ -67,12 +67,13 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ht_keybindings_s {
|
struct ht_keybindings_s {
|
||||||
char *label;
|
const char *label;
|
||||||
enum key key;
|
enum key key;
|
||||||
HTABLE_ENTRY (ht_keybindings_s);
|
HTABLE_ENTRY (ht_keybindings_s);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void load_keys_ht_getkey (struct ht_keybindings_s *, char **, int *);
|
static void load_keys_ht_getkey (struct ht_keybindings_s *, const char **,
|
||||||
|
int *);
|
||||||
static int load_keys_ht_compare (struct ht_keybindings_s *,
|
static int load_keys_ht_compare (struct ht_keybindings_s *,
|
||||||
struct ht_keybindings_s *);
|
struct ht_keybindings_s *);
|
||||||
|
|
||||||
@ -94,14 +95,14 @@ progress_bar (progress_bar_t type, int progress)
|
|||||||
const char *mesg_load = _("Loading...");
|
const char *mesg_load = _("Loading...");
|
||||||
const char *mesg_export = _("Exporting...");
|
const char *mesg_export = _("Exporting...");
|
||||||
const char *error_msg = _("Internal error while displaying progress bar");
|
const char *error_msg = _("Internal error while displaying progress bar");
|
||||||
char *barchar = "|";
|
const char *barchar = "|";
|
||||||
char *file[NBFILES] = {
|
const char *file[NBFILES] = {
|
||||||
"[ conf ]",
|
"[ conf ]",
|
||||||
"[ todo ]",
|
"[ todo ]",
|
||||||
"[ apts ]",
|
"[ apts ]",
|
||||||
"[ keys ]"
|
"[ keys ]"
|
||||||
};
|
};
|
||||||
char *data[NBEXPORTED] = {
|
const char *data[NBEXPORTED] = {
|
||||||
"[ events ]",
|
"[ events ]",
|
||||||
"[appointments]",
|
"[appointments]",
|
||||||
"[ todo ]"
|
"[ todo ]"
|
||||||
@ -226,10 +227,10 @@ io_fprintln (const char *fname, const char *fmt, ...)
|
|||||||
* The datadir argument can be use to specify an alternative data root dir.
|
* The datadir argument can be use to specify an alternative data root dir.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
io_init (char *cfile, char *datadir)
|
io_init (const char *cfile, const char *datadir)
|
||||||
{
|
{
|
||||||
FILE *data_file;
|
FILE *data_file;
|
||||||
char *home;
|
const char *home;
|
||||||
char apts_file[BUFSIZ] = "";
|
char apts_file[BUFSIZ] = "";
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
@ -723,7 +724,7 @@ io_load_todo (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_keys_ht_getkey (struct ht_keybindings_s *data, char **key, int *len)
|
load_keys_ht_getkey (struct ht_keybindings_s *data, const char **key, int *len)
|
||||||
{
|
{
|
||||||
*key = data->label;
|
*key = data->label;
|
||||||
*len = strlen (data->label);
|
*len = strlen (data->label);
|
||||||
@ -760,7 +761,7 @@ static int is_blank (int c)
|
|||||||
* configuration file.
|
* configuration file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
io_load_keys (char *pager)
|
io_load_keys (const char *pager)
|
||||||
{
|
{
|
||||||
struct ht_keybindings_s keys[NBKEYS];
|
struct ht_keybindings_s keys[NBKEYS];
|
||||||
FILE *keyfp;
|
FILE *keyfp;
|
||||||
@ -1108,7 +1109,7 @@ get_import_stream (enum export_type type)
|
|||||||
* and is cleared at the end.
|
* and is cleared at the end.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
io_import_data (enum import_type type, char *stream_name)
|
io_import_data (enum import_type type, const char *stream_name)
|
||||||
{
|
{
|
||||||
const char *proc_report = _("Import process report: %04d lines read ");
|
const char *proc_report = _("Import process report: %04d lines read ");
|
||||||
char stats_str[4][BUFSIZ];
|
char stats_str[4][BUFSIZ];
|
||||||
@ -1232,7 +1233,7 @@ io_log_print (struct io_file *log, int line, const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
io_log_display (struct io_file *log, const char *msg, char *pager)
|
io_log_display (struct io_file *log, const char *msg, const char *pager)
|
||||||
{
|
{
|
||||||
int ans;
|
int ans;
|
||||||
|
|
||||||
@ -1243,7 +1244,7 @@ io_log_display (struct io_file *log, const char *msg, char *pager)
|
|||||||
ans = fgetc (stdin);
|
ans = fgetc (stdin);
|
||||||
if (ans == 'y')
|
if (ans == 'y')
|
||||||
{
|
{
|
||||||
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)))
|
||||||
|
16
src/keys.c
16
src/keys.c
@ -42,8 +42,8 @@
|
|||||||
#define MAXKEYVAL KEY_MAX /* ncurses defines KEY_MAX as maximum key value */
|
#define MAXKEYVAL KEY_MAX /* ncurses defines KEY_MAX as maximum key value */
|
||||||
|
|
||||||
struct keydef_s {
|
struct keydef_s {
|
||||||
char *label;
|
const char *label;
|
||||||
char *binding;
|
const char *binding;
|
||||||
};
|
};
|
||||||
|
|
||||||
static llist_t keys[NBKEYS];
|
static llist_t keys[NBKEYS];
|
||||||
@ -166,7 +166,7 @@ keys_dump_defaults (char *file)
|
|||||||
file_close (fd, __FILE_POS__);
|
file_close (fd, __FILE_POS__);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
keys_get_label (enum key key)
|
keys_get_label (enum key key)
|
||||||
{
|
{
|
||||||
EXIT_IF (key < 0 || key > NBKEYS,
|
EXIT_IF (key < 0 || key > NBKEYS,
|
||||||
@ -269,7 +269,7 @@ keys_remove_binding (int key, enum key action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
keys_str2int (char *key)
|
keys_str2int (const char *key)
|
||||||
{
|
{
|
||||||
const char CONTROL_KEY[] = "C-";
|
const char CONTROL_KEY[] = "C-";
|
||||||
const char TAB_KEY[] = "TAB";
|
const char TAB_KEY[] = "TAB";
|
||||||
@ -315,7 +315,7 @@ keys_str2int (char *key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
keys_int2str (int key)
|
keys_int2str (int key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
@ -355,14 +355,14 @@ keys_action_count_keys (enum key action)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
keys_action_firstkey (enum key action)
|
keys_action_firstkey (enum key action)
|
||||||
{
|
{
|
||||||
char *s = LLIST_GET_DATA (LLIST_FIRST (&keys[action]));
|
const char *s = LLIST_GET_DATA (LLIST_FIRST (&keys[action]));
|
||||||
return (s != NULL) ? s : "XXX";
|
return (s != NULL) ? s : "XXX";
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
keys_action_nkey (enum key action, int keynum)
|
keys_action_nkey (enum key action, int keynum)
|
||||||
{
|
{
|
||||||
return LLIST_GET_DATA (LLIST_NTH (&keys[action], keynum));
|
return LLIST_GET_DATA (LLIST_NTH (&keys[action], keynum));
|
||||||
|
@ -46,7 +46,7 @@ struct note_gc_hash {
|
|||||||
HTABLE_ENTRY (note_gc_hash);
|
HTABLE_ENTRY (note_gc_hash);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void note_gc_extract_key (struct note_gc_hash *, char **, int *);
|
static void note_gc_extract_key (struct note_gc_hash *, const char **, int *);
|
||||||
static int note_gc_cmp (struct note_gc_hash *, struct note_gc_hash *);
|
static int note_gc_cmp (struct note_gc_hash *, struct note_gc_hash *);
|
||||||
|
|
||||||
HTABLE_HEAD (htp, NOTE_GC_HSIZE, note_gc_hash);
|
HTABLE_HEAD (htp, NOTE_GC_HSIZE, note_gc_hash);
|
||||||
@ -74,7 +74,7 @@ generate_note (const char *str)
|
|||||||
|
|
||||||
/* Edit a note with an external editor. */
|
/* Edit a note with an external editor. */
|
||||||
void
|
void
|
||||||
edit_note (char **note, char *editor)
|
edit_note (char **note, const char *editor)
|
||||||
{
|
{
|
||||||
char tmppath[BUFSIZ];
|
char tmppath[BUFSIZ];
|
||||||
char *tmpext;
|
char *tmpext;
|
||||||
@ -114,7 +114,7 @@ edit_note (char **note, char *editor)
|
|||||||
|
|
||||||
/* View a note in an external pager. */
|
/* View a note in an external pager. */
|
||||||
void
|
void
|
||||||
view_note (char *note, char *pager)
|
view_note (const char *note, const char *pager)
|
||||||
{
|
{
|
||||||
char fullname[BUFSIZ];
|
char fullname[BUFSIZ];
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ note_read (char *buffer, FILE *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
note_gc_extract_key (struct note_gc_hash *data, char **key, int *len)
|
note_gc_extract_key (struct note_gc_hash *data, const char **key, int *len)
|
||||||
{
|
{
|
||||||
*key = data->hash;
|
*key = data->hash;
|
||||||
*len = strlen (data->hash);
|
*len = strlen (data->hash);
|
||||||
|
@ -119,9 +119,9 @@ notify_bar (void)
|
|||||||
void
|
void
|
||||||
notify_init_vars (void)
|
notify_init_vars (void)
|
||||||
{
|
{
|
||||||
char *time_format = "%T";
|
const char *time_format = "%T";
|
||||||
char *date_format = "%a %F";
|
const char *date_format = "%a %F";
|
||||||
char *cmd = "printf '\\a'";
|
const char *cmd = "printf '\\a'";
|
||||||
|
|
||||||
pthread_mutex_init (&nbar.mutex, NULL);
|
pthread_mutex_init (&nbar.mutex, NULL);
|
||||||
nbar.show = 1;
|
nbar.show = 1;
|
||||||
|
@ -463,7 +463,7 @@ todo_update_panel (int which_pan)
|
|||||||
|
|
||||||
/* Attach a note to a todo */
|
/* Attach a note to a todo */
|
||||||
void
|
void
|
||||||
todo_edit_note (char *editor)
|
todo_edit_note (const char *editor)
|
||||||
{
|
{
|
||||||
struct todo *i = todo_get_item (hilt);
|
struct todo *i = todo_get_item (hilt);
|
||||||
edit_note (&i->note, editor);
|
edit_note (&i->note, editor);
|
||||||
@ -471,7 +471,7 @@ todo_edit_note (char *editor)
|
|||||||
|
|
||||||
/* View a note previously attached to a todo */
|
/* View a note previously attached to a todo */
|
||||||
void
|
void
|
||||||
todo_view_note (char *pager)
|
todo_view_note (const char *pager)
|
||||||
{
|
{
|
||||||
struct todo *i = todo_get_item (hilt);
|
struct todo *i = todo_get_item (hilt);
|
||||||
view_note (i->note, pager);
|
view_note (i->note, pager);
|
||||||
|
22
src/utils.c
22
src/utils.c
@ -148,7 +148,7 @@ void
|
|||||||
warnbox (const char *msg)
|
warnbox (const char *msg)
|
||||||
{
|
{
|
||||||
WINDOW *warnwin;
|
WINDOW *warnwin;
|
||||||
char *label = "/!\\";
|
const char *label = "/!\\";
|
||||||
const int WINROW = 10;
|
const int WINROW = 10;
|
||||||
const int WINCOL = col - 2;
|
const int WINCOL = col - 2;
|
||||||
const int MSGLEN = WINCOL - 2;
|
const int MSGLEN = WINCOL - 2;
|
||||||
@ -207,8 +207,8 @@ erase_window_part (WINDOW *win, int first_col, int first_row, int last_col,
|
|||||||
|
|
||||||
/* draws a popup window */
|
/* draws a popup window */
|
||||||
WINDOW *
|
WINDOW *
|
||||||
popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
|
popup (int pop_row, int pop_col, int pop_y, int pop_x, const char *title,
|
||||||
int hint)
|
const char *msg, int hint)
|
||||||
{
|
{
|
||||||
const char *any_key = _("Press any key to continue...");
|
const char *any_key = _("Press any key to continue...");
|
||||||
char label[BUFSIZ];
|
char label[BUFSIZ];
|
||||||
@ -308,7 +308,7 @@ date2sec (struct date day, unsigned hour, unsigned min)
|
|||||||
|
|
||||||
/* Return a string containing the date, given a date in seconds. */
|
/* Return a string containing the date, given a date in seconds. */
|
||||||
char *
|
char *
|
||||||
date_sec2date_str (long sec, char *datefmt)
|
date_sec2date_str (long sec, const char *datefmt)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
char *datestr = (char *) mem_calloc (BUFSIZ, sizeof (char));
|
char *datestr = (char *) mem_calloc (BUFSIZ, sizeof (char));
|
||||||
@ -431,8 +431,8 @@ draw_scrollbar (WINDOW *win, int y, int x, int length,
|
|||||||
* long to fit in its corresponding panel window.
|
* long to fit in its corresponding panel window.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
|
item_in_popup (const char *saved_a_start, const char *saved_a_end,
|
||||||
char *pop_title)
|
const char *msg, const char *pop_title)
|
||||||
{
|
{
|
||||||
WINDOW *popup_win, *pad;
|
WINDOW *popup_win, *pad;
|
||||||
const int margin_left = 4, margin_top = 4;
|
const int margin_left = 4, margin_top = 4;
|
||||||
@ -866,7 +866,7 @@ psleep (unsigned secs)
|
|||||||
* appropriate file descriptors are written to pfdin/pfdout.
|
* appropriate file descriptors are written to pfdin/pfdout.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
|
fork_exec (int *pfdin, int *pfdout, const char *path, const char *const *arg)
|
||||||
{
|
{
|
||||||
int pin[2], pout[2];
|
int pin[2], pout[2];
|
||||||
int pid;
|
int pid;
|
||||||
@ -894,7 +894,7 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
|
|||||||
close (pin[1]);
|
close (pin[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
execvp (path, arg);
|
execvp (path, (char *const *)arg);
|
||||||
_exit (127);
|
_exit (127);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -931,9 +931,9 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
|
|||||||
|
|
||||||
/* Execute an external program in a shell. */
|
/* Execute an external program in a shell. */
|
||||||
int
|
int
|
||||||
shell_exec (int *pfdin, int *pfdout, char *cmd)
|
shell_exec (int *pfdin, int *pfdout, const char *cmd)
|
||||||
{
|
{
|
||||||
char *arg[] = { "/bin/sh", "-c", cmd, NULL };
|
const char *arg[] = { "/bin/sh", "-c", cmd, NULL };
|
||||||
return fork_exec (pfdin, pfdout, *arg, arg);
|
return fork_exec (pfdin, pfdout, *arg, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ press_any_key (void)
|
|||||||
* (patch submitted by Erik Saule).
|
* (patch submitted by Erik Saule).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
print_notefile (FILE *out, char *filename, int nbtab)
|
print_notefile (FILE *out, const char *filename, int nbtab)
|
||||||
{
|
{
|
||||||
char path_to_notefile[BUFSIZ];
|
char path_to_notefile[BUFSIZ];
|
||||||
FILE *notefile;
|
FILE *notefile;
|
||||||
|
@ -65,7 +65,7 @@ int read_only = 0;
|
|||||||
* variables to store calendar names
|
* variables to store calendar names
|
||||||
*/
|
*/
|
||||||
int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
char *monthnames[12] = {
|
const char *monthnames[12] = {
|
||||||
N_("January"),
|
N_("January"),
|
||||||
N_("February"),
|
N_("February"),
|
||||||
N_("March"),
|
N_("March"),
|
||||||
@ -80,7 +80,7 @@ char *monthnames[12] = {
|
|||||||
N_("December")
|
N_("December")
|
||||||
};
|
};
|
||||||
|
|
||||||
char *daynames[8] = {
|
const char *daynames[8] = {
|
||||||
N_("Sun"),
|
N_("Sun"),
|
||||||
N_("Mon"),
|
N_("Mon"),
|
||||||
N_("Tue"),
|
N_("Tue"),
|
||||||
@ -123,7 +123,7 @@ struct dmon_conf dmon;
|
|||||||
void
|
void
|
||||||
vars_init (void)
|
vars_init (void)
|
||||||
{
|
{
|
||||||
char *ed, *pg;
|
const char *ed, *pg;
|
||||||
|
|
||||||
/* Variables for user configuration */
|
/* Variables for user configuration */
|
||||||
conf.confirm_quit = 1;
|
conf.confirm_quit = 1;
|
||||||
|
@ -620,9 +620,9 @@ wins_unprepare_external (void)
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
wins_launch_external (char *file, char *cmd)
|
wins_launch_external (const char *file, const char *cmd)
|
||||||
{
|
{
|
||||||
char *arg[] = { cmd, file, NULL };
|
const char *arg[] = { cmd, file, NULL };
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
wins_prepare_external ();
|
wins_prepare_external ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user