load-git and event parsing
Robert Helling
helling at atdotde.de
Thu Feb 13 13:25:18 PST 2020
Hi,
there were complaints that bailout events get converted to generic events upon saving (to git) and I tracked this down to the following: The bailout event results in a line like
event 40:00 type=8 divemode="OC" name="modechange"
in the Divecomputer file in the repository.
When that is loaded, however, the parsing thinks „OC“ is the event->name and not „modechange“. Looking at the code in load-git.c, I am a bit lost with the clever combination of macros and jump tables in the parser. I see in parse_event_keyvalue()
if (!strcmp(key, "type")) {
event->type = val;
} else if (!strcmp(key, "flags")) {
event->flags = val;
} else if (!strcmp(key, "value")) {
event->value = val;
} else if (!strcmp(key, "name")) {
/* We get the name from the string handling */
} else if (!strcmp(key,"divemode")) {
So parsing the key is a NOP at this point. It seems to get parsed however in parse_dc_event() where the code reads
name = "";
if (str->len)
name = mb_cstring(str);
ev = add_event(state->active_dc, event.time.seconds, event.type, event.flags, event.value, name);
printf reveals that after these lines name is „OC“ and not „modechange“.
Maybe somebody with a better understanding of the code (Linus?) can help me out with this.
Thanks
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20200213/68239ab5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20200213/68239ab5/attachment.sig>
More information about the subsurface
mailing list