amassari 2004/01/19 08:06:56
Modified: c/src/xercesc/util/Transcoders/Cygwin CygwinTransService.cpp
c/src/xercesc/util/Transcoders/Win32 Win32TransService.cpp
Log:
WideCharToMultiByte and MultiByteToWideChar return 0 on failure, not -1
Revision Changes Path
1.12 +11 -14
xml-xerces/c/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp
Index: CygwinTransService.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/util/Transcoders/Cygwin/CygwinTransService.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CygwinTransService.cpp 13 Jan 2004 16:34:22 -0000 1.11
+++ CygwinTransService.cpp 19 Jan 2004 16:06:56 -0000 1.12
@@ -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 @@
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 @@
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 @@
{
// 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 @@
{
// 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 @@
{
// 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 @@
{
// 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 @@
}
// 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 @@
}
// 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
1.21 +5 -11
xml-xerces/c/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp
Index: Win32TransService.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Win32TransService.cpp 16 Jan 2004 16:34:59 -0000 1.20
+++ Win32TransService.cpp 19 Jan 2004 16:06:56 -0000 1.21
@@ -849,10 +849,7 @@
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 @@
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 @@
}
// 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 @@
}
// 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]