mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
smtk-import Fix wreck data import
It was assumed that every data field in a wreck table was filled or zeroed. This assumption is actually false, so this patch adds testing for the existence of strings before working with them. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
This commit is contained in:
parent
8c94fa2676
commit
4864ea56cb
1 changed files with 12 additions and 8 deletions
|
@ -266,24 +266,29 @@ static void smtk_wreck_site(MdbHandle *mdb, char *site_idx, struct dive_site *ds
|
||||||
/* Begin parsing. Write strings to notes only if available.*/
|
/* Begin parsing. Write strings to notes only if available.*/
|
||||||
while (mdb_fetch_row(table)) {
|
while (mdb_fetch_row(table)) {
|
||||||
if (!strcmp(col[1]->bind_ptr, site_idx)) {
|
if (!strcmp(col[1]->bind_ptr, site_idx)) {
|
||||||
tmp = copy_string(col[1]->bind_ptr);
|
|
||||||
notes = smtk_concat_str(notes, "\n", translate("gettextFromC", "Wreck Data"));
|
notes = smtk_concat_str(notes, "\n", translate("gettextFromC", "Wreck Data"));
|
||||||
for (i = 3; i < 16; i++) {
|
for (i = 3; i < 16; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
if (memcmp(col[i]->bind_ptr, "\0", 1))
|
tmp = copy_string(col[i]->bind_ptr);
|
||||||
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], strtok(copy_string(col[i]->bind_ptr), " "));
|
if (tmp)
|
||||||
|
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], strtok(tmp , " "));
|
||||||
|
free(tmp);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (strcmp(rindex(copy_string(col[i]->bind_ptr), ' '), "\0"))
|
tmp = copy_string(col[i]->bind_ptr);
|
||||||
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], rindex(col[i]->bind_ptr, ' '));
|
if (tmp)
|
||||||
|
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], rindex(tmp, ' '));
|
||||||
|
free(tmp);
|
||||||
break;
|
break;
|
||||||
case 6 ... 9:
|
case 6 ... 9:
|
||||||
case 14:
|
case 14:
|
||||||
case 15:
|
case 15:
|
||||||
if (memcmp(col[i]->bind_ptr, "\0", 1))
|
tmp = copy_string(col[i]->bind_ptr);
|
||||||
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], col[i]->bind_ptr);
|
if (tmp)
|
||||||
|
notes = smtk_concat_str(notes, "\n", "%s: %s", wreck_fields[i - 3], tmp);
|
||||||
|
free(tmp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
d = lrintl(strtold(col[i]->bind_ptr, NULL));
|
d = lrintl(strtold(col[i]->bind_ptr, NULL));
|
||||||
|
@ -300,7 +305,6 @@ static void smtk_wreck_site(MdbHandle *mdb, char *site_idx, struct dive_site *ds
|
||||||
smtk_free(bound_values, table->num_cols);
|
smtk_free(bound_values, table->num_cols);
|
||||||
mdb_free_tabledef(table);
|
mdb_free_tabledef(table);
|
||||||
free(notes);
|
free(notes);
|
||||||
free(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue