aboutsummaryrefslogtreecommitdiffstats
path: root/set-contact-organisations.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-03 10:31:02 +0200
committerMattias Andrée <maandree@kth.se>2021-04-03 10:31:02 +0200
commitc3cac7a521857747771f661d607004f58470e0cc (patch)
tree91a9058a1000a121a7c89dd7869c866b4d63ca80 /set-contact-organisations.c
parentFirst commmit (diff)
downloadcontacts-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--set-contact-organisations.c13
1 files changed, 6 insertions, 7 deletions
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;
}
}