bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] in-place edit request


From: Andrew J. Schorr
Subject: Re: [bug-gawk] in-place edit request
Date: Sun, 23 Dec 2012 10:23:36 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Arnold,

On Sun, Dec 23, 2012 at 12:33:22PM +0200, Aharon Robbins wrote:
> I'm not familiar with the perl select function. Can you describe what
> it does?

I'm no Perl hacker, but "perldoc -f select" says this:

        select FILEHANDLE

        Returns the currently selected filehandle.  If FILEHANDLE is supplied,
        sets the new current default filehandle for output.  This has two
        effects: first, a "write" or a "print" without a filehandle default to
        this FILEHANDLE.  Second, references to variables related to output
        will refer to this output channel.

I think it may be equivalent to assigning output_fp in the gawk code
(as is done by the debug.c:set_gawk_output function).

> It may be that in-place editing can be entirely implemented by using
> BEGINFILE, ENDFILE, and a small extension function that simply uses
> freopen(3) on stdout.
> 
> Since that has zero effect on the gawk code base, I'm all for it. :-)

I had also hoped this could be done with a small extension function.  The
problem with freopen is that it closes the existing stdout.  I don't
see how one can then switch back to the previous stdout after redirection
is no longer desired.  If stdout were an lvalue, one could simply
reassign it, but that does not seem to be the case.  Thus, output_fp
seems like the best bet to me.  Unfortunately, that would require exposing
the set_gawk_output function through the extension API or adding a new
builtin gawk function.

Can anybody see another way to do this?  Maybe I am missing something.

Regards,
Andy



reply via email to

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