projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use GetCopyrightToDisplay instead of GetCopyright; part of commit 57245
[wxWidgets.git]
/
src
/
common
/
strconv.cpp
diff --git
a/src/common/strconv.cpp
b/src/common/strconv.cpp
index ae7fa502312f48e87f978f5959ed97f42dac9763..64d31ae75075b8e76301ebc5731d2c8fa9bc269c 100644
(file)
--- a/
src/common/strconv.cpp
+++ b/
src/common/strconv.cpp
@@
-142,7
+142,7
@@
static wxUint32 wxDecodeSurrogate(const wxDecodeSurrogate_t **pSrc)
{
wxUint32 out;
const size_t
{
wxUint32 out;
const size_t
- n = decode_utf16(
wx_reinterpret_cast(const wxUint16 *,
*pSrc), out);
+ n = decode_utf16(
reinterpret_cast<const wxUint16 *>(
*pSrc), out);
if ( n == wxCONV_FAILED )
*pSrc = NULL;
else
if ( n == wxCONV_FAILED )
*pSrc = NULL;
else
@@
-355,9
+355,7
@@
wxMBConv::FromWChar(char *dst, size_t dstLen,
size_t wxMBConv::MB2WC(wchar_t *outBuff, const char *inBuff, size_t outLen) const
{
size_t wxMBConv::MB2WC(wchar_t *outBuff, const char *inBuff, size_t outLen) const
{
- // add 1 to available buffer length because MB2WC() parameter counts the
- // number of non-NUL characters while ToWChar() counts everything
- size_t rc = ToWChar(outBuff, outLen + 1, inBuff);
+ size_t rc = ToWChar(outBuff, outLen, inBuff);
if ( rc != wxCONV_FAILED )
{
// ToWChar() returns the buffer length, i.e. including the trailing
if ( rc != wxCONV_FAILED )
{
// ToWChar() returns the buffer length, i.e. including the trailing
@@
-370,12
+368,10
@@
size_t wxMBConv::MB2WC(wchar_t *outBuff, const char *inBuff, size_t outLen) cons
size_t wxMBConv::WC2MB(char *outBuff, const wchar_t *inBuff, size_t outLen) const
{
size_t wxMBConv::WC2MB(char *outBuff, const wchar_t *inBuff, size_t outLen) const
{
- const size_t nulLen = GetMBNulLen();
-
- size_t rc = FromWChar(outBuff, outLen + nulLen, inBuff);
+ size_t rc = FromWChar(outBuff, outLen, inBuff);
if ( rc != wxCONV_FAILED )
{
if ( rc != wxCONV_FAILED )
{
- rc -=
nulLen
;
+ rc -=
GetMBNulLen()
;
}
return rc;
}
return rc;
@@
-588,7
+584,7
@@
size_t wxMBConvUTF7::ToWChar(wchar_t *dst, size_t dstLen,
}
else // when working with partial strings we do use the shift state
{
}
else // when working with partial strings we do use the shift state
{
- statePtr =
wx_const_cast(DecoderState *,
&m_stateDecoder);
+ statePtr =
const_cast<DecoderState *>(
&m_stateDecoder);
// also save the old state to be able to rollback to it on error
stateOrig = m_stateDecoder;
// also save the old state to be able to rollback to it on error
stateOrig = m_stateDecoder;
@@
-775,7
+771,7
@@
size_t wxMBConvUTF7::FromWChar(char *dst, size_t dstLen,
else // do use the mode we left the output in previously
{
stateOrig = m_stateEncoder;
else // do use the mode we left the output in previously
{
stateOrig = m_stateEncoder;
- statePtr =
wx_const_cast(EncoderState *,
&m_stateEncoder);
+ statePtr =
const_cast<EncoderState *>(
&m_stateEncoder);
}
EncoderState& state = *statePtr;
}
EncoderState& state = *statePtr;
@@
-1411,7
+1407,7
@@
size_t wxMBConvUTF16Base::GetLength(const char *src, size_t srcLen)
if ( srcLen == wxNO_LEN )
{
// count the number of bytes in input, including the trailing NULs
if ( srcLen == wxNO_LEN )
{
// count the number of bytes in input, including the trailing NULs
- const wxUint16 *inBuff =
wx_reinterpret_cast(const wxUint16 *,
src);
+ const wxUint16 *inBuff =
reinterpret_cast<const wxUint16 *>(
src);
for ( srcLen = 1; *inBuff++; srcLen++ )
;
for ( srcLen = 1; *inBuff++; srcLen++ )
;
@@
-1495,7
+1491,7
@@
wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen,
if ( dstLen < srcLen )
return wxCONV_FAILED;
if ( dstLen < srcLen )
return wxCONV_FAILED;
- const wxUint16 *inBuff =
wx_reinterpret_cast(const wxUint16 *,
src);
+ const wxUint16 *inBuff =
reinterpret_cast<const wxUint16 *>(
src);
for ( size_t n = 0; n < srcLen; n++, inBuff++ )
{
*dst++ = wxUINT16_SWAP_ALWAYS(*inBuff);
for ( size_t n = 0; n < srcLen; n++, inBuff++ )
{
*dst++ = wxUINT16_SWAP_ALWAYS(*inBuff);
@@
-1519,7
+1515,7
@@
wxMBConvUTF16swap::FromWChar(char *dst, size_t dstLen,
if ( dstLen < srcLen )
return wxCONV_FAILED;
if ( dstLen < srcLen )
return wxCONV_FAILED;
- wxUint16 *outBuff =
wx_reinterpret_cast(wxUint16 *,
dst);
+ wxUint16 *outBuff =
reinterpret_cast<wxUint16 *>(
dst);
for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ )
{
*outBuff++ = wxUINT16_SWAP_ALWAYS(*src);
for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ )
{
*outBuff++ = wxUINT16_SWAP_ALWAYS(*src);
@@
-1553,7
+1549,7
@@
wxMBConvUTF16straight::ToWChar(wchar_t *dst, size_t dstLen,
}
size_t outLen = 0;
}
size_t outLen = 0;
- const wxUint16 *inBuff =
wx_reinterpret_cast(const wxUint16 *,
src);
+ const wxUint16 *inBuff =
reinterpret_cast<const wxUint16 *>(
src);
for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; )
{
const wxUint32 ch = wxDecodeSurrogate(&inBuff);
for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; )
{
const wxUint32 ch = wxDecodeSurrogate(&inBuff);
@@
-1578,7
+1574,7
@@
wxMBConvUTF16straight::FromWChar(char *dst, size_t dstLen,
srcLen = wxWcslen(src) + 1;
size_t outLen = 0;
srcLen = wxWcslen(src) + 1;
size_t outLen = 0;
- wxUint16 *outBuff =
wx_reinterpret_cast(wxUint16 *,
dst);
+ wxUint16 *outBuff =
reinterpret_cast<wxUint16 *>(
dst);
for ( size_t n = 0; n < srcLen; n++ )
{
wxUint16 cc[2];
for ( size_t n = 0; n < srcLen; n++ )
{
wxUint16 cc[2];
@@
-1626,7
+1622,7
@@
wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen,
}
size_t outLen = 0;
}
size_t outLen = 0;
- const wxUint16 *inBuff =
wx_reinterpret_cast(const wxUint16 *,
src);
+ const wxUint16 *inBuff =
reinterpret_cast<const wxUint16 *>(
src);
for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; )
{
wxUint32 ch;
for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; )
{
wxUint32 ch;
@@
-1661,7
+1657,7
@@
wxMBConvUTF16swap::FromWChar(char *dst, size_t dstLen,
srcLen = wxWcslen(src) + 1;
size_t outLen = 0;
srcLen = wxWcslen(src) + 1;
size_t outLen = 0;
- wxUint16 *outBuff =
wx_reinterpret_cast(wxUint16 *,
dst);
+ wxUint16 *outBuff =
reinterpret_cast<wxUint16 *>(
dst);
for ( const wchar_t *srcEnd = src + srcLen; src < srcEnd; src++ )
{
wxUint16 cc[2];
for ( const wchar_t *srcEnd = src + srcLen; src < srcEnd; src++ )
{
wxUint16 cc[2];
@@
-1712,7
+1708,7
@@
size_t wxMBConvUTF32Base::GetLength(const char *src, size_t srcLen)
if ( srcLen == wxNO_LEN )
{
// count the number of bytes in input, including the trailing NULs
if ( srcLen == wxNO_LEN )
{
// count the number of bytes in input, including the trailing NULs
- const wxUint32 *inBuff =
wx_reinterpret_cast(const wxUint32 *,
src);
+ const wxUint32 *inBuff =
reinterpret_cast<const wxUint32 *>(
src);
for ( srcLen = 1; *inBuff++; srcLen++ )
;
for ( srcLen = 1; *inBuff++; srcLen++ )
;
@@
-1743,7
+1739,7
@@
wxMBConvUTF32straight::ToWChar(wchar_t *dst, size_t dstLen,
if ( srcLen == wxNO_LEN )
return wxCONV_FAILED;
if ( srcLen == wxNO_LEN )
return wxCONV_FAILED;
- const wxUint32 *inBuff =
wx_reinterpret_cast(const wxUint32 *,
src);
+ const wxUint32 *inBuff =
reinterpret_cast<const wxUint32 *>(
src);
const size_t inLen = srcLen / BYTES_PER_CHAR;
size_t outLen = 0;
for ( size_t n = 0; n < inLen; n++ )
const size_t inLen = srcLen / BYTES_PER_CHAR;
size_t outLen = 0;
for ( size_t n = 0; n < inLen; n++ )
@@
-1790,7
+1786,7
@@
wxMBConvUTF32straight::FromWChar(char *dst, size_t dstLen,
return srcLen * BYTES_PER_CHAR;
}
return srcLen * BYTES_PER_CHAR;
}
- wxUint32 *outBuff =
wx_reinterpret_cast(wxUint32 *,
dst);
+ wxUint32 *outBuff =
reinterpret_cast<wxUint32 *>(
dst);
size_t outLen = 0;
for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; )
{
size_t outLen = 0;
for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; )
{
@@
-1821,7
+1817,7
@@
wxMBConvUTF32swap::ToWChar(wchar_t *dst, size_t dstLen,
if ( srcLen == wxNO_LEN )
return wxCONV_FAILED;
if ( srcLen == wxNO_LEN )
return wxCONV_FAILED;
- const wxUint32 *inBuff =
wx_reinterpret_cast(const wxUint32 *,
src);
+ const wxUint32 *inBuff =
reinterpret_cast<const wxUint32 *>(
src);
const size_t inLen = srcLen / BYTES_PER_CHAR;
size_t outLen = 0;
for ( size_t n = 0; n < inLen; n++, inBuff++ )
const size_t inLen = srcLen / BYTES_PER_CHAR;
size_t outLen = 0;
for ( size_t n = 0; n < inLen; n++, inBuff++ )
@@
-1868,7
+1864,7
@@
wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen,
return srcLen*BYTES_PER_CHAR;
}
return srcLen*BYTES_PER_CHAR;
}
- wxUint32 *outBuff =
wx_reinterpret_cast(wxUint32 *,
dst);
+ wxUint32 *outBuff =
reinterpret_cast<wxUint32 *>(
dst);
size_t outLen = 0;
for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; )
{
size_t outLen = 0;
for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; )
{
@@
-1953,7
+1949,7
@@
wxMBConvUTF32swap::ToWChar(wchar_t *dst, size_t dstLen,
if ( dstLen < srcLen )
return wxCONV_FAILED;
if ( dstLen < srcLen )
return wxCONV_FAILED;
- const wxUint32 *inBuff =
wx_reinterpret_cast(const wxUint32 *,
src);
+ const wxUint32 *inBuff =
reinterpret_cast<const wxUint32 *>(
src);
for ( size_t n = 0; n < srcLen; n++, inBuff++ )
{
*dst++ = wxUINT32_SWAP_ALWAYS(*inBuff);
for ( size_t n = 0; n < srcLen; n++, inBuff++ )
{
*dst++ = wxUINT32_SWAP_ALWAYS(*inBuff);
@@
-1977,7
+1973,7
@@
wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen,
if ( dstLen < srcLen )
return wxCONV_FAILED;
if ( dstLen < srcLen )
return wxCONV_FAILED;
- wxUint32 *outBuff =
wx_reinterpret_cast(wxUint32 *,
dst);
+ wxUint32 *outBuff =
reinterpret_cast<wxUint32 *>(
dst);
for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ )
{
*outBuff++ = wxUINT32_SWAP_ALWAYS(*src);
for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ )
{
*outBuff++ = wxUINT32_SWAP_ALWAYS(*src);
@@
-2304,7
+2300,7
@@
wxMBConv_iconv::ToWChar(wchar_t *dst, size_t dstLen,
else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
- wchar_t tbuf[
8
];
+ wchar_t tbuf[
256
];
res = 0;
do
res = 0;
do
@@
-2351,13
+2347,12
@@
size_t wxMBConv_iconv::FromWChar(char *dst, size_t dstLen,
if (ms_wcNeedsSwap)
{
// need to copy to temp buffer to switch endianness
if (ms_wcNeedsSwap)
{
// need to copy to temp buffer to switch endianness
- // (doing WC_BSWAP twice on the original buffer won't
help
, as it
+ // (doing WC_BSWAP twice on the original buffer won't
work
, as it
// could be in read-only memory, or be accessed in some other thread)
// could be in read-only memory, or be accessed in some other thread)
- tmpbuf = (wchar_t *)malloc(inbuflen
+ SIZEOF_WCHAR_T
);
+ tmpbuf = (wchar_t *)malloc(inbuflen);
for ( size_t i = 0; i < srcLen; i++ )
tmpbuf[i] = WC_BSWAP(src[i]);
for ( size_t i = 0; i < srcLen; i++ )
tmpbuf[i] = WC_BSWAP(src[i]);
- tmpbuf[srcLen] = L'\0';
src = tmpbuf;
}
src = tmpbuf;
}
@@
-2372,16
+2367,16
@@
size_t wxMBConv_iconv::FromWChar(char *dst, size_t dstLen,
else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
- char tbuf[
1
6];
+ char tbuf[
25
6];
res = 0;
do
{
dst = tbuf;
res = 0;
do
{
dst = tbuf;
- outbuflen =
16
;
+ outbuflen =
WXSIZEOF(tbuf)
;
cres = iconv(w2m, ICONV_CHAR_CAST(&inbuf), &inbuflen, &dst, &outbuflen);
cres = iconv(w2m, ICONV_CHAR_CAST(&inbuf), &inbuflen, &dst, &outbuflen);
- res +=
16
- outbuflen;
+ res +=
WXSIZEOF(tbuf)
- outbuflen;
}
while ((cres == (size_t)-1) && (errno == E2BIG));
}
}
while ((cres == (size_t)-1) && (errno == E2BIG));
}
@@
-3369,6
+3364,11
@@
wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
#define WX_DEFINE_GLOBAL_CONV(klass, name, ctor_args) \
WX_DEFINE_GLOBAL_CONV2(klass, klass, name, ctor_args)
#define WX_DEFINE_GLOBAL_CONV(klass, name, ctor_args) \
WX_DEFINE_GLOBAL_CONV2(klass, klass, name, ctor_args)
+#ifdef __INTELC__
+ // disable warning "variable 'xxx' was declared but never referenced"
+ #pragma warning(disable: 177)
+#endif // Intel C++
+
#ifdef __WINDOWS__
WX_DEFINE_GLOBAL_CONV2(wxMBConv, wxMBConv_win32, wxConvLibc, wxEMPTY_PARAMETER_VALUE);
#else
#ifdef __WINDOWS__
WX_DEFINE_GLOBAL_CONV2(wxMBConv, wxMBConv_win32, wxConvLibc, wxEMPTY_PARAMETER_VALUE);
#else