git: 77a201b1705d - main - ministat: parse comma used as decimal delimiter

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 17 Jul 2026 01:40:14 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=77a201b1705dbd97ea9ebe5b25b1d4ddac8a7d38

commit 77a201b1705dbd97ea9ebe5b25b1d4ddac8a7d38
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-07-17 00:49:55 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-07-17 01:40:03 +0000

    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.
---
 usr.bin/ministat/ministat.c | 8 +++++---
 1 file 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);
 	}