diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-01-24 17:03:11 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-24 14:49:45 -0800 |
commit | 29c6d03dfa1d8b5017e5d97006d258a73a0fd85e (patch) | |
tree | a95bda981441e3d93fd4ed40f2385b10c3c16e0a /file.c | |
parent | 6bb1fee9a61f412fd20fd8fabda249294bee10c7 (diff) | |
download | subsurface-29c6d03dfa1d8b5017e5d97006d258a73a0fd85e.tar.gz |
Fix a bug if CSV file does not have ending new line
Add a new line when importing a CSV file, so we get the last dive
imported as well (in case file ends without last new line).
See #814
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 | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -116,13 +116,13 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons * * Tag markers take: strlen("<></>") = 5 */ - buf = realloc(mem->buffer, mem->size + 6 + strlen(tag) * 2); + buf = realloc(mem->buffer, mem->size + 7 + strlen(tag) * 2); if (buf != NULL) { char *starttag = NULL; char *endtag = NULL; starttag = malloc(3 + strlen(tag)); - endtag = malloc(4 + strlen(tag)); + endtag = malloc(5 + strlen(tag)); if (starttag == NULL || endtag == NULL) { /* this is fairly silly - so the malloc fails, but we strdup the error? @@ -135,12 +135,12 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons } sprintf(starttag, "<%s>", tag); - sprintf(endtag, "</%s>", tag); + sprintf(endtag, "\n</%s>", tag); memmove(buf + 2 + strlen(tag), buf, mem->size); memcpy(buf, starttag, 2 + strlen(tag)); - memcpy(buf + mem->size + 2 + strlen(tag), endtag, 4 + strlen(tag)); - mem->size += (5 + 2 * strlen(tag)); + memcpy(buf + mem->size + 2 + strlen(tag), endtag, 5 + strlen(tag)); + mem->size += (6 + 2 * strlen(tag)); mem->buffer = buf; free(starttag); |