Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/xlint lint: clean up usage messages



details:   https://anonhg.NetBSD.org/src/rev/e95a33b0fadd
branches:  trunk
changeset: 366568:e95a33b0fadd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon May 30 23:02:02 2022 +0000

description:
lint: clean up usage messages

The two synopsis forms differed in the spelling of 'file ...'.

The options string for getopt does not start with ':', which led to a
duplicate message 'unknown option -- ?' followed by 'Unknown flag ?'.

Be more specific when calling 'lint file.c -u'; the message 'Unknown
argument' was not helpful as it didn't pinpoint that there are two
different phases for parsing options.  In the second phase, only the
options '-L' and '-l' are recognized.

In the manual page, mention the difference between the two synopsis
forms as early as possible.  The two synopsis forms are very similar and
both have far to many options to see the difference at a glance.

diffstat:

 usr.bin/xlint/xlint/lint.1  |  12 ++++++++++--
 usr.bin/xlint/xlint/xlint.c |  13 +++++++------
 2 files changed, 17 insertions(+), 8 deletions(-)

diffs (87 lines):

diff -r 20c1a031fc1c -r e95a33b0fadd usr.bin/xlint/xlint/lint.1
--- a/usr.bin/xlint/xlint/lint.1        Mon May 30 21:42:02 2022 +0000
+++ b/usr.bin/xlint/xlint/lint.1        Mon May 30 23:02:02 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: lint.1,v 1.52 2022/04/15 23:25:04 rillig Exp $
+.\" $NetBSD: lint.1,v 1.53 2022/05/30 23:02:02 rillig Exp $
 .\"
 .\" Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
 .\" Copyright (c) 1994, 1995 Jochen Pohl
@@ -30,7 +30,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 15, 2022
+.Dd May 31, 2022
 .Dt LINT 1
 .Os
 .Sh NAME
@@ -80,6 +80,14 @@
 produces are enumerated in
 .Xr lint 7 .
 .Pp
+In the first synopsis form,
+.Nm
+checks each given file as a separate translation unit.
+In the second synopsis form,
+.Nm
+cross-checks the results of the first synopsis form for inconsistencies
+between translation units.
+.Pp
 .Nm
 runs the C preprocessor as its first phase, with the
 following preprocessor symbols
diff -r 20c1a031fc1c -r e95a33b0fadd usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c       Mon May 30 21:42:02 2022 +0000
+++ b/usr.bin/xlint/xlint/xlint.c       Mon May 30 23:02:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.92 2022/05/20 21:18:55 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.93 2022/05/30 23:02:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: xlint.c,v 1.92 2022/05/20 21:18:55 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.93 2022/05/30 23:02:02 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -322,14 +322,15 @@
        va_start(ap, fmt);
        vfprintf(stderr, fmt, ap);
        va_end(ap);
-       fprintf(stderr, "\n");
+       if (fmt[0] != '\0')
+               fprintf(stderr, "\n");
 
        indent = (int)(strlen("usage: ") + strlen(name));
        (void)fprintf(stderr,
            "usage: %s [-abceghprvwxzHFST] [-s|-t] [-i|-nu]\n"
            "%*s [-Dname[=def]] [-Uname] [-Idirectory] [-Z <cpparg>]\n"
            "%*s [-Ldirectory] [-llibrary] [-ooutputfile]\n"
-           "%*s [-X <id>[,<id>]...] [-Ac11] file...\n",
+           "%*s [-X <id>[,<id>]...] [-Ac11] file ...\n",
            name, indent, "", indent, "", indent, "");
        (void)fprintf(stderr,
            "       %s [-abceghprvwzHFST] [-s|-t] -Clibrary\n"
@@ -556,7 +557,7 @@
                        break;
 
                default:
-                       usage("Unknown flag %c", c);
+                       usage("");
                        /* NOTREACHED */
                }
        }
@@ -582,7 +583,7 @@
                        else if (arg[1] == 'L')
                                list = &libsrchpath;
                        else {
-                               usage("Unknown argument %s", arg);
+                               usage("Unknown late option '%s'", arg);
                                /* NOTREACHED */
                        }
 



Home | Main Index | Thread Index | Old Index