summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-01-07 11:12:48 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-01-11 06:07:13 +0100
commite85ecdd9254a8bd222ccb2dfed7d3b3bb96c8294 (patch)
tree0483cdb3c5770ca75eeeb0cc2de787b0e7bdbd3c /core/dive.c
parent86ef9fce7517313570838ca8e853132876035611 (diff)
downloadsubsurface-e85ecdd9254a8bd222ccb2dfed7d3b3bb96c8294.tar.gz
Introduce helper function empty_string()
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/dive.c b/core/dive.c
index 1d2168206..84acecb38 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1190,7 +1190,7 @@ static struct event *find_previous_event(struct divecomputer *dc, struct event *
struct event *ev = dc->events;
struct event *previous = NULL;
- if (same_string(event->name, ""))
+ if (empty_string(event->name))
return NULL;
while (ev && ev != event) {
if (same_string(ev->name, event->name))
@@ -2954,7 +2954,7 @@ void taglist_cleanup(struct tag_entry **tag_list)
struct tag_entry **tl = tag_list;
while (*tl) {
/* skip tags that are empty or that we have seen before */
- if (same_string((*tl)->tag->name, "") || tag_seen_before(*tag_list, *tl)) {
+ if (empty_string((*tl)->tag->name) || tag_seen_before(*tag_list, *tl)) {
*tl = (*tl)->next;
continue;
}
@@ -3128,7 +3128,7 @@ int count_dives_with_tag(const char *tag)
struct dive *d;
for_each_dive (i, d) {
- if (same_string(tag, "")) {
+ if (empty_string(tag)) {
// count dives with no tags
if (d->tag_list == NULL)
counter++;
@@ -3148,9 +3148,9 @@ int count_dives_with_person(const char *person)
struct dive *d;
for_each_dive (i, d) {
- if (same_string(person, "")) {
+ if (empty_string(person)) {
// solo dive
- if (same_string(d->buddy, "") && same_string(d->divemaster, ""))
+ if (empty_string(d->buddy) && empty_string(d->divemaster))
counter++;
} else if (string_sequence_contains(d->buddy, person) || string_sequence_contains(d->divemaster, person)) {
counter++;