diff --git a/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp b/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp index adb44eb3e8e8144cc47a1bed00a0b6a654aa53d4..556af94048661f7f1c8b59e42ce464d1f248b257 100644 --- a/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp +++ b/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2004/01/19 16:06:56 amassari + * WideCharToMultiByte and MultiByteToWideChar return 0 on failure, not -1 + * * Revision 1.11 2004/01/13 16:34:22 cargilld * Misc memory management changes. * @@ -1015,10 +1018,7 @@ unsigned int CygwinLCPTranscoder::calcRequiredSize(const char* const srcText if (!srcText) return 0; - const unsigned int retVal = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, srcText, -1, NULL, 0); - if (retVal == (unsigned int)-1) - return 0; - return retVal; + return ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, srcText, -1, NULL, 0); } @@ -1028,10 +1028,7 @@ unsigned int CygwinLCPTranscoder::calcRequiredSize(const XMLCh* const srcText if (!srcText) return 0; - const unsigned int retVal = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)srcText, -1, NULL, 0, NULL, NULL); - if (retVal == (unsigned int)-1) - return 0; - return retVal; + return ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)srcText, -1, NULL, 0, NULL, NULL); } @@ -1045,7 +1042,7 @@ char* CygwinLCPTranscoder::transcode(const XMLCh* const toTranscode) { // Calc the needed size const unsigned int neededLen = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, NULL, 0, NULL, NULL); - if (neededLen == (unsigned int)-1) + if (neededLen == 0) return 0; // Allocate a buffer of that size plus one for the null and transcode @@ -1075,7 +1072,7 @@ char* CygwinLCPTranscoder::transcode(const XMLCh* const toTranscode, { // Calc the needed size const unsigned int neededLen = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, NULL, 0, NULL, NULL); - if (neededLen == (unsigned int)-1) + if (neededLen == 0) return 0; // Allocate a buffer of that size plus one for the null and transcode @@ -1105,7 +1102,7 @@ XMLCh* CygwinLCPTranscoder::transcode(const char* const toTranscode) { // Calculate the buffer size required const unsigned int neededLen = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, NULL, 0); - if (neededLen == (unsigned int)-1) + if (neededLen == 0) return 0; // Allocate a buffer of that size plus one for the null and transcode @@ -1134,7 +1131,7 @@ XMLCh* CygwinLCPTranscoder::transcode(const char* const toTranscode, { // Calculate the buffer size required const unsigned int neededLen = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, NULL, 0); - if (neededLen == (unsigned int)-1) + if (neededLen == 0) return 0; // Allocate a buffer of that size plus one for the null and transcode @@ -1172,7 +1169,7 @@ bool CygwinLCPTranscoder::transcode( const char* const toTranscode } // This one has a fixed size output, so try it and if it fails it fails - if ( size_t(-1) == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) ) + if ( 0 == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) ) return false; return true; } @@ -1197,7 +1194,7 @@ bool CygwinLCPTranscoder::transcode( const XMLCh* const toTranscode } // This one has a fixed size output, so try it and if it fails it fails - if ( size_t(-1) == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) ) + if ( 0 == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) ) return false; // Cap it off just in case diff --git a/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp b/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp index a9368b4b661f4869db0de3460711bc73f7b27280..63fc8a7900ba9d7ee9e9ee26317f2518384e3d34 100644 --- a/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp +++ b/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp @@ -849,10 +849,7 @@ unsigned int Win32LCPTranscoder::calcRequiredSize(const char* const srcText if (!srcText) return 0; - int retVal = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, srcText, -1, NULL, 0); - if (retVal == -1) - return 0; - return retVal; + return ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, srcText, -1, NULL, 0); } @@ -862,10 +859,7 @@ unsigned int Win32LCPTranscoder::calcRequiredSize(const XMLCh* const srcText if (!srcText) return 0; - int retVal = ::WideCharToMultiByte(CP_ACP, 0, srcText, -1, NULL, 0, NULL, NULL); - if (retVal == -1) - return 0; - return retVal; + return ::WideCharToMultiByte(CP_ACP, 0, srcText, -1, NULL, 0, NULL, NULL); } // Return value using global operator new @@ -1010,7 +1004,7 @@ bool Win32LCPTranscoder::transcode( const char* const toTranscode } // This one has a fixed size output, so try it and if it fails it fails - if ( size_t(-1) == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) ) + if ( 0 == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) ) return false; return true; } @@ -1035,7 +1029,7 @@ bool Win32LCPTranscoder::transcode( const XMLCh* const toTranscode } // This one has a fixed size output, so try it and if it fails it fails - if ( size_t(-1) == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) ) + if ( 0 == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) ) return false; // Cap it off just in case