[tz] Print zdump and zic program names in --version output
Paul Eggert
eggert at cs.ucla.edu
Sat Nov 10 02:17:00 UTC 2012
Here's an updated version of the proposed patch, which
outputs the version info as something like
"zic (tzcode) 2012i"; this follows the GNU coding
standards more carefully.
>From 89a60086d33916dc355325525b85381033b7e86e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Fri, 9 Nov 2012 18:12:22 -0800
Subject: [PATCH] Output version info in a more-typical format.
E.g., "zic (tzcode) 2012i" instead of "tzcode2012i".
Thread started by Joseph S. Myers in
<http://mm.icann.org/pipermail/tz/2012-November/018439.html>.
* Makefile (PACKAGE): New macro.
(version.h, tzselect): New constant PKGVERSION, derived from PACKAGE.
(tzselect): TZVERSION is now simply VERSION, since PACKAGE is also
output.
* tzselect.ksh (PKGVERSION): New var, which Makefile substitutes for.
(--usage, --version): Exit with nonzero status if we can't
output the help or version number.
* tzselect.ksh (--version):
* zdump.c, zic.c (main):
Output versions like this: "zdump (tzcode) 2012i".
---
Makefile | 10 +++++++---
tzselect.ksh | 7 ++++---
zdump.c | 2 +-
zic.c | 2 +-
4 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index ea081a3..5a17164 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,9 @@
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
+# Package name for the code distribution.
+PACKAGE= tzcode
+
# Version numbers of the code and data distributions.
VERSION= 2012i
@@ -340,8 +343,8 @@ INSTALL: ALL install date.1
cp date.1 $(MANDIR)/man1/.
version.h:
- echo >$@ \
- 'static char const TZVERSION[]="tz$(VERSION)";'
+ (echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
+ echo 'static char const TZVERSION[]="$(VERSION)";') >$@
zdump: $(TZDOBJS)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
@@ -392,8 +395,9 @@ tzselect: tzselect.ksh
sed \
-e 's|#!/bin/bash|#!$(KSHELL)|g' \
-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
+ -e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
- -e 's|\(TZVERSION\)=.*|\1=tz$(VERSION)|' \
+ -e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \
<$? >$@
chmod +x $@
diff --git a/tzselect.ksh b/tzselect.ksh
index 279bdf2..51bafc1 100644
--- a/tzselect.ksh
+++ b/tzselect.ksh
@@ -1,5 +1,6 @@
#!/bin/bash
+PKGVERSION='(tzcode) '
TZVERSION=see_Makefile
# Ask the user about the time zone, and output the resulting TZ value to stdout.
@@ -45,12 +46,12 @@ Select a time zone interactively.
Report bugs to tz at iana.org.
EOF
- exit 0
+ exit
elif [ "$1" = "--version" ]; then
cat <<EOF
-tzselect $TZVERSION
+tzselect $PKGVERSION$TZVERSION
EOF
- exit 0
+ exit
fi
# Make sure the tables are readable.
diff --git a/zdump.c b/zdump.c
index bdbd1d6..626b09d 100644
--- a/zdump.c
+++ b/zdump.c
@@ -309,7 +309,7 @@ main(int argc, char *argv[])
progname = argv[0];
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", TZVERSION);
+ (void) printf("zdump %s%s\n", PKGVERSION, TZVERSION);
exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
diff --git a/zic.c b/zic.c
index 35c8d4b..1964a89 100644
--- a/zic.c
+++ b/zic.c
@@ -462,7 +462,7 @@ main(int argc, char **argv)
}
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", TZVERSION);
+ (void) printf("zic %s%s\n", PKGVERSION, TZVERSION);
exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
--
1.7.9.5
More information about the tz
mailing list