tstopwatch.c: store program name globally - stopwatch - simple timer for console or x root window
(HTM) git clone git://src.adamsgaard.dk/stopwatch
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4f6e38d9d743040a27ac5fdc0f49dbe5d53ec2af
(DIR) parent 1e0f2abc8c9a86278d85ddc424d639343c0359dc
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 5 Nov 2020 08:57:59 +0100
stopwatch.c: store program name globally
Diffstat:
M stopwatch.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/stopwatch.c b/stopwatch.c
t@@ -9,8 +9,10 @@
#include "timeutil.h"
+char *argv0;
+
void
-usage(char *argv0)
+usage()
{
errx(1, "usage: %s [-p prefix] [-P postfix] [-i interval] [-x]", argv0);
}
t@@ -55,6 +57,8 @@ main(int argc, char *argv[])
char prefix[LINE_MAX] = "", postfix[LINE_MAX] = "";
const char *errstr;
+ argv0 = *argv;
+
while ((ch = getopt(argc, argv, "p:P:i:x")) != -1) {
switch (ch) {
case 'p':
t@@ -72,13 +76,13 @@ main(int argc, char *argv[])
xflag = 1;
break;
default:
- usage(argv[0]);
+ usage();
}
}
argc -= optind;
argv += optind;
if (argc > 0)
- usage(argv[0]);
+ usage();
if (xflag)
xroot_loop(interval, prefix, postfix);