summaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-18 23:42:17 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-24 09:51:37 -0700
commit8c65558b5c432c1d0e9c6af5939faa56ffecf51a (patch)
treeb7ded4867685f70849d687d465c1653d3955b499 /core/load-git.c
parent255f561afffb26bae5c4de0c5fe2d60effb41103 (diff)
downloadsubsurface-8c65558b5c432c1d0e9c6af5939faa56ffecf51a.tar.gz
devices: create device nodes in parsers
So far, we added a non-global device table to the parser states. Now, create device nodes in that table instead of in the global table. Thus, on undo of dive-import, the new device nodes will be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/load-git.c b/core/load-git.c
index dc7a3e8dc..2f2da1efb 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -713,7 +713,12 @@ static void parse_dc_date(char *line, struct membuffer *str, struct git_parser_s
{ UNUSED(str); update_date(&state->active_dc->when, line); }
static void parse_dc_deviceid(char *line, struct membuffer *str, struct git_parser_state *state)
-{ UNUSED(str); set_dc_deviceid(state->active_dc, get_hex(line), &device_table); }
+{
+ UNUSED(str);
+ int id = get_hex(line);
+ set_dc_deviceid(state->active_dc, id, &device_table); // prefer already known serial/firmware over those from the loaded log
+ set_dc_deviceid(state->active_dc, id, state->devices);
+}
static void parse_dc_diveid(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->diveid = get_hex(line); }
@@ -984,9 +989,8 @@ static void parse_divecomputerid_keyvalue(void *_cid, const char *key, const cha
* it can have multiple strings (but see the tag parsing for another example of
* that) in addition to the non-string entries.
*/
-static void parse_settings_divecomputerid(char *line, struct membuffer *str, struct git_parser_state *_unused)
+static void parse_settings_divecomputerid(char *line, struct membuffer *str, struct git_parser_state *state)
{
- UNUSED(_unused);
struct divecomputerid id = { pop_cstring(str, line) };
/* Skip the '"' that stood for the model string */
@@ -1001,7 +1005,7 @@ static void parse_settings_divecomputerid(char *line, struct membuffer *str, str
break;
line = parse_keyvalue_entry(parse_divecomputerid_keyvalue, &id, line, str);
}
- create_device_node(&device_table, id.model, id.deviceid, id.serial, id.firmware, id.nickname);
+ create_device_node(state->devices, id.model, id.deviceid, id.serial, id.firmware, id.nickname);
}
static void parse_picture_filename(char *line, struct membuffer *str, struct git_parser_state *state)
@@ -1699,7 +1703,7 @@ static int parse_settings_entry(struct git_parser_state *state, const git_tree_e
git_blob *blob = git_tree_entry_blob(state->repo, entry);
if (!blob)
return report_error("Unable to read settings file");
- for_each_line(blob, settings_parser, NULL);
+ for_each_line(blob, settings_parser, state);
git_blob_free(blob);
return 0;
}