mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:03:23 +00:00
Merging dives: Improve merging of divemaster, buddy and notes
Change the merging behavior for the following information: Divemaster, buddy, suit: From "(a) or (b)" to "a, b" Notes: From "(a) or (b)" to "a\n--\nb" Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
parent
b7806d1b94
commit
a95cc2b1c5
1 changed files with 7 additions and 7 deletions
14
core/dive.c
14
core/dive.c
|
@ -1716,7 +1716,7 @@ struct dive *fixup_dive(struct dive *dive)
|
||||||
/* Don't pick a zero for MERGE_MIN() */
|
/* Don't pick a zero for MERGE_MIN() */
|
||||||
#define MERGE_MAX(res, a, b, n) res->n = MAX(a->n, b->n)
|
#define MERGE_MAX(res, a, b, n) res->n = MAX(a->n, b->n)
|
||||||
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? MIN(a->n, b->n) : (a->n) : (b->n)
|
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? MIN(a->n, b->n) : (a->n) : (b->n)
|
||||||
#define MERGE_TXT(res, a, b, n) res->n = merge_text(a->n, b->n)
|
#define MERGE_TXT(res, a, b, n, sep) res->n = merge_text(a->n, b->n, sep)
|
||||||
#define MERGE_NONZERO(res, a, b, n) res->n = a->n ? a->n : b->n
|
#define MERGE_NONZERO(res, a, b, n) res->n = a->n ? a->n : b->n
|
||||||
|
|
||||||
struct sample *add_sample(struct sample *sample, int time, struct divecomputer *dc)
|
struct sample *add_sample(struct sample *sample, int time, struct divecomputer *dc)
|
||||||
|
@ -1862,7 +1862,7 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *merge_text(const char *a, const char *b)
|
static char *merge_text(const char *a, const char *b, const char *sep)
|
||||||
{
|
{
|
||||||
char *res;
|
char *res;
|
||||||
if (!a && !b)
|
if (!a && !b)
|
||||||
|
@ -1876,7 +1876,7 @@ static char *merge_text(const char *a, const char *b)
|
||||||
res = malloc(strlen(a) + strlen(b) + 32);
|
res = malloc(strlen(a) + strlen(b) + 32);
|
||||||
if (!res)
|
if (!res)
|
||||||
return (char *)a;
|
return (char *)a;
|
||||||
sprintf(res, translate("gettextFromC", "(%s) or (%s)"), a, b);
|
sprintf(res, "%s%s%s", a, sep, b);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3268,11 +3268,11 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
|
||||||
res->when = dl ? dl->when : a->when;
|
res->when = dl ? dl->when : a->when;
|
||||||
res->selected = a->selected || b->selected;
|
res->selected = a->selected || b->selected;
|
||||||
merge_trip(res, a, b);
|
merge_trip(res, a, b);
|
||||||
MERGE_TXT(res, a, b, notes);
|
MERGE_TXT(res, a, b, notes, "\n--\n");
|
||||||
MERGE_TXT(res, a, b, buddy);
|
MERGE_TXT(res, a, b, buddy, ", ");
|
||||||
MERGE_TXT(res, a, b, divemaster);
|
MERGE_TXT(res, a, b, divemaster, ", ");
|
||||||
MERGE_MAX(res, a, b, rating);
|
MERGE_MAX(res, a, b, rating);
|
||||||
MERGE_TXT(res, a, b, suit);
|
MERGE_TXT(res, a, b, suit, ", ");
|
||||||
MERGE_MAX(res, a, b, number);
|
MERGE_MAX(res, a, b, number);
|
||||||
MERGE_NONZERO(res, a, b, cns);
|
MERGE_NONZERO(res, a, b, cns);
|
||||||
MERGE_NONZERO(res, a, b, visibility);
|
MERGE_NONZERO(res, a, b, visibility);
|
||||||
|
|
Loading…
Add table
Reference in a new issue