Introduction
Introduction Statistics Contact Development Disclaimer Help
fix label length due to sizeof(ptr) misuse - ploot - simple plotting tools
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
README
LICENSE
---
commit 7dad2b0d2e8a560efbe5d38164a63f999b3a23f9
parent ca79681acc3c649b67abc21bc0aabe980d5c989c
Author: Josuah Demangeon <[email protected]>
Date: Sun, 23 Feb 2020 11:58:08 +0100
fix label length due to sizeof(ptr) misuse
Diffstat:
M src/csv.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/csv.c b/src/csv.c
@@ -69,7 +69,8 @@ csv_addrow(struct csv *vl, size_t ncol, char *line)
void
csv_labels(FILE *fp, struct csv **vl, size_t *ncol)
{
- char *field, *line, *cp, *label;
+ char *field, *line, *cp;
+ struct csv *col;
size_t sz;
ssize_t r;
@@ -79,6 +80,7 @@ csv_labels(FILE *fp, struct csv **vl, size_t *ncol)
fatal(111, "error while reading from file");
if (r == -1)
fatal(100, "missing label line");
+ strchomp(line);
cp = line;
if (strcmp(strsep(&cp, ","), "epoch") != 0)
@@ -88,8 +90,8 @@ csv_labels(FILE *fp, struct csv **vl, size_t *ncol)
*ncol = 0;
while ((field = strsep(&cp, ","))) {
assert(*vl = realloc(*vl, sz += sizeof(**vl)));
- label = (*vl)[(*ncol)++].label;
- strlcpy(label, field, sizeof(label));
+ col = (*vl) + (*ncol)++;
+ strlcpy(col->label, field, sizeof(col->label));
}
free(line);
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.