DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25812>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25812

transcode function return value incorrect

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[EMAIL PROTECTED]
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From [EMAIL PROTECTED]  2004-01-19 17:13 -------

Hi,

I'm reopening this bug as I think that there is an issue with the 
implementation of this routine.  Unfortunately our description for the bug 
didn't include enough relevant information so the conclusion that was reached 
is expected - apologies for this.

In essence, we are finding that the behaviour of this routine on AIX is 
different to that on Solaris, Windows and Linux.  On all non-AIX platforms that 
we've tested on the function returns false when the size specified is not large 
enough to fully transcode the input string.

I guess the bug is really that the behaviour is inconsistent across platforms.  
Whether the AIX behaviour is correct is really dependent on your interpretation 
of the intended behaviour.

At least from our point of view, to return false in the scenario specified 
seems the most useful.  For example, consider the following user code:

inline XMLCh * STRING_TO_DOM(const char * str, XMLCh * buffer, size_t 
buffer_size)
{
    if (*str == '\0')
    {
        return 0;
    }
    else
    {
        if (XMLString::transcode(str, buffer, buffer_size - 1))
        {
            return buffer;
        }
        
        return XMLString::transcode(str);
    }
}

As can be seen from the above, if the transcode function returns false when the 
buffer size is not large enough it allows the user to easily switch between 
using a pre-allocated buffer or heap-allocated storage for transcoding 
depending on the length of the message.  In the above code, if the heap-based 
transcode function was used all the time the performance would (in general) be 
much slower, assuming that most strings to be transcoded were reasonably short.

Without the transcode function returning false on buffer overflow the above 
example cannot be simply implemented because there is no way of knowing whether 
a pre-allocated buffer based transcode call will be or has been successful.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to