diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | dive.h | 5 | ||||
-rw-r--r-- | packaging/macosx/README | 19 | ||||
-rw-r--r-- | parse-xml.c | 35 |
4 files changed, 49 insertions, 11 deletions
@@ -104,6 +104,7 @@ else ifeq ($(UNAME), darwin) MACOSXFILES = packaging/macosx EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) + LDFLAGS += -headerpad_max_install_names else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTK2CFLAGS) @@ -156,6 +156,11 @@ static inline unsigned long F_to_mkelvin(double f) return (f-32) * 1000 / 1.8 + 273150.5; } +static inline unsigned long C_to_mkelvin(double c) +{ + return c * 1000 + 273150.5; +} + static inline int to_C(temperature_t temp) { if (!temp.mkelvin) diff --git a/packaging/macosx/README b/packaging/macosx/README index 88a383db9..a1a7cdad5 100644 --- a/packaging/macosx/README +++ b/packaging/macosx/README @@ -1,22 +1,27 @@ Creating a Subsurface bundle +============================ install gtk-mac-bundler (this has been tested with version 0.7.0) and run -gtk-mac-bundler subsurface.bundle + $ gtk-mac-bundler subsurface.bundle This should install a self-contained Subsurface application under /Applications/Subsurface.app You still need to manually build a DMG if you want to easily distribute this. -One important caveat is that (at least with MacPorts) you need to build pango like this: +Caveats +------- -sudo port install pango +builtin_modules +no_x11 +quartz +* You need (at least with MacPorts) to build pango like this: + + $ sudo port install pango +builtin_modules +no_x11 +quartz Without the builtin modules the installed application fails to find the modules and doesn't render any text. -Also, it seems that gtk-mac-bundler expects the charset.alias file to be -in the ${prefix}/lib folder which it isn't with the current version of -MacPorts. The following fixes that: +* It seems that gtk-mac-bundler expects the charset.alias file to be + in the ${prefix}/lib folder which it isn't with the current version of + MacPorts. The following fixes that: -sudo cp /usr/lib/charset.alias /opt/local/lib + $ sudo cp /usr/lib/charset.alias /opt/local/lib +* libdivecomputer needs to be configured with --with-prefix=/opt/local diff --git a/parse-xml.c b/parse-xml.c index d6197b57d..cb84cc26a 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -574,6 +574,14 @@ static int uemis_fill_sample(struct sample *sample, const char *name, int len, c * what Diving Log uses for "no temperature". * * So throw away crap like that. + * + * It gets worse. Sometimes the sample temperatures are in + * Celsius, which apparently happens if you are in a SI + * locale. So we now do: + * + * - temperatures < 32.0 == Celsius + * - temperature == 32.0 -> garbage, it's a missing temperature (zero converted from C to F) + * - temperatures > 32.0 == Fahrenheit */ static void fahrenheit(char *buffer, void *_temperature) { @@ -585,7 +593,10 @@ static void fahrenheit(char *buffer, void *_temperature) /* Floating point equality is evil, but works for small integers */ if (val.fp == 32.0) break; - temperature->mkelvin = (val.fp + 459.67) * 5000/9; + if (val.fp < 32.0) + temperature->mkelvin = C_to_mkelvin(val.fp); + else + temperature->mkelvin = F_to_mkelvin(val.fp); break; default: fprintf(stderr, "Crazy Diving Log temperature reading %s\n", buffer); @@ -602,15 +613,28 @@ static void fahrenheit(char *buffer, void *_temperature) * these inconvenient typed structures, and you have to say * "pressure->mbar" to get the actual value. Exactly so that * you can never have unit confusion. + * + * It gets worse: sometimes apparently the pressures are in + * bar, sometimes in psi. Dirk suspects that this may be a + * DivingLog Uemis importer bug, and that they are always + * supposed to be in bar, but that the importer got the + * sample importing wrong. + * + * Sadly, there's no way to really tell. So I think we just + * have to have some arbitrary cut-off point where we assume + * that smaller values mean bar.. Not good. */ -static void psi(char *buffer, void *_pressure) +static void psi_or_bar(char *buffer, void *_pressure) { pressure_t *pressure = _pressure; union int_or_float val; switch (integer_or_float(buffer, &val)) { case FLOAT: - pressure->mbar = val.fp * 68.95 + 0.5; + if (val.fp > 400) + pressure->mbar = psi_to_mbar(val.fp); + else + pressure->mbar = val.fp * 1000 + 0.5; break; default: fprintf(stderr, "Crazy Diving Log PSI reading %s\n", buffer); @@ -623,7 +647,7 @@ static int divinglog_fill_sample(struct sample *sample, const char *name, int le return MATCH(".p.time", sampletime, &sample->time) || MATCH(".p.depth", depth, &sample->depth) || MATCH(".p.temp", fahrenheit, &sample->temperature) || - MATCH(".p.press1", psi, &sample->cylinderpressure) || + MATCH(".p.press1", psi_or_bar, &sample->cylinderpressure) || 0; } @@ -741,8 +765,11 @@ static int divinglog_dive_match(struct dive **divep, const char *name, int len, return MATCH(".divedate", divedate, &dive->when) || MATCH(".entrytime", divetime, &dive->when) || MATCH(".depth", depth, &dive->maxdepth) || + MATCH(".tanktype", utf8_string, &dive->cylinder[0].type.description) || MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) || MATCH(".presw", pressure, &dive->cylinder[0].type.workingpressure) || + MATCH(".press", pressure, &dive->cylinder[0].start) || + MATCH(".prese", pressure, &dive->cylinder[0].end) || MATCH(".comments", utf8_string, &dive->notes) || MATCH(".buddy.names", utf8_string, &dive->buddy) || MATCH(".country.name", utf8_string, &country) || |