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 <[email protected]> --- file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/file.c b/file.c index cbe38eb..eacd875 100644 --- a/file.c +++ b/file.c @@ -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); -- 1.9.1 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
