Nicholas Clark wrote:

>On Wed, Jan 26, 2005 at 09:19:26AM +0100, Reinhard Pagitsch wrote:
>  
>
>>Hello Steve,
>>
>>Steve Hay wrote:
>>
>>    
>>
>>>why is it that the following XS code outputs -25:
>>>
>>>
>>>      
>>>
>>[code sniped]
>>
>>On my system (Windows 2000) the output is -1, as expected.
>>    
>>
>
>What's it documented to be? stricmp() doesn't seem to be a standard function
>in any standard implemented on Unix, but strcmp()'s return is stated only
>to be "an integer greater than, equal to, or less than 0", not specifically
>-1 or +1
>
The docs for MS stricmp() also say <0, 0 or >0, not specifically -1, 0, 
+1, but it seems very odd that the XS code reliably does something 
different than the pure C code.  There must be a reason for it somewhere.

(A C library that I'm linking to (inadvisedly) tested for a return value 
of +1.  It has worked for many years as a pure C library, but tripped up 
when called via the Perl XS extension because the return value was >1.  
Clearly the fix is to change the C library to test for >0, but I'd like 
to understand where the different behaviour crept in.)

- Steve


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.

Reply via email to