[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 15/39: [gxditview]: Support -version, --version option.
From: |
G. Branden Robinson |
Subject: |
[groff] 15/39: [gxditview]: Support -version, --version option. |
Date: |
Sun, 9 Oct 2022 23:53:37 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit c73decb58f1fbc3d6d2ba0c2f613b821c21ae658
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 9 04:06:31 2022 -0500
[gxditview]: Support -version, --version option.
[gxditview]: Support `-version`, `--version` option. As a C program,
gxditview had no access to the (C++) libgroff `Version_string` symbol,
so construct a header file to store this datum at build time. If groff
gets other user-facing C programs, we should consider generating this
header in src/include instead.
* src/devices/xditview/xditview.am: Generate "groff_version.h" file.
(GXDITVIEW_GROFF_VERSION_H): Define new macro.
($(GXDITVIEW_GROFF_VERSION_H)): Define target to generate file.
(XDITVIEW_GENHDRS): Add $(GXDITVIEW_GROFF_VERSION_H).
* src/devices/xditview/xditview.c: Include new header file.
(Syntax): Report newly supported options.
(main): Recognize and handle new options.
* src/devices/xditview/gxditview.1.man (Synopsis): Document them.
---
ChangeLog | 22 ++++++++++++++++++++++
src/devices/xditview/gxditview.1.man | 30 +++++++++++++++++++++++-------
src/devices/xditview/xditview.am | 11 ++++++++++-
src/devices/xditview/xditview.c | 9 +++++++++
4 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 760ee92c2..f318c1d9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2022-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [gxditview]: Support `-version`, `--version` option. As a C
+ program, gxditview had no access to the (C++) libgroff
+ `Version_string` symbol, so construct a header file to store
+ this datum at build time. If groff gets other user-facing C
+ programs, we should consider generating this header in
+ src/include instead.
+
+ * src/devices/xditview/xditview.am: Generate "groff_version.h"
+ file.
+ (GXDITVIEW_GROFF_VERSION_H): Define new macro.
+ ($(GXDITVIEW_GROFF_VERSION_H)): Define target to generate file.
+ (XDITVIEW_GENHDRS): Add $(GXDITVIEW_GROFF_VERSION_H).
+
+ * src/devices/xditview/xditview.c: Include new header file.
+ (Syntax): Report newly supported options.
+ (main): Recognize and handle new options.
+
+ * src/devices/xditview/gxditview.1.man (Synopsis): Document
+ them.
+
2022-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
[gxditview]: Update usage message production and contents.
diff --git a/src/devices/xditview/gxditview.1.man
b/src/devices/xditview/gxditview.1.man
index 5dc547d26..944bfdbac 100644
--- a/src/devices/xditview/gxditview.1.man
+++ b/src/devices/xditview/gxditview.1.man
@@ -63,6 +63,14 @@ gxditview \- display groff intermediate output files in X11
.YS
.
.
+.SY gxditview
+.B \-version
+.
+.SY gxditview
+.B \-\-version
+.YS
+.
+.
.\" ====================================================================
.SH Description
.\" ====================================================================
@@ -412,23 +420,31 @@ SS \-adobe\-symbol\-medium\-r\-normal\-\-*\-100\" break
.EE
.
.
-.if t .ne 4v \" force section heading to the next page for groff 1.23.0
+.br
+.ne 3v
.\" ====================================================================
.SH Options
.\" ====================================================================
.
+.B \-help
+and
+.B \-\-help
+display a usage message,
+while
+.B \-version
+and
+.B \-\-version
+show version information;
+all exit afterward.
+.
+.
+.P
.I gxditview
accepts all of the standard X\~Toolkit command-line options along with
the additional options listed below.
.
.
.TP
-.B \-help
-This option indicates that a brief summary of the allowed options should
-be printed.
-.
-.
-.TP
.B \-page
This option specifies the page number of the document to be displayed.
.
diff --git a/src/devices/xditview/xditview.am b/src/devices/xditview/xditview.am
index 38e3d3568..da4a7cac7 100644
--- a/src/devices/xditview/xditview.am
+++ b/src/devices/xditview/xditview.am
@@ -34,6 +34,13 @@ GXDITVIEWSOURCES = \
src/devices/xditview/Menu.h \
src/devices/xditview/Dvi.h
+GXDITVIEW_GROFF_VERSION_H=src/devices/xditview/groff_version.h
+
+$(GXDITVIEW_GROFF_VERSION_H): $(top_srcdir)/.version
+ $(AM_V_at)$(MKDIR_P) `dirname $@` \
+ && $(AM_V_GEN)printf \
+ 'const char *Version_string = "%s";\n' $(GROFF_VERSION) > $@
+
if WITHOUT_X11
GXDITVIEW_MAN1 =
EXTRA_DIST += $(GXDITVIEWSOURCES)
@@ -45,7 +52,9 @@ gxditview_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) -Dlint \
-I$(top_builddir)/src/devices/xditview
gxditview_LDADD = $(X_LIBS) $(X_PRE_LIBS) -lXaw -lXmu -lXt -lX11 \
$(X_EXTRA_LIBS) $(LIBM) libxutil.a lib/libgnu.a
-XDITVIEW_GENHDRS = src/devices/xditview/GXditview-ad.h
+XDITVIEW_GENHDRS = \
+ src/devices/xditview/GXditview-ad.h \
+ $(GXDITVIEW_GROFF_VERSION_H)
gxditview_SOURCES = $(GXDITVIEWSOURCES)
nodist_gxditview_SOURCES = $(XDITVIEW_GENHDRS)
CLEANFILES += $(XDITVIEW_GENHDRS)
diff --git a/src/devices/xditview/xditview.c b/src/devices/xditview/xditview.c
index e5b0e4f17..1f7931d8d 100644
--- a/src/devices/xditview/xditview.c
+++ b/src/devices/xditview/xditview.c
@@ -56,6 +56,7 @@ static char rcsid[] = "$XConsortium: xditview.c,v 1.17
89/12/10 17:05:08 rws Exp
#include <stdio.h>
#include "Dvi.h"
+#include "groff_version.h"
#include "xdit.bm"
#include "xdit_mask.bm"
@@ -136,6 +137,8 @@ Syntax(const char *progname, bool had_error)
" [file]\n", progname);
(void) fprintf (stream, "usage: %s {-help | --help}\n",
progname);
+ (void) fprintf (stream, "usage: %s {-version | --version}\n",
+ progname);
if (had_error)
exit(EXIT_FAILURE);
else
@@ -222,6 +225,12 @@ int main(int argc, char **argv)
if ((strcmp(argv[1], "-help") == 0)
|| (strcmp(argv[1], "--help") == 0))
Syntax(argv[0], false /* did not have error */);
+ else if ((strcmp(argv[1], "-version") == 0)
+ || (strcmp(argv[1], "--version") == 0)) {
+ (void) printf("GNU gxditview (groff) version %s\n",
+ Version_string);
+ exit(EXIT_SUCCESS);
+ }
}
XtGetApplicationResources(toplevel, (XtPointer)&app_resources,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 15/39: [gxditview]: Support -version, --version option.,
G. Branden Robinson <=