On Aug 21 21:04:53, [email protected] wrote:
> I came across some m4 problems when trying to compile sox
> (a future version of the audio/sox port), which uses the
> horrendous autotools to create it's ./configure script.
> These tools in turn use m4 to define their macros.
> 
> What should the following print?
> (Please excuse my m4 ignorance.)
> 
> divert(-1)dnl
> changequote([, ])
> define([dquote],  [[$@]])
> define([argn], [pushdef([_$0], [popdef([_$0])]dquote([$]incr([$1])))_$0($@)])

Could it be this?

     The built-ins pushdef and popdef handle macro definitions as a stack.
     However, define interacts with the stack in an undefined way.  In this
     implementation, define replaces the top-most definition only.  Other
     implementations may erase all definitions on the stack instead.


> define([foo], [argn([10], $@)])
> define([bar], [argn([9], shift($@))])
> define([baz], [argn([8], shift(shift($@)))])
> define([numbers], [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]])
> divert(0)dnl
> foo(numbers)
> bar(numbers)
> baz(numbers)
> 
> According to upstream, it should be
> 
> 10
> 10
> 10
> 
> On current, it's
> 
> 101
> 90
> 10
> 
>       Jan
> 
> https://marc.info/?l=sox-devel&m=159803236823541&w=2
> https://sourceforge.net/p/sox/code/ci/affc279d142f843f3f50d4718798303396ee24b4/
> 
> 

Reply via email to