From 46ff3462ccb812d000449866880369571027d5da Mon Sep 17 00:00:00 2001
From: Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
Date: Sun, 12 Mar 2017 17:06:33 -0300
Subject: [PATCH] show correct filename in cerror() messages

---
 lib/log.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/log.c b/lib/log.c
index b97cb7cf8..c6b3dd392 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -308,18 +308,21 @@ void cerror(config_setting_t *cfg, const char *fmt, ...)
 {
 	va_list ap;
 	char *buf = NULL;
+	const char *file;
+	int line;
 
 	assert(log != NULL);
 
 	va_start(ap, fmt);
 	vstrcatf(&buf, fmt, ap);
 	va_end(ap);
+	
+	line = config_setting_source_line(cfg);
+	file = config_setting_source_file(cfg);
+	if (!file)
+		file = config_setting_get_hook(config_root_setting(cfg->config));
 
-	log_print(log, LOG_LVL_ERROR, "%s in %s:%u", buf,
-		config_setting_source_file(cfg)
-		   ? config_setting_source_file(cfg)
-		   : "(stdio)",
-		config_setting_source_line(cfg));
+	log_print(log, LOG_LVL_ERROR, "%s in %s:%u", buf, file, line);
 
 	free(buf);
 	die();