GNOME Bugzilla – Bug 153937
Inconsistency between documentation and code
Last modified: 2004-12-22 21:47:04 UTC
The specification for xmlCharEncodingOutputFunc (module encoding) says that the function will return 'the number of bytes written, -1 if lack of space, or -2 if the transcoding failed'. UTF8ToUTF16LE (which is the implementation of that interface for the UTF16LE encoding) appears to return 0 on success (appears to be confirmed by an examination of the 2.6.13 source code). Having said that, several (I didn't check them all) of the converter functions look like they return 0 on success - is it the documentation that's incorrect?
Okay, I fixed this in CVS by making all the conversion functions return the number of bytes converted. I'm not 100% sure this won't introduce errors in existing code though, so I may revert this in case of problems. Daniel
The documentation of (some of the) implementations of xmlCharEncodingOutputFunc is no longer consistent as of 2.6.16, since it says that the implementations will return 0 on success. Furthermore this fix is not backwards compatible with older versions, so software that worked with < 2.6.16 could not work anymore..
Well I knew it could be a problem. Tell me the function for which the comment was not appropriate, I really tried to check that they said the right thing. Seems to me if the implementation was not consistent with the documentation this should be reported as a bug and fixed, especially when all functions are supposed to work the same because they all follow the same pattern. Daniel
FYI - isolat1ToUTF8 and UTF8Toisolat1 (the only documented encoding functions) say they return 0 on success. xmlCharEncodingOutputFunc says it returns the number of bytes on success. isolat1ToUTF8 and UTF8Toisolat1 are implementations of xmlCharEncodingOutputFunc. The three should be self-consistent somehow. Don't really care how.