tFix error messages - filmtools - various tools for photographic film developme… | |
git clone git://src.adamsgaard.dk/filmtools | |
Log | |
Files | |
Refs | |
--- | |
commit e6b42a4b0787ef30e4da02a496b2ef6813868d75 | |
parent e3590cf9bd8a82c4b55415f2a7d55a7591c6f47e | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 16 Jul 2020 21:02:22 +0200 | |
Fix error messages | |
Diffstat: | |
M timeadj.c | 15 ++++++++------- | |
1 file changed, 8 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/timeadj.c b/timeadj.c | |
t@@ -3,13 +3,13 @@ | |
#include <err.h> | |
#include <math.h> | |
-#define PROGNAME "timadj" | |
+char *argv0; | |
void | |
usage() | |
{ | |
- printf("usage: %s FACTOR TIME\n", PROGNAME); | |
- puts("where TIME is in format HH:MM or MM:SS"); | |
+ printf("usage: %s factor time\n", argv0); | |
+ puts("where time is in format HH:MM or MM:SS"); | |
} | |
int | |
t@@ -17,21 +17,22 @@ main(int argc, char** argv) | |
{ | |
double factor; | |
int min, sec, sec_equiv; | |
+ argv0 = *argv; | |
#ifdef __OpenBSD__ | |
if (pledge("stdio", NULL) == -1) | |
err(1, "pledge"); | |
#endif | |
- if (argc < 3) { | |
+ if (argc != 3) { | |
usage(); | |
- err(1, NULL); | |
+ errx(1, "incorrect arguments"); | |
} | |
if (sscanf(argv[1], "%lg", &factor) != 1) | |
- err(2, "could not parse FACTOR"); | |
+ errx(2, "could not parse FACTOR"); | |
if (sscanf(argv[2], "%d:%d", &min, &sec) != 2) | |
- err(2, "could not parse TIME in HH:MM or MM:SS format"); | |
+ errx(2, "could not parse TIME in HH:MM or MM:SS format"); | |
sec_equiv = min*60 + sec; | |