Scott Simpson | 29 Mar 2006 08:35
Picon
Favicon

There is a bug in m4 tracing

Witness the following typescript:

 

Script started on Tue 28 Mar 2006 10:30:52 PM PST
$ cat m4.txt

define(`echo1', `$*')

define(`echo2', `$ <at> ')

define(`foo', `This is the macro `foo'.')

#traceon

echo1(foo)

echo2(foo)

$ m4 m4.txt

 

 

 

#traceon

This is the macro This is the macro foo..

This is the macro foo.

$ sed 's/^#//' < m4.txt > m4_with_trace.txt

$ m4 m4_with_trace.txt

 

 

 

 

m4trace: -2- foo

m4trace: -1- echo1

This is the macro m4trace: -1- foo

This is the macro foo..

m4trace: -2- foo

m4trace: -1- echo2

This is the macro foo.

$
Script done on Tue 28 Mar 2006 10:31:54 PM PST
 

_______________________________________________
Bug-m4 mailing list
Bug-m4 <at> gnu.org
http://lists.gnu.org/mailman/listinfo/bug-m4
Stepan Kasal | 29 Mar 2006 11:55
Picon

Re: There is a bug in m4 tracing

Hello,

> Witness the following typescript:

looks right to me.

Let me explain; let's start with your definition:

> define(`foo', `This is the macro `foo'.')

The most natural way to use this macro as a parameter would be this:

> define(`echo3', `$1')
> echo3(`foo')

(Note that the parameter is quoted.)

echo3 would get one parameter, <foo>  (without the angle braces, of
course).  So it would expand to <foo>.  And this would expand to
	This is the macro `foo'.
which is expanded word by word and ends up as
	This is the macro foo.

Back to your example:

> define(`echo1', `$*')
> echo1(foo)

Since the parameter is not quoted, it is expanded during the parameter
scan for echo1.  So first <foo> is expanded to <This is the macro `foo'.>
and then to <This is the macro foo.>---and this is what becomes the
parameter for echo1.

Then echo1 is expanded, and we get <This is the macro foo.>
Then this is expanded word by word, so we get
	This is the macro This is the macro `foo'..
and
	This is the macro This is the macro foo..

To sum up, the macros were expanded in this order:
	foo, echo1, foo

> define(`echo2', `$ <at> ')
> echo2(foo)

This is similar, but $ <at>  becomes <`This is the macro foo.'> and thus the
macro foo is not expanded once more, so the list is:
	foo, echo2

One final note:
> m4trace: -2- foo
The number 2 means that foo is expanded during the scan for parameters of
echo1.

Hope this helps,
	Stepan Kasal
Scott Simpson | 30 Mar 2006 07:40
Picon
Favicon

RE: There is a bug in m4 tracing

Sorry, what was confusing me was that the trace information is interspersed with the output. I.e.,

 

m4trace: -2- foo

m4trace: -1- echo1

This is the macro m4trace: -1- foo

This is the macro foo..

 

Blue is the real output and red is the trace. I was reading it like

 

m4trace: -2- foo

m4trace: -1- echo1

This is the macro m4trace: -1- foo

This is the macro foo..

 

_______________________________________________
Bug-m4 mailing list
Bug-m4 <at> gnu.org
http://lists.gnu.org/mailman/listinfo/bug-m4
Jonathan Wong | 31 Mar 2006 20:23

Need Help[

I am attempting to install GNU m4 because I need it for Autoconf which I need for Flex which I need for Art and Bison for which I need it for cflowd (utterly ridiculous), Anyways when I try to do a ./configure it reports that it cant find itself. When I do a sh ./configure it goes through the files, but then when I try to do a make, it says can not find autoconf!!! That’s the whole reason why I am installing this.

 

Jonathan Wong

Hudson Valley DataNet, LLC

Network Operations Technician

900 Corporate Blvd.

Newburgh New York12550

(t) 845-567-6367 ext. 102

(f) 845-567-6377

jwong <at> hvdata.net

 

Confidentiality Notice

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_______________________________________________
Bug-m4 mailing list
Bug-m4 <at> gnu.org
http://lists.gnu.org/mailman/listinfo/bug-m4

Gmane