Subject: Re: make: allow setting variable mods in variable?
To: Simon J. Gerraty <sjg@crufty.net>
From: Roland Illig <rillig@NetBSD.org>
List: tech-toolchain
Date: 02/12/2006 08:28:19
Simon J. Gerraty wrote:
> No one has any thoughts on this?
> Any one have objections to allowing this?
> 
> 
>>I occasionally have a complex set of variable mods that I want to use 
>>in multiple places and it would be handy to specify these in variable
>>as in (trivial example I know):
> 
> 
>>MODS=S,A,a,
> 
> 
>>V=Abc
> 
> 
>>all:
>>	@echo V=${V:${MODS}}

Looks good to me, too. Especially for pkgsrc this might become useful, 
once we stop supporting old make(1) implementations, say from NetBSD 1.6.

It's a great step towards usability and readability to write 
${PREFIX:${Qsed}:Q} instead of ${PREFIX:C/\\/\\\\/g:C/&/\\&/g:Q}. As 
well as Qawk, Qc, Qperl, Qpython, Qruby, etc.

>>--- var.c.~1~	Sat Sep  3 15:15:09 2005
>>+++ var.c	Fri Jan 20 16:58:52 2006
>>@@ -1890,6 +1890,7 @@ Var_Parse(const char *str, GNode *ctxt, 
>>	  Boolean *freePtr)
>>{
>>    const char	   *tstr;    	/* Pointer into str */
>>+    const char	   *tstr2;	/* Secondary tstr if we need to recurse  */

...

>>+    if (tstr2)
>>+	free(tstr2);

Freeing a pointer to constant memory doesn't look nice to me.

Roland