Hi David, David A. Caplan wrote: > m4 seems to be picking up single quote characters (') within comment > lines (both when using # and dnl). I am using "GNU m4 1.4.1". It also > expands $1, $2,... if they are within a comment. > > Example: > define(`foo',` > # there aren't any arguments to this macro > this is output of the fo`o' macro') > foo
I can see 3 problems with this code: 1. The m4 reader breaks tokens up on quote pairs (among others) before it starts any parsing, though it strips outer quotes almost immediately: token1: define token2: ( token3: foo {quotes are stripped) token4: \n#there aren token5: t any arguments to this macro\nthis is output of the foo macro' token6: ) Note that token4 is considered complete when a matching ' character is read; token 5 has an unbalanced ' character, and the quotes inside foo are stripped because they are a matching outer pair. You have to change the quote characters to stop the reader treating your unbalanced ' as a close quote 2. Trying to partially quote fo`o' doesn't work at the outer level either, because by the time the reader has passed the token to the parser, those outer quotes have been stripped and foo is rescanned for macros (and hence expanded). Double quoting literals is the standard way to make that work in m4. 3. The comment characters only apply at the outermost level, arguments to macro invocations are rescanned and expanded just like everything else. (and positional parameters are expanded too). Here is an example of how to use all this: changequote([,]) => define([foo], [[ # there aren't any arguments to foo this is output of the foo macro]]) => # foo => # foo foo => # there aren't any arguments to foo this is output of the foo macro HTH, Gary. -- Gary V. Vaughan ())_. [EMAIL PROTECTED],gnu.org} Research Scientist ( '/ http://tkd.kicks-ass.net GNU Hacker / )= http://www.gnu.org/software/libtool Technical Author `(_~)_ http://sources.redhat.com/autobook
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Bug-m4 mailing list Bug-m4@gnu.org http://lists.gnu.org/mailman/listinfo/bug-m4