[PATCH 2/2] lib/config: use g_key_file_get_string to read config values

Subject: [PATCH 2/2] lib/config: use g_key_file_get_string to read config values

Date: Thu, 30 Sep 2021 15:28:35 -0300

To: David Bremner, notmuch@notmuchmail.org, Ciprian Dorin Craciun

Cc:

From: David Bremner


Unlike the previous g_key_file_get_value, this version processes
escape codes for whitespace and \. The remaining two broken tests from
the last commit are because "notmuch config get" treats every value as
a list, and thus the previously introduces stripping of leading
whitespace applies.
---
 lib/config.cc | 2 +-
 lib/open.cc   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/config.cc b/lib/config.cc
index 8775b00a..d57240d1 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -427,7 +427,7 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch,
 	for (gchar **keys_p = keys; *keys_p; keys_p++) {
 	    char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp,  *keys_p);
 	    char *normalized_val;
-	    val = g_key_file_get_value (file, *grp, *keys_p, NULL);
+	    val = g_key_file_get_string (file, *grp, *keys_p, NULL);
 	    if (! val) {
 		status = NOTMUCH_STATUS_FILE_ERROR;
 		goto DONE;
diff --git a/lib/open.cc b/lib/open.cc
index 8a835e98..0f44b858 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -199,7 +199,7 @@ _choose_database_path (void *ctx,
     }
 
     if (! *database_path && key_file) {
-	char *path = g_key_file_get_value (key_file, "database", "path", NULL);
+	char *path = g_key_file_get_string (key_file, "database", "path", NULL);
 	if (path) {
 	    if (path[0] == '/')
 		*database_path = talloc_strdup (ctx, path);
@@ -637,7 +637,7 @@ notmuch_database_create_with_config (const char *database_path,
 
     if (key_file && ! split) {
 	char *mail_root = notmuch_canonicalize_file_name (
-	    g_key_file_get_value (key_file, "database", "mail_root", NULL));
+	    g_key_file_get_string (key_file, "database", "mail_root", NULL));
 	char *db_path = notmuch_canonicalize_file_name (database_path);
 
 	split = (mail_root && (0 != strcmp (mail_root, db_path)));
-- 
2.33.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: