summaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2020-02-14 12:08:43 -0800
committerGravatar Robert C. Helling <helling@atdotde.de>2020-02-15 10:12:35 +0100
commit66a2b2e133608fdb8635560c64bbf6121662872e (patch)
tree8b59a37c89d7b7d751fc91487e3cbfb5182ec380 /core/load-git.c
parenta9112e6e054d08a2a2af9eba167c3fdefb3f12c4 (diff)
downloadsubsurface-66a2b2e133608fdb8635560c64bbf6121662872e.tar.gz
load-git: fix up any corrupted modechange event names
Because of the multiple string confusion, we'd get the names wrong for modechange events. If we then made other changes to the dive and saved the end result back, they'd now be wrong in the git cloud storage too. Fix it up manually by just noticing that there's a 'divemode' string on the event line, which can only happen with modechange events. Maybe we should report the fixup? This just silently fixes it (but only for the git save format). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/load-git.c b/core/load-git.c
index 5fe51af96..9d36e4e39 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -761,6 +761,7 @@ static int get_divemode(const char *divemodestring) {
struct parse_event {
const char *name;
struct event ev;
+ int has_divemode;
};
static void parse_event_keyvalue(void *_parse, const char *key, const char *value)
@@ -778,6 +779,7 @@ static void parse_event_keyvalue(void *_parse, const char *key, const char *valu
parse->name = value;
} else if (!strcmp(key,"divemode")) {
parse->ev.value = get_divemode(value);
+ parse->has_divemode = 1;
} else if (!strcmp(key, "cylinder")) {
/* NOTE! We add one here as a marker that "yes, we got a cylinder index" */
parse->ev.gas.index = 1 + get_index(value);
@@ -834,6 +836,10 @@ static void parse_dc_event(char *line, struct membuffer *str, struct git_parser_
line = parse_keyvalue_entry(parse_event_keyvalue, &p, line, str);
}
+ /* Only modechange events should have a divemode - fix up any corrupted names */
+ if (p.has_divemode && strcmp(p.name, "modechange"))
+ p.name = "modechange";
+
ev = add_event(state->active_dc, p.ev.time.seconds, p.ev.type, p.ev.flags, p.ev.value, p.name);
/*