]> git.notmuchmail.org Git - notmuch/commitdiff
lib: return "" rather than NULL from notmuch_thread_get_authors
authorDavid Bremner <david@tethera.net>
Fri, 15 Dec 2017 02:29:57 +0000 (22:29 -0400)
committerDavid Bremner <david@tethera.net>
Thu, 21 Dec 2017 13:22:30 +0000 (09:22 -0400)
The current behaviour is at best under-documented. The modified test in
T470-missing-headers.sh previously relied on printf doing the right
thing with NULL, which seems icky.

The use of talloc_strdup here is probably overkill, but it avoids
having to enforce that thread->authors is never mutated outside
_resolve_thread_authors_string.

lib/thread.cc
test/T470-missing-headers.sh

index 1632da4cd0f4f9398e774b8157004e89914485d9..3561b27f743976d2c2d1918d33fc2a8d33469c74 100644 (file)
@@ -160,6 +160,9 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
     thread->authors_array = NULL;
     g_ptr_array_free (thread->matched_authors_array, true);
     thread->matched_authors_array = NULL;
     thread->authors_array = NULL;
     g_ptr_array_free (thread->matched_authors_array, true);
     thread->matched_authors_array = NULL;
+
+    if (!thread->authors)
+       thread->authors = talloc_strdup(thread, "");
 }
 
 /* clean up the ugly "Lastname, Firstname" format that some mail systems
 }
 
 /* clean up the ugly "Lastname, Firstname" format that some mail systems
index 4bf5d285c49b43c567f94fb85c556b5d34317efc..555fd4e9c51657bc39778446283670f939802caf 100755 (executable)
@@ -25,7 +25,7 @@ NOTMUCH_NEW >/dev/null
 test_begin_subtest "Search: text"
 output=$(notmuch search '*' | notmuch_search_sanitize)
 test_expect_equal "$output" "\
 test_begin_subtest "Search: text"
 output=$(notmuch search '*' | notmuch_search_sanitize)
 test_expect_equal "$output" "\
-thread:XXX   2001-01-05 [1/1] (null);  (inbox unread)
+thread:XXX   2001-01-05 [1/1] ;  (inbox unread)
 thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"
 
 test_begin_subtest "Search: json"
 thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"
 
 test_begin_subtest "Search: json"