tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bmake: how about :tr/CHARS/REPL/[1g]

> Another proposal (now minor) for bmake.

> How about adding new variable substitution :tr/CHARS/REPLS/[1g]
> similar to tr(1).

> It is close to sequence of :S/SUBSTR/REPL/[1g] but sometimes
> cannot be emulated easily, for example :tr/-./.-/g

I'll explain why I propose this.
In my wip/mk-configure the following construct is used many (>10) times.

# Somewhere in user's Makefile
MKC_CHECK_SIZEOF+= int long long-long void* size_t:string.h
.include <>

.for t in ${MKC_CHECK_SIZEOF}
SIZEOF.${t:S|.|_|g:S|-|_|g:S|*|P|g:S|/|_|g:S|:|.|g}   !=   env ${mkc.environ} 
${MKC_SHELL} mkc_check_sizeof ${t:S/:/ /g}
MKC_CFLAGS  +=  -DSIZEOF_${t:S/-/_/g:S| 

This code should "generate" something like  = 4
SIZEOF.long = 4
SIZEOF.long_long = 8
SIZEOF.voidP = 8
SIZEOF.size_t.string_h = 4

As you can see code has lots of sequences of :S/// modifiers.
In the future I'd like to replace long constructs like


with more natural, much shorter, easier to read and faster


If nobody objects I think I can prepare a patch for this.

Best regards, Aleksey Cheusov.

Home | Main Index | Thread Index | Old Index