From 05d7a883c99c3120e3d321dedce99f609b58c019 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 28 Sep 2014 20:28:17 +0200 Subject: [PATCH] [WIP 1/3] util: move chomp_newline to string-util.h --- 8e/b69e6d1a433257b6497e2d49be7b3ffe797ba2 | 138 ++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 8e/b69e6d1a433257b6497e2d49be7b3ffe797ba2 diff --git a/8e/b69e6d1a433257b6497e2d49be7b3ffe797ba2 b/8e/b69e6d1a433257b6497e2d49be7b3ffe797ba2 new file mode 100644 index 000000000..e674509e3 --- /dev/null +++ b/8e/b69e6d1a433257b6497e2d49be7b3ffe797ba2 @@ -0,0 +1,138 @@ +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 7ADF6431FC9 + for ; Sun, 28 Sep 2014 11:28:58 -0700 (PDT) +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 RpYcUtKEuTnj for ; + Sun, 28 Sep 2014 11:28:58 -0700 (PDT) +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 16C70431FC7 + for ; Sun, 28 Sep 2014 11:28:58 -0700 (PDT) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1XYJDL-0005g0-F2; Sun, 28 Sep 2014 15:28:55 -0300 +Received: (nullmailer pid 31285 invoked by uid 1000); Sun, 28 Sep 2014 + 18:28:49 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [WIP 1/3] util: move chomp_newline to string-util.h +Date: Sun, 28 Sep 2014 20:28:17 +0200 +Message-Id: <1411928899-29625-2-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.0 +In-Reply-To: <1411928899-29625-1-git-send-email-david@tethera.net> +References: <87iok8vog6.fsf@steelpick.2x.cz> + <1411928899-29625-1-git-send-email-david@tethera.net> +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: Sun, 28 Sep 2014 18:28:58 -0000 + +This allows it to be called from functions in the library, if needed. + +Instead of making all of string-util available to everywhere +notmuch-client.h is included, just add an extra include to the three +places chomp_newline was needed (and string-util.h not yet included). +--- + notmuch-client.h | 7 ------- + notmuch-count.c | 1 + + notmuch-setup.c | 1 + + test/hex-xcode.c | 2 ++ + util/string-util.h | 7 +++++++ + 5 files changed, 11 insertions(+), 7 deletions(-) + +diff --git a/notmuch-client.h b/notmuch-client.h +index e1efbe0..bd01005 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -111,13 +111,6 @@ typedef struct notmuch_show_params { + #define STRNCMP_LITERAL(var, literal) \ + strncmp ((var), (literal), sizeof (literal) - 1) + +-static inline void +-chomp_newline (char *str) +-{ +- if (str && str[strlen(str)-1] == '\n') +- str[strlen(str)-1] = '\0'; +-} +- + /* Exit status code indicating the requested format version is too old + * (support for that version has been dropped). CLI code should use + * notmuch_exit_if_unsupported_format rather than directly exiting +diff --git a/notmuch-count.c b/notmuch-count.c +index 6058f7c..c3f4b54 100644 +--- a/notmuch-count.c ++++ b/notmuch-count.c +@@ -20,6 +20,7 @@ + */ + + #include "notmuch-client.h" ++#include "string-util.h" + + enum { + OUTPUT_THREADS, +diff --git a/notmuch-setup.c b/notmuch-setup.c +index 36a6171..eb91179 100644 +--- a/notmuch-setup.c ++++ b/notmuch-setup.c +@@ -19,6 +19,7 @@ + */ + + #include "notmuch-client.h" ++#include "string-util.h" + + static const char * + make_path_absolute (void *ctx, const char *path) +diff --git a/test/hex-xcode.c b/test/hex-xcode.c +index 65d4956..20d0a68 100644 +--- a/test/hex-xcode.c ++++ b/test/hex-xcode.c +@@ -9,6 +9,8 @@ + + #include "notmuch-client.h" + #include "hex-escape.h" ++#include "string-util.h" ++ + #include + + enum direction { +diff --git a/util/string-util.h b/util/string-util.h +index e409cb3..9337770 100644 +--- a/util/string-util.h ++++ b/util/string-util.h +@@ -64,6 +64,13 @@ int + parse_boolean_term (void *ctx, const char *str, + char **prefix_out, char **term_out); + ++static inline void ++chomp_newline (char *str) ++{ ++ if (str && str[strlen(str)-1] == '\n') ++ str[strlen(str)-1] = '\0'; ++} ++ + #ifdef __cplusplus + } + #endif +-- +2.1.0 + -- 2.26.2