Re: make: refuse empty variable names

Stuart Henderson <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
This has been through mkr and a ports bulk build on i386 without problem.
It's ok with me.

On 2026/06/16 12:11, Marc Espie wrote:
> On Sun, Jun 14, 2026 at 11:01:47AM +0200, Marc Espie wrote:
> > Found by accident while looking at www/dufs/crates.inc
> > 
> > gmake refuses empty variable names, I think we should too.
> > 
> > Especially if we make typos and end up expanding empty stuff.
> > 
> > (currently, stuff that starts with an = will be treated as a comment)
> > 
> > This needs to get through a full release, obviously...
> 
> Of course first version was wrong. Namely the check needs to happen
> *after* the parser has determined we are in a variable assignment.
> 
> Index: parsevar.c
> ===================================================================
> RCS file: /home/espie/cvs/src/usr.bin/make/parsevar.c,v
> diff -u -p -r1.18 parsevar.c
> --- parsevar.c	18 Jun 2024 02:11:03 -0000	1.18
> +++ parsevar.c	16 Jun 2026 08:00:51 -0000
> @@ -133,6 +133,8 @@ parse_variable_assignment(const char *li
>  		}
>  	}
>  
> +	if (name.s == name.e)
> +		Parse_Error(PARSE_FATAL, "empty variable name");
>  	arg++;
>  	while (ISSPACE(*arg))
>  		arg++;
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.