[hackers] [scroll] Add version option || Steve Ward
commit 117d7db63f8b0c6fb4c00f1003d2577538a9f517
Author: Steve Ward <planet36_AT_gmail.com>
AuthorDate: Fri May 1 21:40:49 2020 -0400
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Sun May 3 21:55:27 2020 +0200
Add version option
diff --git a/config.mk b/config.mk
index 622cbdb..5676b85 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -6,7 +6,7 @@ PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
-CPPFLAGS = -D_DEFAULT_SOURCE
+CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE
# if your system is not POSIX, add -std=c99 to CFLAGS
CFLAGS = -Os
LDFLAGS = -s
diff --git a/scroll.c b/scroll.c
index 25c5d1a..86241b8 100644
--- a/scroll.c
+++ b/scroll.c
_AT_@ -47,6 +47,8 @@
#define LENGTH(X) (sizeof (X) / sizeof ((X)[0]))
+const char *argv0;
+
TAILQ_HEAD(tailhead, line) head;
struct line {
_AT_@ -402,7 +404,7 @@ jumpdown(char *buf, size_t size)
void
usage(void) {
- die("usage: scroll [-Mh] [-m mem] [program]");
+ die("usage: %s [-Mvh] [-m mem] [program]", argv0);
}
int
_AT_@ -411,10 +413,13 @@ main(int argc, char *argv[])
int ch;
struct rlimit rlimit;
+ argv0 = argv[0];
+
if (getrlimit(RLIMIT_DATA, &rlimit) == -1)
die("getrlimit");
- while ((ch = getopt(argc, argv, "Mm:h")) != -1) {
+ const char *optstring = "Mm:vh";
+ while ((ch = getopt(argc, argv, optstring)) != -1) {
switch (ch) {
case 'M':
rlimit.rlim_cur = rlimit.rlim_max;
_AT_@ -424,6 +429,9 @@ main(int argc, char *argv[])
if (errno != 0)
die("strtoull: %s", optarg);
break;
+ case 'v':
+ die("%s " VERSION, argv0);
+ break;
case 'h':
default:
usage();
Received on Sun May 03 2020 - 21:56:27 CEST
This archive was generated by hypermail 2.3.0
: Sun May 03 2020 - 22:00:38 CEST