summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-08-18 12:27:22 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-08-18 12:27:22 +0200
commit0a2c4d20fe49c504b5bbb383afc97db340814bba (patch)
treed5853c4f0c9a13f95ceb35442acfc3456975d1f2
parentf3fe3c818cf277a547024492abd90c155dab1cd4 (diff)
downloadcalcurse-0a2c4d20fe49c504b5bbb383afc97db340814bba.zip
Retain comments in descriptions and config values
Comments should only be stripped if they start at the beginning of a line. We do not want to chop off an TODO item description or a configuration value. Reported-by: HÃ¥kan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/config.c4
-rw-r--r--src/io.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index cd9ca50..2e7d483 100644
--- a/src/config.c
+++ b/src/config.c
@@ -470,7 +470,7 @@ config_file_walk(config_fn_walk_cb_t fn_cb,
break;
io_extract_data(e_conf, buf, sizeof buf);
- if (*e_conf == '\0') {
+ if (*e_conf == '\0' || *e_conf == '#') {
if (fn_junk_cb)
fn_junk_cb(buf, data);
continue;
@@ -517,6 +517,8 @@ config_file_walk(config_fn_walk_cb_t fn_cb,
if (fgets(buf, sizeof buf, data_file) == NULL)
break;
io_extract_data(e_conf, buf, sizeof buf);
+ if (*e_conf == '#')
+ *e_conf = '\0';
value = e_conf;
}
diff --git a/src/io.c b/src/io.c
index dca23d1..8d1d886 100644
--- a/src/io.c
+++ b/src/io.c
@@ -274,7 +274,7 @@ void io_extract_data(char *dst_data, const char *org, int len)
for (; *org == ' ' || *org == '\t'; org++) ;
for (i = 0; i < len - 1; i++) {
- if (*org == '\n' || *org == '\0' || *org == '#')
+ if (*org == '\n' || *org == '\0')
break;
*dst_data++ = *org++;
}