develooper Front page | perl.perl5.porters | Postings from April 2003


Thread Previous
Nick Ing-Simmons
April 17, 2003 06:28
Message ID:
Chip Salzenberg <> writes:
>In bleadperl there are nine "FIXME" comments (not counting four in lib
>and ext, and three in win32).  The one in doio.c first caught my eye,
>and I'd appreciate somebody explaining just what's dangerous about the
>code below it.  

FIXME is what I put in when I notice something odd.

For the doio.c case:

    /* Eeek - FIXME !!!
     * If this is a standard handle we discard all the layer stuff
     * and just dup the fd into whatever was on the handle before !

    if (saveifp) {		/* must use old fp? */

This is refering to the case where someone does:

  binmode(STDOUT,":encoding(Klingon)"); or some such 

and then 


or whatever. do_openn carefully opens a PerlIO * and pushes the requested 
layers onto it. Then the FIXME code just asks the PerlIO * for its UNIX fd,
dup-s that onto 1 (for STDOUT) and closes it. Leaving STDOUT with 
the layer stack that was binmode-d on and ignoring the layers specified 
in the open call.

The reason it is like that is in the bad old days of 
#define PerlIO FILE 

The FILE * stdout could not be re-assigned.
We also did not want to "close(1)" until we knew that new open had worked.

In these modern days of perliol.h what "should" happen in the that 
linked-list that is "stdout" should be adjusted to point to new PerlIO *
- but there is still the issue that fileno(STDOUT) should be 1 - so 
some kind of hybrid is needed.

Nick Ing-Simmons

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About