summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-15 18:04:24 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-15 18:13:47 +0200
commit1f658881dee9a5aecbd86a7bc5d7fbf68b1c2850 (patch)
treed9a9ee4b35946471ee3521d2d111e8947439ddcd
parentb362c17daa3cf44f6b62648e1b0fe0175c7a01e6 (diff)
downloadcalcurse-1f658881dee9a5aecbd86a7bc5d7fbf68b1c2850.zip
Be stricter when parsing the configuration file
Throw an error message if there is a line that contains an invalid configuration line (e.g. a non-empty line that neither contains a key nor a value). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/custom.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/custom.c b/src/custom.c
index bb84410..3ae181f 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -42,7 +42,6 @@
/* Available configuration variables. */
enum conf_var {
- CUSTOM_CONF_NOVARIABLE,
CUSTOM_CONF_AUTOSAVE,
CUSTOM_CONF_PERIODICSAVE,
CUSTOM_CONF_CONFIRMQUIT,
@@ -62,8 +61,7 @@ enum conf_var {
CUSTOM_CONF_OUTPUTDATEFMT,
CUSTOM_CONF_INPUTDATEFMT,
CUSTOM_CONF_DMON_ENABLE,
- CUSTOM_CONF_DMON_LOG,
- CUSTOM_CONF_VARIABLES
+ CUSTOM_CONF_DMON_LOG
};
struct attribute {
@@ -258,7 +256,9 @@ custom_load_conf (struct conf *conf, int background)
break;
io_extract_data (e_conf, buf, sizeof buf);
- if (strncmp (e_conf, "auto_save=", 10) == 0)
+ if (*e_conf == '\0')
+ continue;
+ else 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;
@@ -300,8 +300,8 @@ custom_load_conf (struct conf *conf, int background)
var = CUSTOM_CONF_DMON_LOG;
else
{
- var = CUSTOM_CONF_NOVARIABLE;
- continue;
+ EXIT (_("configuration variable unknown"));
+ /* NOTREACHED */
}
if (fgets (buf, sizeof buf, data_file) == NULL)
@@ -310,8 +310,6 @@ custom_load_conf (struct conf *conf, int background)
switch (var)
{
- case CUSTOM_CONF_NOVARIABLE:
- break;
case CUSTOM_CONF_AUTOSAVE:
conf->auto_save = fill_config_var (e_conf);
break;
@@ -381,9 +379,6 @@ custom_load_conf (struct conf *conf, int background)
case CUSTOM_CONF_DMON_LOG:
dmon.log = fill_config_var (e_conf);
break;
- default:
- EXIT (_("configuration variable unknown"));
- /* NOTREACHED */
}
}
file_close (data_file, __FILE_POS__);