logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 5d44cf475cc204a07d67a4f400b46f2f04603940
parent 090b88be1892ca08ade620a7bd0c8ba4f5ac427b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 20 Sep 2024 04:24:28 +0200

cmd/test: unify error message formatting

Diffstat:

Mcmd/test.c18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/cmd/test.c b/cmd/test.c @@ -198,7 +198,7 @@ main(int argc, char **argv) p++; if(strcmp(p, "[") == 0) { - if(strcmp(argv[--argc], "]") != 0) error("missing ]"); + if(strcmp(argv[--argc], "]") != 0) error("error: missing ]"); argv[argc] = NULL; } @@ -229,9 +229,9 @@ syntax(const char *op, const char *msg) { if(op && *op) - error("%s: %s", op, msg); + error("error: %s: %s", op, msg); else - error("%s", msg); + error("error: %s", msg); } static int @@ -514,14 +514,14 @@ getn(const char *s) errno = 0; r = strtol(s, &p, 10); - if(s == p) error("%s: bad number", s); + if(s == p) error("error: %s: bad number", s); - if(errno != 0) error((errno == EINVAL) ? "%s: bad number" : "%s: out of range", s); + if(errno != 0) error((errno == EINVAL) ? "error: %s: bad number" : "error: %s: out of range", s); while(isspace((unsigned char)*p)) p++; - if(*p) error("%s: bad number", s); + if(*p) error("error: %s: bad number", s); return (int)r; } @@ -536,14 +536,14 @@ getq(const char *s) errno = 0; r = strtoimax(s, &p, 10); - if(s == p) error("%s: bad number", s); + if(s == p) error("error: %s: bad number", s); - if(errno != 0) error((errno == EINVAL) ? "%s: bad number" : "%s: out of range", s); + if(errno != 0) error((errno == EINVAL) ? "error: %s: bad number" : "error: %s: out of range", s); while(isspace((unsigned char)*p)) p++; - if(*p) error("%s: bad number", s); + if(*p) error("error: %s: bad number", s); return r; }