]> git.tdb.fi Git - ext/subsurface.git/blobdiff - parse.c
Fix stupid mis-initialization of current sample
[ext/subsurface.git] / parse.c
diff --git a/parse.c b/parse.c
index 7595ef529b1dde708bb55d845759512ff0a1b3da..43bf82d86a7885469c691a9100ad516ab996f3c0 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -104,14 +104,31 @@ static void record_dive(struct dive *dive)
        printf("Recording dive %d with %d samples\n", ++nr, dive->samples);
 }
 
+static void nonmatch(const char *type, const char *fullname, const char *name, int size, const char *buffer)
+{
+       printf("Unable to match %s '(%.*s)%s' (%.*s)\n", type,
+               (int) (name - fullname), fullname, name,
+               size, buffer);
+}
+
+static const char *last_part(const char *name)
+{
+       const char *p = strrchr(name, '.');
+       return p ? p+1 : name;
+}
+
 /* We're in samples - try to convert the random xml value to something useful */
 static void try_to_fill_sample(struct sample *sample, const char *name, int size, const char *buffer)
 {
+       const char *last = last_part(name);
+       nonmatch("sample", name, last, size, buffer);
 }
 
 /* We're in the top-level dive xml. Try to convert whatever value to a dive value */
 static void try_to_fill_dive(struct dive *dive, const char *name, int size, const char *buffer)
 {
+       const char *last = last_part(name);
+       nonmatch("dive", name, last, size, buffer);
 }
 
 /*
@@ -168,7 +185,7 @@ static void sample_start(void)
                if (!dive)
                        return;
        }
-       sample = dive->samples + nr;
+       sample = dive->sample + nr;
 }
 
 static void sample_end(void)