Patchworkβ [1/2] notmuch-show: Do not output (null) when the message body is empty

login
register
about
Submitter Sebastian Spaeth
Date 2010-03-02 10:52:32
Message ID <1267527153-8364-1-git-send-email-Sebastian@SSpaeth.de>
Download mbox | patch
Permalink /patch/405/
State New
Headers show

Comments

Sebastian Spaeth - 2010-03-02 10:52:32
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
---
I actually agree that we should output tags as array, it was just that the get_tags_as_string function was already existing, so that was more convenient. Here comes the second iteration that outputs the tags as json array.

 notmuch-show.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Patch

diff --git a/notmuch-show.c b/notmuch-show.c
index 1a1d601..f21914f 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -311,8 +311,10 @@  format_part_json (GMimeObject *part, int *part_count)
     {
 	show_part_content (part, stream_memory);
 	part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory));
-
-	printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data));
+	if (part_content->data != NULL)
+	  printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data));
+	else
+	  printf (", \"content\": \"\"");
     }
 
     fputs ("}", stdout);