diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-03 10:31:02 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-03 10:31:02 +0200 |
commit | c3cac7a521857747771f661d607004f58470e0cc (patch) | |
tree | 91a9058a1000a121a7c89dd7869c866b4d63ca80 | |
parent | First commmit (diff) | |
download | contacts-c3cac7a521857747771f661d607004f58470e0cc.tar.gz contacts-c3cac7a521857747771f661d607004f58470e0cc.tar.bz2 contacts-c3cac7a521857747771f661d607004f58470e0cc.tar.xz |
Use strcmpnul
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | find-contact-by-email.c | 2 | ||||
-rw-r--r-- | find-contact-by-name.c | 2 | ||||
-rw-r--r-- | find-contact-by-pgpkey.c | 2 | ||||
-rw-r--r-- | find-contact-by-site.c | 2 | ||||
-rw-r--r-- | get-contact-emails.c | 4 | ||||
-rw-r--r-- | get-contact-organisations.c | 4 | ||||
-rw-r--r-- | get-contact-pgpkeys.c | 4 | ||||
-rw-r--r-- | get-contact-sites.c | 4 | ||||
-rw-r--r-- | set-contact-emails.c | 12 | ||||
-rw-r--r-- | set-contact-organisations.c | 13 | ||||
-rw-r--r-- | set-contact-pgpkeys.c | 12 | ||||
-rw-r--r-- | set-contact-sites.c | 12 |
12 files changed, 36 insertions, 37 deletions
diff --git a/find-contact-by-email.c b/find-contact-by-email.c index cff71db..3880bb0 100644 --- a/find-contact-by-email.c +++ b/find-contact-by-email.c @@ -42,7 +42,7 @@ main(int argc, char *argv[]) for (; (email = *emails); emails++) { if (!email->address) continue; - if (context && (!email->context || strcmp(email->context, context))) + if (context && strcmpnul(email->context, context)) continue; if (list) printf("%s (%s)\n", contacts[i]->id, email->address); diff --git a/find-contact-by-name.c b/find-contact-by-name.c index d99f0a8..4b4b8c1 100644 --- a/find-contact-by-name.c +++ b/find-contact-by-name.c @@ -59,7 +59,7 @@ main(int argc, char *argv[]) if (list) { if (name) printf("%s (%s)\n", contacts[i]->id, name); - } else if (name && !strcmp(name, argv[0])) { + } else if (!strcmpnul(name, argv[0])) { printf("%s\n", contacts[i]->id); } libcontacts_contact_destroy(contacts[i]); diff --git a/find-contact-by-pgpkey.c b/find-contact-by-pgpkey.c index 85d2202..94c312f 100644 --- a/find-contact-by-pgpkey.c +++ b/find-contact-by-pgpkey.c @@ -42,7 +42,7 @@ main(int argc, char *argv[]) for (; (pgpkey = *pgpkeys); pgpkeys++) { if (!pgpkey->id) continue; - if (context && (!pgpkey->context || strcmp(pgpkey->context, context))) + if (context && strcmpnul(pgpkey->context, context)) continue; if (list) printf("%s (%s)\n", contacts[i]->id, pgpkey->id); diff --git a/find-contact-by-site.c b/find-contact-by-site.c index afda922..7c21777 100644 --- a/find-contact-by-site.c +++ b/find-contact-by-site.c @@ -42,7 +42,7 @@ main(int argc, char *argv[]) for (; (site = *sites); sites++) { if (!site->address) continue; - if (context && (!site->context || strcmp(site->context, context))) + if (context && strcmpnul(site->context, context)) continue; if (list) printf("%s (%s)\n", contacts[i]->id, site->address); diff --git a/get-contact-emails.c b/get-contact-emails.c index 433cf22..891c873 100644 --- a/get-contact-emails.c +++ b/get-contact-emails.c @@ -59,9 +59,9 @@ main(int argc, char *argv[]) ret = 1; } else { for (emails = contact.emails; (email = *emails); emails++) { - if (lookup_ctx && (!email->context || strcmp(email->context, lookup_ctx))) + if (lookup_ctx && strcmpnul(email->context, lookup_ctx)) continue; - if (lookup_addr && (!email->address || strcmp(email->address, lookup_addr))) + if (lookup_addr && strcmpnul(email->address, lookup_addr)) continue; if (lookup_ctx && lookup_addr && !display_ctx && !display_addr) { printf("%s\n", *argv); diff --git a/get-contact-organisations.c b/get-contact-organisations.c index c16b333..3441f55 100644 --- a/get-contact-organisations.c +++ b/get-contact-organisations.c @@ -59,9 +59,9 @@ main(int argc, char *argv[]) ret = 1; } else { for (orgs = contact.organisations; (org = *orgs); orgs++) { - if (lookup_org && (!org->organisation || strcmp(org->organisation, lookup_org))) + if (lookup_org && strcmpnul(org->organisation, lookup_org)) continue; - if (lookup_title && (!org->title || strcmp(org->title, lookup_title))) + if (lookup_title && strcmpnul(org->title, lookup_title)) continue; if (lookup_org && lookup_title && !display_org && !display_title) { printf("%s\n", *argv); diff --git a/get-contact-pgpkeys.c b/get-contact-pgpkeys.c index 9a1250a..ad56cc2 100644 --- a/get-contact-pgpkeys.c +++ b/get-contact-pgpkeys.c @@ -59,9 +59,9 @@ main(int argc, char *argv[]) ret = 1; } else { for (keys = contact.pgpkeys; (key = *keys); keys++) { - if (lookup_ctx && (!key->context || strcmp(key->context, lookup_ctx))) + if (lookup_ctx && strcmpnul(key->context, lookup_ctx)) continue; - if (lookup_id && (!key->id || strcmp(key->id, lookup_id))) + if (lookup_id && strcmpnul(key->id, lookup_id)) continue; if (lookup_ctx && lookup_id && !display_ctx && !display_id) { printf("%s\n", *argv); diff --git a/get-contact-sites.c b/get-contact-sites.c index 6627cc3..7208d9f 100644 --- a/get-contact-sites.c +++ b/get-contact-sites.c @@ -59,9 +59,9 @@ main(int argc, char *argv[]) ret = 1; } else { for (sites = contact.sites; (site = *sites); sites++) { - if (lookup_ctx && (!site->context || strcmp(site->context, lookup_ctx))) + if (lookup_ctx && strcmpnul(site->context, lookup_ctx)) continue; - if (lookup_addr && (!site->address || strcmp(site->address, lookup_addr))) + if (lookup_addr && strcmpnul(site->address, lookup_addr)) continue; if (lookup_ctx && lookup_addr && !display_ctx && !display_addr) { printf("%s\n", *argv); diff --git a/set-contact-emails.c b/set-contact-emails.c index 5911484..d015533 100644 --- a/set-contact-emails.c +++ b/set-contact-emails.c @@ -53,7 +53,7 @@ main(int argc, char *argv[]) for (; contact.emails[i]; i++); } else if (update_address) { for (; contact.emails[i]; i++) { - if (contact.emails[i]->context && !strcmp(contact.emails[i]->context, argv[1])) { + if (!strcmpnul(contact.emails[i]->context, argv[1])) { free(contact.emails[i]->address); contact.emails[i]->address = estrdup(argv[2]); goto save; @@ -61,7 +61,7 @@ main(int argc, char *argv[]) } } else if (update_context) { for (; contact.emails[i]; i++) { - if (contact.emails[i]->address && !strcmp(contact.emails[i]->address, argv[2])) { + if (!strcmpnul(contact.emails[i]->address, argv[2])) { free(contact.emails[i]->context); contact.emails[i]->context = estrdup(argv[1]); goto save; @@ -69,16 +69,16 @@ main(int argc, char *argv[]) } } else if (argc == 3) { for (; contact.emails[i]; i++) - if (contact.emails[i]->context && !strcmp(contact.emails[i]->context, argv[1])) - if (contact.emails[i]->address && !strcmp(contact.emails[i]->address, argv[2])) + if (!strcmpnul(contact.emails[i]->context, argv[1])) + if (!strcmpnul(contact.emails[i]->address, argv[2])) break; } else if (remove_by_context) { for (; contact.emails[i]; i++) - if (contact.emails[i]->context && !strcmp(contact.emails[i]->context, argv[1])) + if (!strcmpnul(contact.emails[i]->context, argv[1])) break; } else { for (; contact.emails[i]; i++) - if (contact.emails[i]->address && !strcmp(contact.emails[i]->address, argv[1])) + if (!strcmpnul(contact.emails[i]->address, argv[1])) break; } } diff --git a/set-contact-organisations.c b/set-contact-organisations.c index 17db004..d1fbeaf 100644 --- a/set-contact-organisations.c +++ b/set-contact-organisations.c @@ -53,8 +53,7 @@ main(int argc, char *argv[]) for (; contact.organisations[i]; i++); } else if (update_title) { for (; contact.organisations[i]; i++) { - if (contact.organisations[i]->organisation && - !strcmp(contact.organisations[i]->organisation, argv[1])) { + if (!strcmpnul(contact.organisations[i]->organisation, argv[1])) { free(contact.organisations[i]->title); contact.organisations[i]->title = estrdup(argv[2]); goto save; @@ -62,7 +61,7 @@ main(int argc, char *argv[]) } } else if (update_organisation) { for (; contact.organisations[i]; i++) { - if (contact.organisations[i]->title && !strcmp(contact.organisations[i]->title, argv[2])) { + if (!strcmpnul(contact.organisations[i]->title, argv[2])) { free(contact.organisations[i]->organisation); contact.organisations[i]->organisation = estrdup(argv[1]); goto save; @@ -70,16 +69,16 @@ main(int argc, char *argv[]) } } else if (argc == 3) { for (; contact.organisations[i]; i++) - if (contact.organisations[i]->organisation && !strcmp(contact.organisations[i]->organisation, argv[1])) - if (contact.organisations[i]->title && !strcmp(contact.organisations[i]->title, argv[2])) + if (!strcmpnul(contact.organisations[i]->organisation, argv[1])) + if (!strcmpnul(contact.organisations[i]->title, argv[2])) break; } else if (remove_by_organisation) { for (; contact.organisations[i]; i++) - if (contact.organisations[i]->organisation && !strcmp(contact.organisations[i]->organisation, argv[1])) + if (!strcmpnul(contact.organisations[i]->organisation, argv[1])) break; } else { for (; contact.organisations[i]; i++) - if (contact.organisations[i]->title && !strcmp(contact.organisations[i]->title, argv[1])) + if (!strcmpnul(contact.organisations[i]->title, argv[1])) break; } } diff --git a/set-contact-pgpkeys.c b/set-contact-pgpkeys.c index b5bebfb..adb62d3 100644 --- a/set-contact-pgpkeys.c +++ b/set-contact-pgpkeys.c @@ -53,7 +53,7 @@ main(int argc, char *argv[]) for (; contact.pgpkeys[i]; i++); } else if (update_id) { for (; contact.pgpkeys[i]; i++) { - if (contact.pgpkeys[i]->context && !strcmp(contact.pgpkeys[i]->context, argv[1])) { + if (!strcmpnul(contact.pgpkeys[i]->context, argv[1])) { free(contact.pgpkeys[i]->id); contact.pgpkeys[i]->id = estrdup(argv[2]); goto save; @@ -61,7 +61,7 @@ main(int argc, char *argv[]) } } else if (update_context) { for (; contact.pgpkeys[i]; i++) { - if (contact.pgpkeys[i]->id && !strcmp(contact.pgpkeys[i]->id, argv[2])) { + if (!strcmpnul(contact.pgpkeys[i]->id, argv[2])) { free(contact.pgpkeys[i]->context); contact.pgpkeys[i]->context = estrdup(argv[1]); goto save; @@ -69,16 +69,16 @@ main(int argc, char *argv[]) } } else if (argc == 3) { for (; contact.pgpkeys[i]; i++) - if (contact.pgpkeys[i]->context && !strcmp(contact.pgpkeys[i]->context, argv[1])) - if (contact.pgpkeys[i]->id && !strcmp(contact.pgpkeys[i]->id, argv[2])) + if (!strcmpnul(contact.pgpkeys[i]->context, argv[1])) + if (!strcmpnul(contact.pgpkeys[i]->id, argv[2])) break; } else if (remove_by_context) { for (; contact.pgpkeys[i]; i++) - if (contact.pgpkeys[i]->context && !strcmp(contact.pgpkeys[i]->context, argv[1])) + if (!strcmpnul(contact.pgpkeys[i]->context, argv[1])) break; } else { for (; contact.pgpkeys[i]; i++) - if (contact.pgpkeys[i]->id && !strcmp(contact.pgpkeys[i]->id, argv[1])) + if (!strcmpnul(contact.pgpkeys[i]->id, argv[1])) break; } } diff --git a/set-contact-sites.c b/set-contact-sites.c index e826f73..56a31ea 100644 --- a/set-contact-sites.c +++ b/set-contact-sites.c @@ -53,7 +53,7 @@ main(int argc, char *argv[]) for (; contact.sites[i]; i++); } else if (update_address) { for (; contact.sites[i]; i++) { - if (contact.sites[i]->context && !strcmp(contact.sites[i]->context, argv[1])) { + if (!strcmpnul(contact.sites[i]->context, argv[1])) { free(contact.sites[i]->address); contact.sites[i]->address = estrdup(argv[2]); goto save; @@ -61,7 +61,7 @@ main(int argc, char *argv[]) } } else if (update_context) { for (; contact.sites[i]; i++) { - if (contact.sites[i]->address && !strcmp(contact.sites[i]->address, argv[2])) { + if (!strcmpnul(contact.sites[i]->address, argv[2])) { free(contact.sites[i]->context); contact.sites[i]->context = estrdup(argv[1]); goto save; @@ -69,16 +69,16 @@ main(int argc, char *argv[]) } } else if (argc == 3) { for (; contact.sites[i]; i++) - if (contact.sites[i]->context && !strcmp(contact.sites[i]->context, argv[1])) - if (contact.sites[i]->address && !strcmp(contact.sites[i]->address, argv[2])) + if (!strcmpnul(contact.sites[i]->context, argv[1])) + if (!strcmpnul(contact.sites[i]->address, argv[2])) break; } else if (remove_by_context) { for (; contact.sites[i]; i++) - if (contact.sites[i]->context && !strcmp(contact.sites[i]->context, argv[1])) + if (!strcmpnul(contact.sites[i]->context, argv[1])) break; } else { for (; contact.sites[i]; i++) - if (contact.sites[i]->address && !strcmp(contact.sites[i]->address, argv[1])) + if (!strcmpnul(contact.sites[i]->address, argv[1])) break; } } |