From 71da9df0b39c15a3557aa5d9d4d682da54c563e8 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Thu, 16 Jan 2014 09:24:53 +2000 Subject: [PATCH] Re: [PATCH 1/2] cli: abstract common config get/set code --- 1c/303ee95a70f8b8047189811800f4e8c75f42c2 | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 1c/303ee95a70f8b8047189811800f4e8c75f42c2 diff --git a/1c/303ee95a70f8b8047189811800f4e8c75f42c2 b/1c/303ee95a70f8b8047189811800f4e8c75f42c2 new file mode 100644 index 000000000..833ba916b --- /dev/null +++ b/1c/303ee95a70f8b8047189811800f4e8c75f42c2 @@ -0,0 +1,85 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id B91C0431FBD + for ; Wed, 15 Jan 2014 05:25:09 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id SqfPCPB7OOlw for ; + Wed, 15 Jan 2014 05:25:01 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id E150F431FAF + for ; Wed, 15 Jan 2014 05:25:01 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1W3QSn-0005ej-0x; Wed, 15 Jan 2014 09:24:57 -0400 +Received: (nullmailer pid 24745 invoked by uid 1000); Wed, 15 Jan 2014 + 13:24:53 -0000 +From: David Bremner +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/2] cli: abstract common config get/set code +In-Reply-To: <1376839205-5115-1-git-send-email-jani@nikula.org> +References: <1376839205-5115-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.17+30~g50677dd (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Wed, 15 Jan 2014 09:24:53 -0400 +Message-ID: <871u09js2i.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 15 Jan 2014 13:25:09 -0000 + +Jani Nikula writes: + +> Pretty straightforward abstraction similar to get/set list. +> --- +> notmuch-config.c | 80 ++++++++++++++++++++---------------------------------- +> 1 file changed, 29 insertions(+), 51 deletions(-) +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index befe9b5..305d213 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -496,6 +496,29 @@ notmuch_config_is_new (notmuch_config_t *config) +> return config->is_new; +> } +> +> +static const char * +> +_config_get (notmuch_config_t *config, char **field, +> + const char *group, const char *key) +> +{ +> + if (*field == NULL) { +> + char *value; +> + value = g_key_file_get_string (config->key_file, group, key, NULL); +> + if (value) { +> + *field = talloc_strdup (config, value); +> + free (value); +> + } +> + } +> + return *field; +> +} +> + + +The use of NULL here is clear enough in the context of the patch, but I +think it deserves a comment in the code; it is not obviously just code +movement after the patch is applied. -- 2.26.2