Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/cgram cgram: provide usage on incorrect invocation
details: https://anonhg.NetBSD.org/src/rev/0a316a47c93c
branches: trunk
changeset: 982755:0a316a47c93c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 25 20:19:19 2021 +0000
description:
cgram: provide usage on incorrect invocation
diffstat:
games/cgram/cgram.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diffs (43 lines):
diff -r 095861fbee5b -r 0a316a47c93c games/cgram/cgram.c
--- a/games/cgram/cgram.c Sun Apr 25 20:14:29 2021 +0000
+++ b/games/cgram/cgram.c Sun Apr 25 20:19:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgram.c,v 1.19 2021/04/25 20:14:29 rillig Exp $ */
+/* $NetBSD: cgram.c,v 1.20 2021/04/25 20:19:19 rillig Exp $ */
/*-
* Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.c,v 1.19 2021/04/25 20:14:29 rillig Exp $");
+__RCSID("$NetBSD: cgram.c,v 1.20 2021/04/25 20:19:19 rillig Exp $");
#endif
#include <assert.h>
@@ -594,11 +594,23 @@
stringarray_cleanup(&lines);
}
-////////////////////////////////////////////////////////////
+
+static void __dead
+usage(void)
+{
+
+ fprintf(stderr, "usage: %s [file]\n", getprogname());
+ exit(1);
+}
int
main(int argc, char *argv[])
{
+
+ setprogname(argv[0]);
+ if (argc != 1 && argc != 2)
+ usage();
+
init(argc > 1 ? argv[1] : NULL);
loop();
clean_up();
Home |
Main Index |
Thread Index |
Old Index