diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-03-22 17:13:46 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-03-23 05:43:52 -0700 |
commit | cb49c37b31fcebb3a1ba97b0a804d398ae0df22d (patch) | |
tree | 4f41d4b75bcfcb01bbed563240144ed0ca9d743e /file.c | |
parent | 384b9dd09b5190aedcd7428f0e997b3c07bffca6 (diff) | |
download | subsurface-cb49c37b31fcebb3a1ba97b0a804d398ae0df22d.tar.gz |
Fix Seabear new line detection
We need to take both \r\n and \n new line formats into account before
failing Seabear validity check on import. (Seabear file has empty lines,
if import file does not have one -> return.)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -930,7 +930,7 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp char curdate[DATESTR]; char curtime[TIMESTR]; char *ptr, *ptr_old = NULL; - char *NL; + char *NL = NULL; 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); @@ -951,13 +951,6 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp NL = "\r\n"; } - /* - * If file does not contain empty lines, it is not a valid - * Seabear CSV file. - */ - if (!ptr) - return -1; - if (!ptr_old) { while ((ptr = strstr(ptr, "\n\n")) != NULL) { ptr_old = ptr; @@ -969,6 +962,13 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp ptr_old += 4; /* + * If file does not contain empty lines, it is not a valid + * Seabear CSV file. + */ + if (NL == NULL) + return -1; + + /* * On my current sample of Seabear DC log file, the date is * without any identifier. Thus we must search for the previous * line and step through from there. |