mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
ministat: parse comma used as decimal delimiter
This allows to use output of '/usr/bin/time -ao foo' as direct input to ministat(1). While here make diagnostic message more verbose.
This commit is contained in:
1 parent
56ac3351c6
commit
77a201b170
1 file changed
+5
-3
@@ -483,7 +483,7 @@ dbl_cmp(const void *a, const void *b)
|
||||
static struct dataset *
|
||||
ReadSet(FILE *f, const char *n, int column, const char *delim)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *t;
|
||||
char buf[BUFSIZ], *p, *t, *comma;
|
||||
struct dataset *s;
|
||||
double d;
|
||||
int line;
|
||||
@@ -507,10 +507,12 @@ ReadSet(FILE *f, const char *n, int column, const char *delim)
|
||||
}
|
||||
if (t == NULL || *t == '#')
|
||||
continue;
|
||||
|
||||
if ((comma = strchr(t, ',')) != NULL)
|
||||
*comma = '.';
|
||||
d = strtod(t, &p);
|
||||
if (p != NULL && *p != '\0')
|
||||
errx(2, "Invalid data on line %d in %s", line, n);
|
||||
errx(2, "Invalid data \"%s\" on line %d in %s",
|
||||
t, line, n);
|
||||
if (*buf != '\0')
|
||||
AddPoint(s, d);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user