m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to patsubst the result of an include?


From: Stepan Kasal
Subject: Re: How to patsubst the result of an include?
Date: Mon, 7 Feb 2005 12:14:42 +0100
User-agent: Mutt/1.4.1i

Hi,

On Fri, Feb 04, 2005 at 05:53:49PM +0000, Gary V. Vaughan wrote:
> I've attached a patch against CVS branch-1_4 that implements it (I called
> it qindir to follow the convention set by sinclude).  What do you think?

I accept the name `qindir'.

I'm not familiar with the GNU m4 implementation, yet I disagree with
your patch.  The explanation follows.

> >     define(`include_orig', defn(`include'))
> >     define(`include', `indirq(`include_orig', $1)')
...
> Actually, with the attached implementation, that won't work because when
> GNU M4 puts a file on the input stack (ala include) any partial string
> that doesn't come from the stack is lost :-(  So it still doesn't solve
> Matthew's problem.

Do I understand correctly that
        qindir(`include', `file')
wouldn't work?  (And perhaps would even emit a spurious right quote string?)

I think this symptom shows you should take another approach to implement
qindir.

Please let me discuss a problem which is not too much unrelated:

the following code:
        define(`x', -'-)
        define(y, defn(`x'))
        y
expands to:
        --'
while I believe it should expand to:
        -'-

I think that there should be a special ``token type'' for treating defn
and qindir: the token would carry a string, adn as soon as the token is
expanded, it would immediately expand to the string.

In other words, you'd place the string on the stack, but when m4 proceeds
to do the next expansion of the string, it'd be somehow instructed to
jump over the string (as if it would find a matching right quote there).
Since we know the expansion will follow immediately, we could implement
this hack via one global variable, which would tell the ``expand loop''
that it should jump to the destination; the ``expand loop'' would clear
the variable as soon as the message is received and the jump is done.

The result of this would be that
        quindir(`include', `file')
would include the file literally, even if it contains unmatched right
quotes.

(I'm afraid this is not suitable for branch-1-4, but I don't care.)

What do you think?

Stepan Kasal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]