bug-m4
[Top][All Lists]
Advanced

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

Example code bug


From: Florian Mayer
Subject: Example code bug
Date: Sat, 16 Aug 2014 16:20:40 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.0

Hello m4 team,

I hope that it is an actual bug this time...
There is a sample listing for a simple for-
loop in the manual at chapter 6.4.
The corresponging lines are
==m4code==
$ m4 -I examples
[...]
# forloop(var, from, to, stmt) - simple version
define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')')
define(`_forloop', `$4'`ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')')
[...]
==end==

While this code works perfectly for the most applications, it miserably fails
if the client uses something like this:
==m4code==
forloop(`a', 1, 8, `a')
=> aifelse(1, 8, , define(`a', incr(a))_forloop(`a',`1',`8',`a'))
==end==

I am aware of the existence of forloop2, which is listed in the example code
directory, but I like this function for it's simplicity.
I think the following (tested) quick fix could be suitalbe for usage in the manual.
==m4code==
[...]
define(`_forloop', `$4'``''`ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')')
[...]
==end==

Best regards
Florian Mayer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]