From c2b33333b84dd0534b2cb153c7a9f31c354ddad4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 3 Apr 2021 12:55:33 +0200 Subject: m + add more tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- get-contact-emails.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'get-contact-emails.c') diff --git a/get-contact-emails.c b/get-contact-emails.c index 891c873..c41b48f 100644 --- a/get-contact-emails.c +++ b/get-contact-emails.c @@ -57,8 +57,10 @@ main(int argc, char *argv[]) if (libcontacts_load_contact(*argv, &contact, user)) { weprintf("libcontacts_load_contact %s: %s\n", *argv, errno ? strerror(errno) : "contact file is malformatted"); ret = 1; - } else { - for (emails = contact.emails; (email = *emails); emails++) { + continue; + } + if ((emails = contact.emails)) { + for (; (email = *emails); emails++) { if (lookup_ctx && strcmpnul(email->context, lookup_ctx)) continue; if (lookup_addr && strcmpnul(email->address, lookup_addr)) @@ -76,8 +78,8 @@ main(int argc, char *argv[]) else printf("%s\n", email->context); } - libcontacts_contact_destroy(&contact); } + libcontacts_contact_destroy(&contact); } if (fflush(stdout) || ferror(stdout) || fclose(stdout)) -- cgit v1.2.3-70-g09d2