summaryrefslogtreecommitdiffstats
path: root/core/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-04 18:59:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-09 19:19:04 +0100
commit8df3705152aa32d8551b5fb7db08e0c8e442b480 (patch)
tree60879e7d4af85d71d64885ea903ac234a09bffda /core/parse-xml.c
parent7c9f46acd202121e67557bb634961ef17a9f6c1f (diff)
downloadsubsurface-8df3705152aa32d8551b5fb7db08e0c8e442b480.tar.gz
Cleanup: return cylinder from cylinder_start() in parser
Most callers of this function accessed the newly generated cylinder immediately after calling this function. Thus, for convenience, return the added cylinder. This avoids a number of verbose expressions. On the flip side, cylinder_start() now has to be cast to function returning void in a the "nesting" function table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r--core/parse-xml.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 02363bde6..0f297bf9a 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1560,13 +1560,14 @@ static void uddf_importer(struct parser_state *state)
state->xml_parsing_units.temperature = KELVIN;
}
+typedef void (*parser_func)(struct parser_state *);
/*
* I'm sure this could be done as some fancy DTD rules.
* It's just not worth the headache.
*/
static struct nesting {
const char *name;
- void (*start)(struct parser_state *), (*end)(struct parser_state *);
+ parser_func start, end;
} nesting[] = {
{ "divecomputerid", dc_settings_start, dc_settings_end },
{ "settings", settings_start, settings_end },
@@ -1579,9 +1580,9 @@ static struct nesting {
{ "SAMPLE", sample_start, sample_end },
{ "reading", sample_start, sample_end },
{ "event", event_start, event_end },
- { "mix", cylinder_start, cylinder_end },
- { "gasmix", cylinder_start, cylinder_end },
- { "cylinder", cylinder_start, cylinder_end },
+ { "mix", (parser_func)cylinder_start, (parser_func)cylinder_end },
+ { "gasmix", (parser_func)cylinder_start, (parser_func)cylinder_end },
+ { "cylinder", (parser_func)cylinder_start, (parser_func)cylinder_end },
{ "weightsystem", ws_start, ws_end },
{ "divecomputer", divecomputer_start, divecomputer_end },
{ "P", sample_start, sample_end },
@@ -1910,8 +1911,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *tabl
}
}
if (!found) {
- cylinder_start(&state);
- cylinder_t *cyl = &state.cur_dive->cylinders.cylinders[state.cur_dive->cylinders.nr - 1];
+ cyl = cylinder_start(&state);
cyl->gasmix.o2.permille = ptr[6] * 10;
cyl->gasmix.he.permille = ptr[7] * 10;
cylinder_end(&state);