core: replace dive master by dive guide

In general, replace "dive master" by "dive guide".

However, do not change written dive logs for now. On reading,
accept both versions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-02-12 14:03:18 +01:00 committed by Dirk Hohndel
parent 889827aadb
commit 9e0712d5dc
38 changed files with 141 additions and 133 deletions

View file

@ -224,7 +224,7 @@ static void free_dive_structures(struct dive *d)
fulltext_unregister(d);
/* free the strings */
free(d->buddy);
free(d->divemaster);
free(d->diveguide);
free(d->notes);
free(d->suit);
/* free tags, additional dive computers, and pictures */
@ -272,7 +272,7 @@ static void copy_dive_nodc(const struct dive *s, struct dive *d)
d->full_text = NULL;
invalidate_dive_cache(d);
d->buddy = copy_string(s->buddy);
d->divemaster = copy_string(s->divemaster);
d->diveguide = copy_string(s->diveguide);
d->notes = copy_string(s->notes);
d->suit = copy_string(s->suit);
copy_cylinders(&s->cylinders, &d->cylinders);
@ -319,7 +319,7 @@ void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_compo
if (clear)
clear_dive(d);
CONDITIONAL_COPY_STRING(notes);
CONDITIONAL_COPY_STRING(divemaster);
CONDITIONAL_COPY_STRING(diveguide);
CONDITIONAL_COPY_STRING(buddy);
CONDITIONAL_COPY_STRING(suit);
if (what.rating)
@ -2616,7 +2616,7 @@ struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset,
*trip = get_preferred_trip(a, b);
MERGE_TXT(res, a, b, notes, "\n--\n");
MERGE_TXT(res, a, b, buddy, ", ");
MERGE_TXT(res, a, b, divemaster, ", ");
MERGE_TXT(res, a, b, diveguide, ", ");
MERGE_MAX(res, a, b, rating);
MERGE_TXT(res, a, b, suit, ", ");
MERGE_MAX(res, a, b, number);

View file

