summaryrefslogtreecommitdiff
path: root/src/io.c
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/io.c
parenta20f36c5deae91805d936c6f7a726cf9c78ad70d (diff)
downloadcalcurse-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/io.c')
-rw-r--r--src/io.c27
1 files changed, 14 insertions, 13 deletions
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)))