Hello,

I've been messing around with diversions inside macros, and have come upon 
an odd scenario. I'd like to call it a bug, but I get the same behavior 
from m4 1.4 as from 1.9a.

See the attached m4 input file. You have div10(), a macro which sends its 
argument to diversion 10, and foo(), a trivial HTML-enclosing thing.

div10() works fine when called by itself, and when called inside a quoted 
macro argument. But when called inside an unquoted macro argument, it is as 
if the divert(10) never happened; the text that was supposed to go to div 
10 ends up in the current div (i.e. 0):

        <FOO>This goes inside FOO tags.</FOO>
        <FOO>This also goes inside FOO tags.This is even more text in div 10.
        </FOO>
        Diversion 10:
        This is text in div 10.
        This is some more text in div 10.
        End of input

I would have expected that all three "This is ... text in div 10" lines 
would have been diverted accordingly:

        <FOO>This goes inside FOO tags.</FOO>
        <FOO>This also goes inside FOO tags.</FOO>
        Diversion 10:
        This is text in div 10.
        This is some more text in div 10.
        This is even more text in div 10.
        End of input

(This came about from attempting to implement a footnote mechanism. foo() 
is my \p{} macro, and div10() is \footnote{}.)

So, what's going on here, and is there any way to make div10() work as 
expected without needing to quote the argument to foo()?


--Daniel


-- 
NAME   = Daniel Richard G.       ##  Remember, skunks       _\|/_  meef?
EMAIL1 = [EMAIL PROTECTED]        ##  don't smell bad---    (/o|o\) /
EMAIL2 = [EMAIL PROTECTED]      ##  it's the people who   < (^),>
WWW    = http://www.******.org/  ##  annoy them that do!    /   \
--
(****** = site not yet online)
define(`div10', `divert(10)$1`'divert(0)')dnl
define(`foo', `<FOO>$1</FOO>
')dnl
dnl
div10(`This is text in div 10.
')dnl
foo(`This goes inside FOO tags.div10(`This is some more text in div 10.
')')dnl
foo(This also goes inside FOO tags.div10(`This is even more text in div 10.
'))dnl
Diversion 10:
undivert(10)dnl
End of input
_______________________________________________
M4-discuss mailing list
M4-discuss@gnu.org
http://lists.gnu.org/mailman/listinfo/m4-discuss

Reply via email to