Module Name: src Committed By: rillig Date: Thu Nov 25 21:48:23 UTC 2021
Modified Files: src/tests/usr.bin/indent: t_errors.sh src/usr.bin/indent: args.c Log Message: indent: make error message for missing command line arguments clearer To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.71 -r1.72 src/usr.bin/indent/args.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.21 src/tests/usr.bin/indent/t_errors.sh:1.22 --- src/tests/usr.bin/indent/t_errors.sh:1.21 Thu Nov 25 21:45:28 2021 +++ src/tests/usr.bin/indent/t_errors.sh Thu Nov 25 21:48:23 2021 @@ -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 @@ option_buffer_overflow_body() 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 } Index: src/usr.bin/indent/args.c diff -u src/usr.bin/indent/args.c:1.71 src/usr.bin/indent/args.c:1.72 --- src/usr.bin/indent/args.c:1.71 Fri Nov 19 20:23:17 2021 +++ src/usr.bin/indent/args.c Thu Nov 25 21:48:23 2021 @@ -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 @@ static char sccsid[] = "@(#)args.c 8.1 ( #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 @@ set_special_option(const char *arg, cons 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 @@ set_special_option(const char *arg, cons 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 @@ set_special_option(const char *arg, cons 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 */ }