Dear Xerces developers,
I'm afraid I found a number of bugs in the implementation of the
(overloaded) 'transcode' functions defined in files "IconvTransService.cpp",
"Iconv390TransService.cpp" and "Iconv400TransService.cpp".
I'm using version 1.4 of Xerces sources, and all the line numbers quoted
below refer to the files of this version.
1) File : src\util\Transcoders\Iconv\IconvTransService.cpp
Function : char* IconvLCPTranscoder::transcode(const XMLCh* const
toTranscode)
Line : 270
Current line: "if (toTranscode)" SHOULD BE
"if (*toTranscode)"
Rationale: the condition "if (!toTranscode)" was already checked in line
266,
and the else clause of "if (toTranscode)" would never be
invoked.
2) Same file (src\util\Transcoders\Iconv\IconvTransService.cpp)
Function : XMLCh* IconvLCPTranscoder::transcode(const char* const
toTranscode)
The behavior of this function is inconsistent with namesake functions in
other
transcoders, specifically, Win32LCPTranscoder (defined in file
src\util\Transcoders\Win32\Win32TransService.cpp):
Usually, when the pointer 'toTranscode' is NULL (line 361),
then a NULL pointer (0) is returned from the function. In this
function,
the else-clause returns a unit-length string containing the
null-terminator.
This is not the same problem as (1) above (since 'len' is explicitly
checked
against 0 in the function, line 364), but seems closely related.
==> Both problems (1) and (2) also exist in the namesake functions in file
"src\util\Transcoders\Iconv390\Iconv390TransService.cpp".
==> The overloaded 'transcode' functions in files
"src\util\Transcoders\Iconv390\Iconv400TransService.cpp"
and "src\util\Transcoders\Win32\Win32TransService.cpp" seem all OK.
3) Section "What should I define XMLCh to be?" of the Xerces' document
"Other Build Instructions"
(http://xml.apache.org/xerces-c/build-misc.html#faq-5)
explains that treating 'XMLCh' characters as 'wchar_t' ones causes
protability
problems, as well as suffers from a number of additional drawbacks.
The section also explains that "typedef wchar_t XMLCh" was historically
superceded
on all platforms by "typedef unsigned short XMLCh".
This warning notwithstanding, a number of transcoding functions assign
values
of type 'XMLCh' to variables of type 'wchar_t'.
File : src\util\Transcoders\Iconv\IconvTransService.cpp
Function : unsigned int IconvLCPTranscoder::calcRequiredSize(const
XMLCh* const srcText)
Lines : 240-242 and 251
Function : char* IconvLCPTranscoder::transcode(const XMLCh* const
toTranscode)
Lines : 274-276 and 285
Function : bool IconvLCPTranscoder::transcode( const XMLCh* const
toTranscode
, char* const
toFill
, const unsigned int
maxBytes)
Lines : 328-330 and 339
File : src\util\Transcoders\Iconv390\Iconv390TransService.cpp
Function : unsigned int Iconv390LCPTranscoder::calcRequiredSize(const
XMLCh* const srcText)
Lines : 364-366 and 375
Regards,
Evgeniy Gabrilovich.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]