wu liang | 31 May 2011 17:38
Picon

A manual problem about quoted string

Sir,
In the chapter 5, there is example as:
----------------------------------
define(`foo’, `This is macro `foo’.’)
The ‘foo’ in the expansion text is not expanded, since it is a quoted
string, and not a name.
----------------------------------
However, according to my test, this will cause infinite loop of
printing. I think that each 'foo' will be expanded and whether it is
quoted only affects when it is expanded.
I am using the version 1.4.14.

Best regards,
Wu Liang
Eric Blake | 31 May 2011 17:44
Picon
Favicon
Gravatar

Re: A manual problem about quoted string

On 05/31/2011 09:38 AM, wu liang wrote:
> Sir,
> In the chapter 5, there is example as:
> ----------------------------------
> define(`foo’, `This is macro `foo’.’)
> The ‘foo’ in the expansion text is not expanded, since it is a quoted
> string, and not a name.
> ----------------------------------
> However, according to my test, this will cause infinite loop of
> printing. I think that each 'foo' will be expanded and whether it is
> quoted only affects when it is expanded.

Thanks for the report.  However, I think the manual is correct as is,
given my simple test (not to mention that 'make check' runs all the
examples in the manual, and has not detected any problems with this
example):

$ m4 <<\EOF
> define(`foo',`This is macro `foo'.')
> foo
> EOF

This is macro foo.
$

Please show your particular test to back up your claim; most likely, the
bug is in your test setup and not in m4 or in the manual.  Did you
perhaps use changequote to some other quote characters before trying the
define?  Does using 'm4 -deaqt' give any more insight into the infinite
loop (warning, that can produce a lot of output on anything larger than
(Continue reading)

Eric Blake | 31 May 2011 19:24
Picon
Favicon
Gravatar

Re: A manual problem about quoted string

[re-adding the list, for closure]

On 05/31/2011 11:22 AM, wu liang wrote:
> Sorry for this wrong report. It's careless typo replacing ` with ' in
> the test script.
> As this:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> define(`foo',`This is macro 'foo'')
> foo
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Glad to hear you got it resolved.  And yes, ` vs. ' can be rather
insidious (which is part of the reason why autoconf uses changequote to
use [ vs. ]).

--

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


Gmane