diff options
author | Salvador Cuñat <salvador.cunat@gmail.com> | 2019-07-25 21:28:57 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2019-08-02 08:58:35 +0200 |
commit | 218567bb86f485c9ff7b851e2d9034cf6c4968ba (patch) | |
tree | 6767ae7bd2d4527b213b280d68f7396895b0a027 /smtk-import | |
parent | 6e4c3ce6d8c1024adadab5d1915df49e6199f821 (diff) | |
download | subsurface-218567bb86f485c9ff7b851e2d9034cf6c4968ba.tar.gz |
fix site/location build issue
We were assuming these tables were sorted with their indexes, but it
happens to be false, under some circustances at least.
Reported-by: Andreas Hagberg <scubasoft@gmail.com>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Diffstat (limited to 'smtk-import')
-rw-r--r-- | smtk-import/smartrak.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index 1787d3fb7..4ed87a646 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -334,8 +334,9 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, struct dive_site **lo if (!table) return; - for (i = 1; i <= atoi(idx); i++) + do { mdb_fetch_row(table); + } while (strcasecmp(col[0]->bind_ptr, idx)); loc_idx = copy_string(col[2]->bind_ptr); site = copy_string(col[1]->bind_ptr); loc = create_location(strtod(col[6]->bind_ptr, NULL), strtod(col[7]->bind_ptr, NULL)); @@ -360,8 +361,10 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, struct dive_site **lo /* Read data from Location table, linked to Site by loc_idx */ table = smtk_open_table(mdb, "Location", col, bound_values); mdb_rewind_table(table); - for (i = 1; i <= atoi(loc_idx); i++) + do { mdb_fetch_row(table); + } while (strcasecmp(col[0]->bind_ptr, loc_idx)); + /* * Create a string for Subsurface's dive site structure with coordinates * if available, if the site's name doesn't previously exists. |