From b105bf8fab5ca69e9857bbe93db0b30078a2f8a3 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Thu, 16 Feb 2012 10:45:09 +0100
Subject: src/config.c: Add junk callback to config_file_walk()

This can be used if we care about junk, such as empty lines and
comments. Currently unused since we skip these when parsing
configuration settings. This makes sense if we want to make slight
modifications to the configuration file without losing formatting and
comments, though.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/config.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/config.c b/src/config.c
index 14294cc..f91b643 100644
--- a/src/config.c
+++ b/src/config.c
@@ -39,6 +39,7 @@
 #include "calcurse.h"
 
 typedef int (*config_fn_walk_cb_t) (const char *, const char *, void *);
+typedef int (*config_fn_walk_junk_cb_t) (const char *, void *);
 
 static int
 config_parse_bool (unsigned *dest, const char *val)
@@ -228,7 +229,8 @@ config_set_conf (const char *key, const char *value)
 }
 
 static void
-config_file_walk (config_fn_walk_cb_t fn_cb, void *data)
+config_file_walk (config_fn_walk_cb_t fn_cb,
+                  config_fn_walk_junk_cb_t fn_junk_cb, void *data)
 {
   FILE *data_file;
   char *mesg_line1 = _("Failed to open config file");
@@ -253,7 +255,11 @@ config_file_walk (config_fn_walk_cb_t fn_cb, void *data)
       io_extract_data (e_conf, buf, sizeof buf);
 
       if (*e_conf == '\0')
-        continue;
+        {
+          if (fn_junk_cb)
+            fn_junk_cb (buf, data);
+          continue;
+        }
 
       key = e_conf;
       value = strchr (e_conf, '=');
@@ -297,7 +303,7 @@ config_load_cb (const char *key, const char *value, void *dummy)
 void
 config_load (void)
 {
-  config_file_walk (config_load_cb, NULL);
+  config_file_walk (config_load_cb, NULL, NULL);
 }
 
 /*
-- 
cgit v1.2.3-70-g09d2