summaryrefslogtreecommitdiffstats
path: root/save-git.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-08-17 12:26:21 -0600
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-12 07:45:37 -0400
commitdf4e26c8757a81bb40ba2fd60431d5d1ecd64b11 (patch)
treea7f46fb0a25a5131a42727ab0ca770f2fc0c8f30 /save-git.c
parentb47e0658cf5e60e18d4c9405e3b28f196ac3e2d8 (diff)
downloadsubsurface-df4e26c8757a81bb40ba2fd60431d5d1ecd64b11.tar.gz
Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and add the (currently unused) ability to specify a gas change to a particular cylinder rather than (or in addition to) the gasmix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-git.c')
-rw-r--r--save-git.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/save-git.c b/save-git.c
index a1ef022fb..308a02c83 100644
--- a/save-git.c
+++ b/save-git.c
@@ -119,6 +119,18 @@ static void save_tags(struct membuffer *b, struct tag_entry *tags)
put_string(b, "\n");
}
+static void put_gasmix(struct membuffer *b, struct gasmix *mix)
+{
+ int o2 = mix->o2.permille;
+ int he = mix->he.permille;
+
+ if (o2) {
+ put_format(b, " o2=%u.%u%%", FRACTION(o2, 10));
+ if (he)
+ put_format(b, " he=%u.%u%%", FRACTION(he, 10));
+ }
+}
+
static void save_cylinder_info(struct membuffer *b, struct dive *dive)
{
int i, nr;
@@ -128,8 +140,6 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
cylinder_t *cylinder = dive->cylinder + i;
int volume = cylinder->type.size.mliter;
const char *description = cylinder->type.description;
- int o2 = cylinder->gasmix.o2.permille;
- int he = cylinder->gasmix.he.permille;
put_string(b, "cylinder");
if (volume)
@@ -137,11 +147,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
put_pressure(b, cylinder->type.workingpressure, " workpressure=", "bar");
show_utf8(b, " description=", description, "");
strip_mb(b);
- if (o2) {
- put_format(b, " o2=%u.%u%%", FRACTION(o2, 10));
- if (he)
- put_format(b, " he=%u.%u%%", FRACTION(he, 10));
- }
+ put_gasmix(b, &cylinder->gasmix);
put_pressure(b, cylinder->start, " start=", "bar");
put_pressure(b, cylinder->end, " end=", "bar");
put_string(b, "\n");
@@ -292,6 +298,13 @@ static void save_one_event(struct membuffer *b, struct event *ev)
show_index(b, ev->flags, "flags=", "");
show_index(b, ev->value, "value=", "");
show_utf8(b, " name=", ev->name, "");
+ if (event_is_gaschange(ev)) {
+ if (ev->gas.index >= 0) {
+ show_index(b, ev->gas.index, "cylinder=", "");
+ put_gasmix(b, &ev->gas.mix);
+ } else if (!event_gasmix_redundant(ev))
+ put_gasmix(b, &ev->gas.mix);
+ }
put_string(b, "\n");
}