Re: argv_ref patch 21: push builtin tokens through $@ and m4wrap

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
Eric Blake <ebb9 <at> byu.net> writes:

> 
> One nice bit about this patch is we now match Solaris m4 behavior on this
> (admittedly contrived) testcase:
> m4wrap(`define(foo,')m4wrap(defn(`divnum'))m4wrap(`)foo
> ')
> => 0
> 

Just to set the record straight, I did more testing of how other 
implementations behave with builtin tokens given to m4wrap.  The above quote is 
wrong, since neither Solaris nor BSD handle it the way patched GNU M4 does.  
But I was able to find at least one case where the other two implementations 
would support a builtin token in the argument to m4wrap:

BSD$ m4
m4wrap(`define(foo,')m4wrap(defn(`divnum'))m4wrap(`)-foo-
')dnl
m4: unexpected end of input, unclosed parenthesis:
   stdin at line 3
BSD$ m4
m4wrap(`define(foo,'defn(`divnum')`)-foo-
')dnl
-0-
BSD$

Solaris$ /usr/xpg4/bin/m4
m4wrap(`define(foo,')m4wrap(defn(`divnum'))m4wrap(`)-foo-
')dnl
--
Solaris$ /usr/xpg4/bin/m4
m4wrap(`define(foo,'defn(`divnum')`)-foo-
')dnl
--
Solaris$ /usr/xpg4/bin/m4
define(q,``$@'')m4wrap(`define'(q(foo,defn(`divnum')))`-foo-
')dnl
-0-
Solaris$

So this statement that I added to the GNU M4 manual is particularly 
true: "However, for portability, it is better to defer the evaluation of `defn' 
along with the rest of the wrapped text".

-- 
Eric Blake
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.