From c79799252badefc58aea7bdcb61ab678c178773b Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 14 Nov 2020 21:55:22 +0000 Subject: [PATCH] make(1): don't modify progname in usage --- usr.bin/make/main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 3fc8c17f1c98..557661484ea9 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.465 2020/11/14 18:36:27 rillig Exp $ */ +/* $NetBSD: main.c,v 1.466 2020/11/14 21:55:22 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.465 2020/11/14 18:36:27 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.466 2020/11/14 21:55:22 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -187,16 +187,14 @@ explode(const char *flags) MAKE_ATTR_DEAD static void usage(void) { - char *p; - if ((p = strchr(progname, '[')) != NULL) - *p = '\0'; + size_t prognameLen = strcspn(progname, "["); (void)fprintf(stderr, -"usage: %s [-BeikNnqrstWwX] \n" +"usage: %.*s [-BeikNnqrstWwX] \n" " [-C directory] [-D variable] [-d flags] [-f makefile]\n" " [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n" " [-V variable] [-v variable] [variable=value] [target ...]\n", - progname); + (int)prognameLen, progname); exit(2); }