diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2026-07-17 00:49:55 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2026-07-17 01:40:03 +0000 |
| commit | 77a201b1705dbd97ea9ebe5b25b1d4ddac8a7d38 (patch) | |
| tree | 212cccda8d1a53c819e55543783d8228db59b387 | |
| parent | 56ac3351c61f285ee5b8c9bd4411eeaeb20efe26 (diff) | |
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.
| -rw-r--r-- | usr.bin/ministat/ministat.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/ministat/ministat.c b/usr.bin/ministat/ministat.c index 7d3232370121..bb2b7e32ea0b 100644 --- a/usr.bin/ministat/ministat.c +++ b/usr.bin/ministat/ministat.c @@ -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); } |
