summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-05-08 20:24:48 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-05-08 21:50:05 +0200
commit6da787a5cc94d1b20d0730c18905ff3b93201874 (patch)
treeef11c9e2704e9006d11b7edf31e0ab1afb56a603 /src
parenta20f36c5deae91805d936c6f7a726cf9c78ad70d (diff)
downloadcalcurse-6da787a5cc94d1b20d0730c18905ff3b93201874.tar.gz
calcurse-6da787a5cc94d1b20d0730c18905ff3b93201874.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/args.c13
-rw-r--r--src/calcurse.h103
-rw-r--r--src/calendar.c6
-rw-r--r--src/config.c6
-rw-r--r--src/custom.c14
-rw-r--r--src/day.c6
-rw-r--r--src/help.c2
-rw-r--r--src/htable.h2
-rw-r--r--src/ical.c2
-rw-r--r--src/io.c27
-rw-r--r--src/keys.c16
-rw-r--r--src/note.c8
-rw-r--r--src/notify.c6
-rw-r--r--src/todo.c4
-rw-r--r--src/utils.c22
-rw-r--r--src/vars.c6
-rw-r--r--src/wins.c4
17 files changed, 125 insertions, 122 deletions
diff --git a/src/args.c b/src/args.c
index b861018..1a4b38c 100644
--- a/src/args.c
+++ b/src/args.c
@@ -480,8 +480,9 @@ display_app (struct tm *t, int numdays, int add_line, const char *fmt_apt,
* days.
*/
static void
-date_arg (char *ddate, int add_line, const char *fmt_apt, const char *fmt_rapt,
- const char *fmt_ev, const char *fmt_rev, regex_t *regex)
+date_arg (const char *ddate, int add_line, const char *fmt_apt,
+ const char *fmt_rapt, const char *fmt_ev, const char *fmt_rev,
+ regex_t *regex)
{
int i;
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.
*/
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_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";
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
- char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
- char *datadir = NULL, *ifile = NULL;
+ const char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
+ const char *datadir = NULL, *ifile = NULL;
regex_t reg, *preg = NULL;
/* Long options only */
@@ -644,7 +645,7 @@ parse_args (int argc, char **argv)
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[] = {
{"appointment", no_argument, NULL, 'a'},
diff --git a/src/calcurse.h b/src/calcurse.h
index b07ce45..f2e6991 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -228,17 +228,17 @@
/* General configuration variables. */
struct conf {
- unsigned auto_save;
- unsigned auto_gc;
- unsigned periodic_save;
- unsigned confirm_quit;
- unsigned confirm_delete;
- unsigned system_dialogs;
- unsigned progress_bar;
- char *editor;
- char *pager;
- char output_datefmt[BUFSIZ]; /* format for displaying date */
- int input_datefmt; /* format for reading date */
+ unsigned auto_save;
+ unsigned auto_gc;
+ unsigned periodic_save;
+ unsigned confirm_quit;
+ unsigned confirm_delete;
+ unsigned system_dialogs;
+ unsigned progress_bar;
+ const char *editor;
+ const char *pager;
+ char output_datefmt[BUFSIZ]; /* format for displaying date */
+ int input_datefmt; /* format for reading date */
};
/* Daemon-related configuration. */
@@ -482,7 +482,7 @@ struct nbar {
char datefmt[BUFSIZ]; /* format for displaying date */
char timefmt[BUFSIZ]; /* format for displaying time */
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 */
pthread_mutex_t mutex;
};
@@ -618,7 +618,7 @@ void calendar_change_day (int);
void calendar_move (enum move, int);
long calendar_start_of_year (void);
long calendar_end_of_year (void);
-char *calendar_get_pom (time_t);
+const char *calendar_get_pom (time_t);
/* config.c */
@@ -654,8 +654,8 @@ int day_cut_item (long, int);
int day_paste_item (long, int);
struct day_item *day_get_item (int);
int day_item_nb (long, int, int);
-void day_edit_note (char *);
-void day_view_note (char *);
+void day_edit_note (const char *);
+void day_view_note (const char *);
void day_pipe_item (void);
/* dmon.c */
@@ -690,7 +690,7 @@ void ical_export_data (FILE *);
/* io.c */
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);
unsigned io_save_apts (void);
unsigned io_save_todo (void);
@@ -698,7 +698,7 @@ unsigned io_save_keys (void);
void io_save_cal (enum save_display);
void io_load_app (void);
void io_load_todo (void);
-void io_load_keys (char *);
+void io_load_keys (const char *);
void io_check_dir (char *, int *);
unsigned io_file_exist (char *);
void io_check_file (char *, int *);
@@ -706,10 +706,10 @@ int io_check_data_files (void);
void io_startup_screen (int);
void io_export_data (enum export_type);
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);
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_start_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 *);
/* keys.c */
-void keys_init (void);
-void keys_free (void);
-void keys_dump_defaults (char *);
-char *keys_get_label (enum key);
-enum key keys_get_action (int);
-enum key keys_getch (WINDOW *win, int *);
-int keys_assign_binding (int, enum key);
-void keys_remove_binding (int, enum key);
-int keys_str2int (char *);
-char *keys_int2str (int);
-int keys_action_count_keys (enum key);
-char *keys_action_firstkey (enum key);
-char *keys_action_nkey (enum key, int);
-char *keys_action_allkeys (enum key);
-void keys_display_bindings_bar (WINDOW *, struct binding *[], int, int,
- int, struct binding *);
-void keys_popup_info (enum key);
-void keys_save_bindings (FILE *);
-int keys_check_missing_bindings (void);
-void keys_fill_missing (void);
+void keys_init (void);
+void keys_free (void);
+void keys_dump_defaults (char *);
+const char *keys_get_label (enum key);
+enum key keys_get_action (int);
+enum key keys_getch (WINDOW *win, int *);
+int keys_assign_binding (int, enum key);
+void keys_remove_binding (int, enum key);
+int keys_str2int (const char *);
+const char *keys_int2str (int);
+int keys_action_count_keys (enum key);
+const char *keys_action_firstkey (enum key);
+const char *keys_action_nkey (enum key, int);
+char *keys_action_allkeys (enum key);
+void keys_display_bindings_bar (WINDOW *, struct binding *[], int, int,
+ int, struct binding *);
+void keys_popup_info (enum key);
+void keys_save_bindings (FILE *);
+int keys_check_missing_bindings (void);
+void keys_fill_missing (void);
/* mem.c */
void *xmalloc (size_t);
@@ -776,8 +776,8 @@ void mem_stats (void);
/* note.c */
char *generate_note (const char *);
-void edit_note (char **, char *);
-void view_note (char *, char *);
+void edit_note (char **, const char *);
+void view_note (const char *, const char *);
void erase_note (char **);
void note_read (char *, FILE *);
void note_gc (void);
@@ -879,8 +879,8 @@ void todo_delete (void);
void todo_chg_priority (int);
void todo_edit_item (void);
void todo_update_panel (int);
-void todo_edit_note (char *);
-void todo_view_note (char *);
+void todo_edit_note (const char *);
+void todo_view_note (const char *);
void todo_pipe_item (void);
void todo_init_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_yesno (const char *);
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 *);
int is_all_digit (const char *);
long get_item_time (long);
int get_item_hour (long);
int get_item_min (long);
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 *);
long date_sec_change (long, int, int);
long update_time_in_date (long, unsigned, unsigned);
long get_sec_date (struct date);
long min2sec (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 now (void);
char *nowstr (void);
@@ -926,8 +927,8 @@ int parse_duration (const char *, unsigned *);
void str_toupper (char *);
void file_close (FILE *, const char *);
void psleep (unsigned);
-int fork_exec (int *, int *, const char *, char *const *);
-int shell_exec (int *, int *, char *);
+int fork_exec (int *, int *, const char *, const char *const *);
+int shell_exec (int *, int *, const char *);
int child_wait (int *, int *, int);
void press_any_key (void);
void print_apoint (const char *, long, struct apoint *);
@@ -945,8 +946,8 @@ extern int foreground, background;
extern enum ui_mode ui_mode;
extern int read_only;
extern int days[12];
-extern char *monthnames[12];
-extern char *daynames[8];
+extern const char *monthnames[12];
+extern const char *daynames[8];
extern char path_dir[BUFSIZ];
extern char path_todo[BUFSIZ];
extern char path_apts[BUFSIZ];
@@ -994,7 +995,7 @@ void wins_update (int);
void wins_reset (void);
void wins_prepare_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_erase_status_bar (void);
void wins_other_status_page (int);
diff --git a/src/calendar.c b/src/calendar.c
index 7ef7f0f..564ee70 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -632,7 +632,7 @@ calendar_change_day (int datefmt)
_("The day you entered is not valid "
"(should be between 01/01/1902 and 12/31/2037)");
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)
{
@@ -910,10 +910,10 @@ pom (time_t tmpt)
* Careful: date is the selected day in calendar at 00:00, so it represents
* the phase of the moon for previous day.
*/
-char *
+const char *
calendar_get_pom (time_t date)
{
- char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
+ const char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
enum pom phase = NO_POM;
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
const double half = 50.0;
diff --git a/src/config.c b/src/config.c
index 30c98e1..88d5acc 100644
--- a/src/config.c
+++ b/src/config.c
@@ -337,9 +337,9 @@ config_color_theme_name (char *theme_name)
int i;
short color[NBCOLORS];
- char *color_name[NBCOLORS];
- char *default_color = "default";
- char *name[MAXCOLORS] = {
+ const char *color_name[NBCOLORS];
+ const char *default_color = "default";
+ const char *name[MAXCOLORS] = {
"black",
"red",
"green",
diff --git a/src/custom.c b/src/custom.c
index e347850..960837d 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -157,7 +157,7 @@ display_layout_config (struct window *lwin, int mark, int cursor)
#define MARK 88
#define LAYOUTH 5
#define LAYOUTW 9
- char *box = "[ ]";
+ const char *box = "[ ]";
const int BOXSIZ = strlen (box);
const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL;
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;
enum {YPOS, XPOS, NBPOS};
int pos[NBLAYOUTS][NBPOS];
- char *layouts[LAYOUTH][NBLAYOUTS] = {
+ const char *layouts[LAYOUTH][NBLAYOUTS] = {
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"},
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |", "| | a |", "| c | |", "| a | |"},
{"| 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 *back_txt = _("Background");
const char *default_txt = _("(terminal's default)");
- char *bar = " ";
- char *box = "[ ]";
+ const char *bar = " ";
+ const char *box = "[ ]";
const unsigned Y = 3;
const unsigned XOFST = 5;
const unsigned YSPC = (cwin->h - 8) / (NBUSERCOLORS + 1);
@@ -869,7 +869,7 @@ custom_general_config (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;
@@ -907,7 +907,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
{
if (action == selected_row)
{
- char *key;
+ const char *key;
int pos;
pos = KEYPOS;
@@ -959,7 +959,7 @@ custom_keys_config (void)
struct scrollwin kwin;
int selrow, selelm, firstrow, lastrow, nbrowelm, nbdisplayed;
int keyval, used, not_recognized;
- char *keystr;
+ const char *keystr;
WINDOW *grabwin;
const int LINESPERKEY = 2;
const int LABELLINES = 3;
diff --git a/src/day.c b/src/day.c
index 2660fee..8ed5de7 100644
--- a/src/day.c
+++ b/src/day.c
@@ -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_time = _("Invalid time: start time must be before end time!");
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";
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. */
void
-day_edit_note (char *editor)
+day_edit_note (const char *editor)
{
struct day_item *p;
struct recur_apoint *ra;
@@ -1130,7 +1130,7 @@ day_edit_note (char *editor)
/* View a note previously attached to an appointment or event */
void
-day_view_note (char *pager)
+day_view_note (const char *pager)
{
struct day_item *p = day_get_item (apoint_hilt ());
view_note (p->note, pager);
diff --git a/src/help.c b/src/help.c
index 3c3ebbf..04c25d9 100644
--- a/src/help.c
+++ b/src/help.c
@@ -100,7 +100,7 @@ static int
help_write_pad (struct window *win, char *title, char *text, enum key action)
{
int colnum, rownum;
- char *bindings_title = "key bindings: %s";
+ const char *bindings_title = "key bindings: %s";
char *bindings;
colnum = 0;
diff --git a/src/htable.h b/src/htable.h
index 654bf57..91d01d8 100644
--- a/src/htable.h
+++ b/src/htable.h
@@ -118,7 +118,7 @@ uint32_t \
name##_HTABLE_FIND_BKT(struct name *head, struct type *elm) \
{ \
uint32_t __bkt; \
- char *__key; \
+ const char *__key; \
int __len; \
\
(key) (elm, &__key, &__len); \
diff --git a/src/ical.c b/src/ical.c
index d646072..375f3a1 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -68,7 +68,7 @@ static void ical_export_apoints (FILE *);
static void ical_export_todo (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" };
/* iCal alarm notification. */
diff --git a/src/io.c b/src/io.c
index f6388df..737a198 100644
--- a/src/io.c
+++ b/src/io.c
@@ -67,12 +67,13 @@ enum {
};
struct ht_keybindings_s {
- char *label;
- enum key key;
+ const char *label;
+ enum key key;
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 *,
struct ht_keybindings_s *);
@@ -94,14 +95,14 @@ progress_bar (progress_bar_t type, int progress)
const char *mesg_load = _("Loading...");
const char *mesg_export = _("Exporting...");
const char *error_msg = _("Internal error while displaying progress bar");
- char *barchar = "|";
- char *file[NBFILES] = {
+ const char *barchar = "|";
+ const char *file[NBFILES] = {
"[ conf ]",
"[ todo ]",
"[ apts ]",
"[ keys ]"
};
- char *data[NBEXPORTED] = {
+ const char *data[NBEXPORTED] = {
"[ events ]",
"[appointments]",
"[ 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.
*/
void
-io_init (char *cfile, char *datadir)
+io_init (const char *cfile, const char *datadir)
{
FILE *data_file;
- char *home;
+ const char *home;
char apts_file[BUFSIZ] = "";
int ch;
@@ -723,7 +724,7 @@ io_load_todo (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;
*len = strlen (data->label);
@@ -760,7 +761,7 @@ static int is_blank (int c)
* configuration file.
*/
void
-io_load_keys (char *pager)
+io_load_keys (const char *pager)
{
struct ht_keybindings_s keys[NBKEYS];
FILE *keyfp;
@@ -1108,7 +1109,7 @@ get_import_stream (enum export_type type)
* and is cleared at the end.
*/
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 ");
char stats_str[4][BUFSIZ];
@@ -1232,7 +1233,7 @@ io_log_print (struct io_file *log, int line, const char *msg)
}
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;
@@ -1243,7 +1244,7 @@ io_log_display (struct io_file *log, const char *msg, char *pager)
ans = fgetc (stdin);
if (ans == 'y')
{
- char *arg[] = { pager, log->name, NULL };
+ const char *arg[] = { pager, log->name, NULL };
int pid;
if ((pid = fork_exec (NULL, NULL, pager, arg)))
diff --git a/src/keys.c b/src/keys.c
index a218d6e..8647e67 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -42,8 +42,8 @@
#define MAXKEYVAL KEY_MAX /* ncurses defines KEY_MAX as maximum key value */
struct keydef_s {
- char *label;
- char *binding;
+ const char *label;
+ const char *binding;
};
static llist_t keys[NBKEYS];
@@ -166,7 +166,7 @@ keys_dump_defaults (char *file)
file_close (fd, __FILE_POS__);
}
-char *
+const char *
keys_get_label (enum key key)
{
EXIT_IF (key < 0 || key > NBKEYS,
@@ -269,7 +269,7 @@ keys_remove_binding (int key, enum key action)
}
int
-keys_str2int (char *key)
+keys_str2int (const char *key)
{
const char CONTROL_KEY[] = "C-";
const char TAB_KEY[] = "TAB";
@@ -315,7 +315,7 @@ keys_str2int (char *key)
}
}
-char *
+const char *
keys_int2str (int key)
{
switch (key)
@@ -355,14 +355,14 @@ keys_action_count_keys (enum key action)
return n;
}
-char *
+const char *
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";
}
-char *
+const char *
keys_action_nkey (enum key action, int keynum)
{
return LLIST_GET_DATA (LLIST_NTH (&keys[action], keynum));
diff --git a/src/note.c b/src/note.c
index a65a384..09b6d0d 100644
--- a/src/note.c
+++ b/src/note.c
@@ -46,7 +46,7 @@ struct 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 *);
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. */
void
-edit_note (char **note, char *editor)
+edit_note (char **note, const char *editor)
{
char tmppath[BUFSIZ];
char *tmpext;
@@ -114,7 +114,7 @@ edit_note (char **note, char *editor)
/* View a note in an external pager. */
void
-view_note (char *note, char *pager)
+view_note (const char *note, const char *pager)
{
char fullname[BUFSIZ];
@@ -155,7 +155,7 @@ note_read (char *buffer, FILE *fp)
}
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;
*len = strlen (data->hash);
diff --git a/src/notify.c b/src/notify.c
index 70b5419..0ef4189 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -119,9 +119,9 @@ notify_bar (void)
void
notify_init_vars (void)
{
- char *time_format = "%T";
- char *date_format = "%a %F";
- char *cmd = "printf '\\a'";
+ const char *time_format = "%T";
+ const char *date_format = "%a %F";
+ const char *cmd = "printf '\\a'";
pthread_mutex_init (&nbar.mutex, NULL);
nbar.show = 1;
diff --git a/src/todo.c b/src/todo.c
index 27e9c36..a4c75da 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -463,7 +463,7 @@ todo_update_panel (int which_pan)
/* Attach a note to a todo */
void
-todo_edit_note (char *editor)
+todo_edit_note (const char *editor)
{
struct todo *i = todo_get_item (hilt);
edit_note (&i->note, editor);
@@ -471,7 +471,7 @@ todo_edit_note (char *editor)
/* View a note previously attached to a todo */
void
-todo_view_note (char *pager)
+todo_view_note (const char *pager)
{
struct todo *i = todo_get_item (hilt);
view_note (i->note, pager);
diff --git a/src/utils.c b/src/utils.c
index aa4a2d6..8ddbe59 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -148,7 +148,7 @@ void
warnbox (const char *msg)
{
WINDOW *warnwin;
- char *label = "/!\\";
+ const char *label = "/!\\";
const int WINROW = 10;
const int WINCOL = col - 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 */
WINDOW *
-popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
- int hint)
+popup (int pop_row, int pop_col, int pop_y, int pop_x, const char *title,
+ const char *msg, int hint)
{
const char *any_key = _("Press any key to continue...");
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. */
char *
-date_sec2date_str (long sec, char *datefmt)
+date_sec2date_str (long sec, const char *datefmt)
{
struct tm *lt;
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.
*/
void
-item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
- char *pop_title)
+item_in_popup (const char *saved_a_start, const char *saved_a_end,
+ const char *msg, const char *pop_title)
{
WINDOW *popup_win, *pad;
const int margin_left = 4, margin_top = 4;
@@ -866,7 +866,7 @@ psleep (unsigned secs)
* appropriate file descriptors are written to pfdin/pfdout.
*/
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 pid;
@@ -894,7 +894,7 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
close (pin[1]);
}
- execvp (path, arg);
+ execvp (path, (char *const *)arg);
_exit (127);
}
else
@@ -931,9 +931,9 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
/* Execute an external program in a shell. */
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);
}
@@ -973,7 +973,7 @@ press_any_key (void)
* (patch submitted by Erik Saule).
*/
static void
-print_notefile (FILE *out, char *filename, int nbtab)
+print_notefile (FILE *out, const char *filename, int nbtab)
{
char path_to_notefile[BUFSIZ];
FILE *notefile;
diff --git a/src/vars.c b/src/vars.c
index 056cb71..db8541b 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -65,7 +65,7 @@ int read_only = 0;
* variables to store calendar names
*/
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_("February"),
N_("March"),
@@ -80,7 +80,7 @@ char *monthnames[12] = {
N_("December")
};
-char *daynames[8] = {
+const char *daynames[8] = {
N_("Sun"),
N_("Mon"),
N_("Tue"),
@@ -123,7 +123,7 @@ struct dmon_conf dmon;
void
vars_init (void)
{
- char *ed, *pg;
+ const char *ed, *pg;
/* Variables for user configuration */
conf.confirm_quit = 1;
diff --git a/src/wins.c b/src/wins.c
index a1004d2..cdb6f5b 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -620,9 +620,9 @@ wins_unprepare_external (void)
* file.
*/
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;
wins_prepare_external ();