Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: make error message for missing comman...
details: https://anonhg.NetBSD.org/src/rev/de18f135f7c7
branches: trunk
changeset: 1026476:de18f135f7c7
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Nov 25 21:48:23 2021 +0000
description:
indent: make error message for missing command line arguments clearer
diffstat:
tests/usr.bin/indent/t_errors.sh | 9 ++++-----
usr.bin/indent/args.c | 14 +++++++-------
2 files changed, 11 insertions(+), 12 deletions(-)
diffs (86 lines):
diff -r f37faccf8296 -r de18f135f7c7 tests/usr.bin/indent/t_errors.sh
--- a/tests/usr.bin/indent/t_errors.sh Thu Nov 25 21:45:28 2021 +0000
+++ b/tests/usr.bin/indent/t_errors.sh Thu Nov 25 21:48:23 2021 +0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: t_errors.sh,v 1.21 2021/11/25 21:45:28 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.22 2021/11/25 21:48:23 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -182,17 +182,16 @@
atf_test_case 'option_special_missing_param'
option_special_missing_param_body()
{
- # TODO: Write '-cli' instead of only 'cli'.
expect_error \
- 'indent: Command line: ``cli'\'\'' requires an argument' \
+ 'indent: Command line: ``-cli'\'\'' requires an argument' \
-cli
expect_error \
- 'indent: Command line: ``T'\'\'' requires an argument' \
+ 'indent: Command line: ``-T'\'\'' requires an argument' \
-T
expect_error \
- 'indent: Command line: ``U'\'\'' requires an argument' \
+ 'indent: Command line: ``-U'\'\'' requires an argument' \
-U
}
diff -r f37faccf8296 -r de18f135f7c7 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Thu Nov 25 21:45:28 2021 +0000
+++ b/usr.bin/indent/args.c Thu Nov 25 21:48:23 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.71 2021/11/19 20:23:17 rillig Exp $ */
+/* $NetBSD: args.c,v 1.72 2021/11/25 21:48:23 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.71 2021/11/19 20:23:17 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.72 2021/11/25 21:48:23 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -162,7 +162,7 @@
if (strncmp(arg, "cli", 3) == 0) {
arg_end = arg + 3;
if (arg_end[0] == '\0')
- goto need_param;
+ goto need_arg;
char *end;
opt.case_indent = (float)strtod(arg_end, &end);
if (*end != '\0')
@@ -182,7 +182,7 @@
if (arg[0] == 'T') {
arg_end = arg + 1;
if (arg_end[0] == '\0')
- goto need_param;
+ goto need_arg;
register_typename(arg_end);
return true;
}
@@ -190,15 +190,15 @@
if (arg[0] == 'U') {
arg_end = arg + 1;
if (arg_end[0] == '\0')
- goto need_param;
+ goto need_arg;
add_typedefs_from_file(arg_end);
return true;
}
return false;
-need_param:
- errx(1, "%s: ``%.*s'' requires an argument",
+need_arg:
+ errx(1, "%s: ``-%.*s'' requires an argument",
option_source, (int)(arg_end - arg), arg);
/* NOTREACHED */
}
Home |
Main Index |
Thread Index |
Old Index