@ -32,7 +32,7 @@ struct dive {
timestamp_t when;
struct dive_site *dive_site;
char *notes;
char *divemaster, *buddy;
char *diveguide, *buddy;
struct cylinder_table cylinders;
struct weightsystem_table weightsystems;
char *suit;
@ -78,7 +78,7 @@ extern int same_gasmix_cylinder(const cylinder_t *cyl, int cylid, const struct d
struct dive_components {
unsigned int divesite : 1;
unsigned int notes : 1;
unsigned int divemaster : 1;
unsigned int diveguide : 1;
unsigned int buddy : 1;
unsigned int suit : 1;
unsigned int rating : 1;

View file

@ -848,7 +848,7 @@ static bool has_people(const filter_constraint &c, const struct dive *d)
QStringList dive_people;
for (const QString &s: QString(d->buddy).split(",", SKIP_EMPTY))
dive_people.push_back(s.trimmed());
for (const QString &s: QString(d->divemaster).split(",", SKIP_EMPTY))
for (const QString &s: QString(d->diveguide).split(",", SKIP_EMPTY))
dive_people.push_back(s.trimmed());
return check(c, dive_people);
}

View file

@ -120,7 +120,7 @@ static std::vector<QString> getWords(const dive *d)
{
std::vector<QString> res;
tokenize(QString(d->notes), res);
tokenize(QString(d->divemaster), res);
tokenize(QString(d->diveguide), res);
tokenize(QString(d->buddy), res);
tokenize(QString(d->suit), res);
for (const tag_entry *tag = d->tag_list; tag; tag = tag->next)

View file

@ -296,7 +296,7 @@ static int divinglog_dive(void *param, int columns, char **data, char **column)
state->cur_dive->dc.duration.seconds = atoi(data[6]) * 60;
if (data[7])
utf8_string(data[7], &state->cur_dive->divemaster);
utf8_string(data[7], &state->cur_dive->diveguide);
if (data[8])
state->cur_dive->airtemp.mkelvin = C_to_mkelvin(atol(data[8]));

View file

@ -214,8 +214,8 @@ static void parse_dive_location(char *line, struct membuffer *str, struct git_pa
free(name);
}
static void parse_dive_divemaster(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->divemaster = detach_cstring(str); }
static void parse_dive_diveguide(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->diveguide = detach_cstring(str); }
static void parse_dive_buddy(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->buddy = detach_cstring(str); }
@ -1113,8 +1113,9 @@ static void divecomputer_parser(char *line, struct membuffer *str, struct git_pa
struct keyword_action dive_action[] = {
#undef D
#define D(x) { #x, parse_dive_ ## x }
D(airpressure), D(airtemp), D(buddy), D(chill), D(current), D(cylinder), D(divemaster), D(divesiteid), D(duration),
D(gps), D(invalid), D(location), D(notes), D(notrip), D(rating), D(suit), D(surge),
/* For historical reasons, we accept divemaster and diveguide */
D(airpressure), D(airtemp), D(buddy), D(chill), D(current), D(cylinder), D(diveguide), { "divemaster", parse_dive_diveguide },
D(divesiteid), D(duration), D(gps), D(invalid), D(location), D(notes), D(notrip), D(rating), D(suit), D(surge),
D(tags), D(visibility), D(watersalinity), D(watertemp), D(wavesize), D(weightsystem)
};

View file

@ -1322,7 +1322,10 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str
return;
if (MATCH("notes", utf8_string, &dive->notes))
return;
if (MATCH("divemaster", utf8_string, &dive->divemaster))
// For historic reasons, we accept dive guide as well as dive master
if (MATCH("diveguide", utf8_string, &dive->diveguide))
return;
if (MATCH("divemaster", utf8_string, &dive->diveguide))
return;
if (MATCH("buddy", utf8_string, &dive->buddy))
return;

View file

@ -97,7 +97,7 @@ static void show_utf8(struct membuffer *b, const char *prefix, const char *value
static void save_overview(struct membuffer *b, struct dive *dive)
{
show_utf8(b, "divemaster ", dive->divemaster, "\n");
show_utf8(b, "divemaster ", dive->diveguide, "\n");
show_utf8(b, "buddy ", dive->buddy, "\n");
show_utf8(b, "suit ", dive->suit, "\n");
show_utf8(b, "notes ", dive->notes, "\n");

View file

@ -370,7 +370,7 @@ static void write_one_dive(struct membuffer *b, struct dive *dive, const char *p
put_HTML_watertemp(b, dive, "\"water\":\"", "\"");
put_string(b, " },");
write_attribute(b, "buddy", dive->buddy, ", ");
write_attribute(b, "divemaster", dive->divemaster, ", ");
write_attribute(b, "divemaster", dive->diveguide, ", ");
write_attribute(b, "suit", dive->suit, ", ");
put_HTML_tags(b, dive, "\"tags\":", ",");
if (!list_only) {
@ -528,6 +528,7 @@ void export_translation(const char *file_name)
write_attribute(b, "Surge", translate("gettextFromC", "Surge"), ", ");
write_attribute(b, "Chill", translate("gettextFromC", "Chill"), ", ");
write_attribute(b, "Duration", translate("gettextFromC", "Duration"), ", ");
write_attribute(b, "DiveGuide", translate("gettextFromC", "Diveguide"), ", ");
write_attribute(b, "DiveMaster", translate("gettextFromC", "Divemaster"), ", ");
write_attribute(b, "Buddy", translate("gettextFromC", "Buddy"), ", ");
write_attribute(b, "Suit", translate("gettextFromC", "Suit"), ", ");

View file

@ -162,7 +162,7 @@ static void save_salinity(struct membuffer *b, struct divecomputer *dc)
static void save_overview(struct membuffer *b, struct dive *dive, bool anonymize)
{
show_utf8_blanked(b, dive->divemaster, " <divemaster>", "</divemaster>\n", 0, anonymize);
show_utf8_blanked(b, dive->diveguide, " <divemaster>", "</divemaster>\n", 0, anonymize);
show_utf8_blanked(b, dive->buddy, " <buddy>", "</buddy>\n", 0, anonymize);
show_utf8_blanked(b, dive->notes, " <notes>", "</notes>\n", 0, anonymize);
show_utf8_blanked(b, dive->suit, " <suit>", "</suit>\n", 0, anonymize);

View file

@ -25,7 +25,7 @@ struct DiveField {
unsigned int water_temp : 1;
unsigned int atm_press : 1;
unsigned int divesite : 1;
unsigned int divemaster : 1;
unsigned int diveguide : 1;
unsigned int buddy : 1;
unsigned int rating : 1;
unsigned int visibility : 1;
@ -49,7 +49,7 @@ struct DiveField {
WATER_TEMP = 1 << 5,
ATM_PRESS = 1 << 6,
DIVESITE = 1 << 7,
DIVEMASTER = 1 << 8,
DIVEGUIDE = 1 << 8,
BUDDY = 1 << 9,
RATING = 1 << 10,
VISIBILITY = 1 << 11,
@ -159,7 +159,7 @@ inline DiveField::DiveField(int flags) :
water_temp((flags & WATER_TEMP) != 0),
atm_press((flags & ATM_PRESS) != 0),
divesite((flags & DIVESITE) != 0),
divemaster((flags & DIVEMASTER) != 0),
diveguide((flags & DIVEGUIDE) != 0),
buddy((flags & BUDDY) != 0),
rating((flags & RATING) != 0),
visibility((flags & VISIBILITY) != 0),

View file

@ -860,7 +860,7 @@ static bool uemis_delete_dive(device_data_t *devdata, uint32_t diveid)
free(dive->dc.sample);
free((void *)dive->notes);
free((void *)dive->divemaster);
free((void *)dive->diveguide);
free((void *)dive->buddy);
free((void *)dive->suit);
taglist_free(dive->tag_list);