Tony Cook <tony <at> develop-help.com> writes: > strxfrm() returns an incorrect value if you supply an output buffer > and that buffer is too short for the result.
The text in the C standard is: >>>>> The strxfrm function returns the length of the transformed string (not including the terminating null character). If the value returned is n or more, the contents of the array pointed to by s1 are indeterminate. EXAMPLE The value of the following expression is the size of the array needed to hold the transformation of the string pointed to by s. 1 + strxfrm(NULL, s, 0) <<<<< It doesn't really provide for an explanation of what should happen if you start with a buffer that is too small, but from the standpoint of defensiveness, if you are getting the size of your buffer or larger, then you should ask again with a size of zero to get the actual minimum size needed or try again with a larger buffer until the returned value is smaller than the buffer size. > It appears that strxfrm() is just returning the size of the output > buffer on an overflow error rather than calling LCMapString() again > with cchDest set to zero to get the required buffer length that > strxfrm() is meant to return on a short buffer. So, you may be expecting something that the standard doesn't explicitly specify, although you might reasonhably invoke that Cygwin should behave like Linux in this case. Regards, Achim. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple