summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-22 06:54:03 +1200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-22 06:54:03 +1200
commitcbab6cc9c80cb51bd11043d0ab210a0d2b4744f6 (patch)
treedbbafa55fcf9a3919340734004270d3cfa693af0 /file.c
parentfd33e7013581aa2bbfebfce23e32c0181e07f049 (diff)
downloadsubsurface-cbab6cc9c80cb51bd11043d0ab210a0d2b4744f6.tar.gz
When importing dives from CSV, mark them accordingly
The dive computer model string should indicate that these were imported from CSV. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/file.c b/file.c
index 60de64d2c..cbe38ebae 100644
--- a/file.c
+++ b/file.c
@@ -864,6 +864,7 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
struct tm *timep = NULL;
char curdate[DATESTR];
char curtime[TIMESTR];
+ int previous;
if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f >= MAXCOLS || cnsf >= MAXCOLS || ndlf >= MAXCOLS || cnsf >= MAXCOLS || stopdepthf >= MAXCOLS || pressuref >= MAXCOLS)
return report_error(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
@@ -877,7 +878,14 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
if (try_to_xslt_open_csv(filename, &mem, csvtemplate))
return -1;
+ previous = dive_table.nr;
ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params);
+
+ // mark imported dives as imported from CSV
+ for (int i = previous; i < dive_table.nr; i++)
+ if (same_string(get_dive(i)->dc.model, ""))
+ get_dive(i)->dc.model = copy_string("Imported from CSV");
+
free(mem.buffer);
return ret;
}