atom feed19 messages in org.perl.perl5-portersRE: [perl #72704] Buggy fputs(f,s) vs...
FromSent OnAttachments
kmx via RTMar 3, 2010 1:47 am 
Steve HayMar 4, 2010 8:40 am 
Dave MitchellMar 4, 2010 12:17 pm 
Steve HayMar 4, 2010 4:17 pm 
Jan DuboisMar 4, 2010 6:53 pm 
Jan DuboisMar 4, 2010 7:07 pm 
kmx via RTMar 4, 2010 11:15 pm 
Jan DuboisMar 5, 2010 12:26 am 
Steve HayMar 5, 2010 1:18 am 
Jan DuboisMar 5, 2010 12:50 pm 
kmxMar 5, 2010 11:52 pm 
Tim BunceMar 6, 2010 1:37 pm 
kmx via RTApr 11, 2010 2:35 am 
Jan Dubois via RTApr 21, 2010 11:55 pm 
kmx via RTApr 22, 2010 10:46 am 
kmx via RTMay 5, 2010 4:30 am 
Jan DuboisMay 5, 2010 12:26 pm 
Tim BunceMay 6, 2010 4:05 am 
Craig A. BerryMay 6, 2010 6:21 am 
Subject:RE: [perl #72704] Buggy fputs(f,s) vs. fputs(s,f) on Win32 (maybe not only)
From:Jan Dubois (ja@activestate.com)
Date:Mar 4, 2010 7:07:59 pm
List:org.perl.perl5-porters

On Thu, 04 Mar 2010, Jan Dubois wrote:

On Thu, 04 Mar 2010, Dave Mitchell wrote:

*However*: out in XS/win32 land, you appear to have:

XSUB.h: #define fputs PerlSIO_fputs

That one is correct. PerlSIO_* APIs are supposed to have the same prototype as their corresponding stdio ones.

iperlsys.h:

#if defined(PERL_IMPLICIT_SYS) #define PerlSIO_fputs(f,s) (*PL_StdIO->pPuts)(PL_StdIO, (f),(s)) #else #define PerlSIO_fputs(f,s) fputs(s,f) #endif

This however is busted. The parameters should not be swapped.

The same problem exists for the fputc() function as well. I've attached my attempt at correcting all the mistakes I found. Core Perl still builds fine on Windows and OS X; but I haven't tried building any extensions that use fputs() or fputc().

Note that is would be _possible_ to make a much smaller patch than the one I supplied by just swapping the parameters in

#define PerlSIO_fputs(f,s) (*PL_StdIO->pPuts)(PL_StdIO, (f),(s))

(and also in the corresponding PerlSIO_fputc() #define). It would however be rather confusing longer term, as that works only accidentally: perlsdio.h doesn't swap the parameter order when it should, and iperlsys.h then compensates for that by swapping when it shouldn't. So I would much prefer to use the comprehensive patch provided in my previous message to reduce the amount of brain-pain when somebody looks at these again in the future.

Cheers, -Jan