[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 13/39: [gxditview]: Update usage msg handling, contents.
From: |
G. Branden Robinson |
Subject: |
[groff] 13/39: [gxditview]: Update usage msg handling, contents. |
Date: |
Sun, 9 Oct 2022 23:53:37 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 58c63d83c6f3a5aa6373ba47ba9326234f1d1f23
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 9 02:23:36 2022 -0500
[gxditview]: Update usage msg handling, contents.
[gxditview]: Update usage message production and contents.
* src/devices/xditview/xditview.c: Use C99 Boolean type.
(Syntax): Accept additional Boolean argument indicating whether the
usage message is to be issued due to an error. Write message to
stderr if so, and stdout otherwise. Stop presuming length of output
line; guessing where to wrap is unreliable due variable terminal width
and length of argv[0]. Write one line per invocation mode of the
program. Stop duplicatively documenting standard X Toolkit options.
Document "-noPolyText" option. Exit with standard C library
`EXIT_FAILURE` status if there was an error, and `EXIT_SUCCESS`
otherwise.
(main): Refactor to prepare for `--version` support.
* src/devices/xditview/gxditview.1.man (Synopsis): Sync list of options
with usage message.
---
ChangeLog | 19 ++++++++++++++++++
src/devices/xditview/gxditview.1.man | 9 +++++----
src/devices/xditview/xditview.c | 38 ++++++++++++++++++++++++------------
3 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9a64d8e21..760ee92c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2022-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [gxditview]: Update usage message production and contents.
+
+ * src/devices/xditview/xditview.c: Use C99 Boolean type.
+ (Syntax): Accept additional Boolean argument indicating whether
+ the usage message is to be issued due to an error. Write
+ message to stderr if so, and stdout otherwise. Stop presuming
+ length of output line; guessing where to wrap is unreliable due
+ variable terminal width and length of argv[0]. Write one line
+ per invocation mode of the program. Stop duplicatively
+ documenting standard X Toolkit options. Document "-noPolyText"
+ option. Exit with standard C library `EXIT_FAILURE` status if
+ there was an error, and `EXIT_SUCCESS` otherwise.
+ (main): Refactor to prepare for `--version` support.
+
+ * src/devices/xditview/gxditview.1.man (Synopsis): Sync list of
+ options with usage message.
+
2022-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/utils/afmtodit/afmtodit.pl: Recognize "--version" as
diff --git a/src/devices/xditview/gxditview.1.man
b/src/devices/xditview/gxditview.1.man
index ebb9cd938..5dc547d26 100644
--- a/src/devices/xditview/gxditview.1.man
+++ b/src/devices/xditview/gxditview.1.man
@@ -43,13 +43,14 @@ gxditview \- display groff intermediate output files in X11
.RB [ \-backingStore\~\c
.IR backing-store-type ]
.RB [ \-filename\~\c
-.IR string ]
+.IR file ]
+.RB [ \-noPolyText ]
.RB [ \-page\~\c
-.IR n ]
+.IR page-number ]
.RB [ \-printCommand\~\c
-.IR string ]
+.IR command ]
.RB [ \-resolution\~\c
-.IR res ]
+.IR resolution ]
.I file
.YS
.
diff --git a/src/devices/xditview/xditview.c b/src/devices/xditview/xditview.c
index 3a993d89f..261696061 100644
--- a/src/devices/xditview/xditview.c
+++ b/src/devices/xditview/xditview.c
@@ -50,6 +50,7 @@ static char rcsid[] = "$XConsortium: xditview.c,v 1.17
89/12/10 17:05:08 rws Exp
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
@@ -120,15 +121,25 @@ static FILE *current_file;
*/
static void
-Syntax(const char *call)
+Syntax(const char *progname, bool had_error)
{
- (void) printf ("Usage: %s [-fg <color>] [-bg <color>]\n", call);
- (void) printf (" [-bd <color>] [-bw <pixels>] [-help]\n");
- (void) printf (" [-display displayname] [-geometry geom]\n");
- (void) printf (" [-page <page-number>] [-backing
<backing-store>]\n");
- (void) printf (" [-resolution <res>] [-print <command>]\n");
- (void) printf (" [-filename <file>] [filename]\n\n");
- exit(1);
+ FILE *stream = stdout;
+ if (had_error)
+ stream = stderr;
+ (void) fprintf (stream, "usage: %s [X-toolkit-option]"
+ " [-backingStore backing-store-type]"
+ " [-filename file]"
+ " [-noPolyText]"
+ " [-page page-number]"
+ " [-printCommand command]"
+ " [-resolution resolution]"
+ " [file]\n", progname);
+ (void) fprintf (stream, "usage: %s {-help | --help}\n",
+ progname);
+ if (had_error)
+ exit(EXIT_FAILURE);
+ else
+ exit(EXIT_SUCCESS);
}
static void NewFile (const char *);
@@ -205,10 +216,13 @@ int main(int argc, char **argv)
toplevel = XtAppInitialize(&xtcontext, "GXditview",
options, XtNumber (options),
&argc, argv, fallback_resources, NULL, 0);
- if (argc > 2
- || (argc == 2 && (!strcmp(argv[1], "-help")
- || !strcmp(argv[1], "--help"))))
- Syntax(argv[0]);
+ if (argc > 2)
+ Syntax(argv[0], true /* had error */);
+ else if (argc == 2) {
+ if ((strcmp(argv[1], "-help") == 0)
+ || (strcmp(argv[1], "--help") == 0))
+ Syntax(argv[0], false /* did not have error */);
+ }
XtGetApplicationResources(toplevel, (XtPointer)&app_resources,
resources, XtNumber(resources),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 13/39: [gxditview]: Update usage msg handling, contents.,
G. Branden Robinson <=