summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-04 15:19:28 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-04 15:27:09 -0800
commitb5d3476b0ba881699c604a3d97c5801b8bb99a08 (patch)
tree788be1551df2a7f26e2aa2e905994250e0d929af /file.c
parent5fc50b2aaba122bf0c7b4251565800aec7a1e4a1 (diff)
downloadsubsurface-b5d3476b0ba881699c604a3d97c5801b8bb99a08.tar.gz
Allow comma separated CSV files
The separator selector in the CSV import dialog was unused. This passes the value into the xslt and adds ',' as possible value. I'm sure this could be done much better (pass the actual character instead of the index), but I couldn't get that to work and this does seem to do the trick. Also added a test dive to test this feature. Fixes #321 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/file.c b/file.c
index 5f9b3d90a..aaf14f3d9 100644
--- a/file.c
+++ b/file.c
@@ -327,17 +327,18 @@ void parse_file(const char *filename, char **error)
#define MAXCOLDIGITS 3
#define MAXCOLS 100
-void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int stopdepthf, char **error)
+void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int stopdepthf, int sepidx, char **error)
{
struct memblock mem;
int pnr=0;
- char *params[17];
+ char *params[19];
char timebuf[MAXCOLDIGITS];
char depthbuf[MAXCOLDIGITS];
char tempbuf[MAXCOLDIGITS];
char po2buf[MAXCOLDIGITS];
char cnsbuf[MAXCOLDIGITS];
char stopdepthbuf[MAXCOLDIGITS];
+ char separator_index[MAXCOLDIGITS];
time_t now;
struct tm *timep;
char curdate[9];
@@ -356,6 +357,7 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int
snprintf(po2buf, MAXCOLDIGITS, "%d", po2f);
snprintf(cnsbuf, MAXCOLDIGITS, "%d", cnsf);
snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf);
+ snprintf(separator_index, MAXCOLDIGITS, "%d", sepidx);
time(&now);
timep = localtime(&now);
strftime(curdate, sizeof(curdate), "%Y%m%d", timep);
@@ -380,6 +382,8 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int
params[pnr++] = curdate;
params[pnr++] = "time";
params[pnr++] = curtime;
+ params[pnr++] = "separatorIndex";
+ params[pnr++] = separator_index;
params[pnr++] = NULL;
if (filename == NULL)