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:Steve Hay (Stev@planit.com)
Date:Mar 4, 2010 8:40:18 am
List:org.perl.perl5-porters

kmx via RT wrote on 2010-03-03:

Dne st 10.02.2010 12:44:10, kmxx napsal(a):

Hi,

I have hit into a strange "maybe-bug" on Win32 platform.

The problem occurs when a XS modules tries to call function fputs() from XS/C code.

The standard UNIX declaration of fputs looks AFAIK like this: int fputs(const char *s, FILE *stream);

Thus one would expect that also in XS/C code you just use "fputs(string,filehandle);" However if you do this on Win32 perl you will see an warning like this (my example comes from Math::Pari where I revealed the problem).

Pari.xs: In function 'XS_Math__Pari_dumpStack': Pari.xs:3798: warning: passing argument 2 of '(*Perl_IStdIO_ptr ((struct PerlInterpreter *)Perl_get_context()))->pPuts' from incompatible pointer type Pari.xs:3798: note: expected 'struct FILE *' but argument is of type 'char *' Pari.xs:3798: warning: passing argument 3 of '(*Perl_IStdIO_ptr((struct PerlInterpreter *)Perl_get_context())) ->pPuts' from incompatible pointer type Pari.xs:3798: note: expected 'const char *' but argument is of type 'struct FILE *'

Swapping the arguments fixed the warning, so it seems to me than in Win32/perl XS code it is expected to use: fputs(filehandle,string);

whereas on Linux/perl box it is expected to use: fputs(string,filehandle);

I have tracked this issue to iperlsys.h where I lost in a bunch of macros and typedefs.

Note: 5.11.4 used for testing is based on release tarball, gcc compiler, all options left in default.

Thanks for any help.

Can somebody please comment on this issue. I know that is not new in perl 5.11.x (perhaps not even in 5.10.x) but from my point of view it seems to be a clear bug.

Thanks in advance for any suggestions.

Sorry, I meant to reply to this earlier but completely forgot.

I think it is deliberate: it is explicitly mentioned in perlapio.pod that the
arguments have been reversed compared to the C library function (probably so
that all the PerlIO functions have the 'f' first). And there's a further comment
about it in perlxstut.pod too.

Are you sure the arguments are not reversed on Linux too? There's no mention of
the reversal being Win32-specific.