Module Name:    src
Committed By:   rillig
Date:           Mon May 30 23:02:02 UTC 2022

Modified Files:
        src/usr.bin/xlint/xlint: lint.1 xlint.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/xlint/lint.1
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/xlint/xlint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/xlint/lint.1
diff -u src/usr.bin/xlint/xlint/lint.1:1.52 src/usr.bin/xlint/xlint/lint.1:1.53
--- src/usr.bin/xlint/xlint/lint.1:1.52	Fri Apr 15 23:25:04 2022
+++ src/usr.bin/xlint/xlint/lint.1	Mon May 30 23:02:02 2022
@@ -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 @@ The list of errors and warnings that
 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

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.92 src/usr.bin/xlint/xlint/xlint.c:1.93
--- src/usr.bin/xlint/xlint/xlint.c:1.92	Fri May 20 21:18:55 2022
+++ src/usr.bin/xlint/xlint/xlint.c	Mon May 30 23:02:02 2022
@@ -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 @@ usage(const char *fmt, ...)
 	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 @@ main(int argc, char *argv[])
 			break;
 
 		default:
-			usage("Unknown flag %c", c);
+			usage("");
 			/* NOTREACHED */
 		}
 	}
@@ -582,7 +583,7 @@ main(int argc, char *argv[])
 			else if (arg[1] == 'L')
 				list = &libsrchpath;
 			else {
-				usage("Unknown argument %s", arg);
+				usage("Unknown late option '%s'", arg);
 				/* NOTREACHED */
 			}
 

Reply via email to