fixed broken wxCtime() implementation (wrong buffer size count, wrong conversion)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33008 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1520,10 +1520,14 @@ wxStrftime(wxChar *s, size_t maxsize, const wxChar *fmt, const struct tm *tm)
|
|||||||
#ifndef wxCtime
|
#ifndef wxCtime
|
||||||
WXDLLEXPORT wxChar *wxCtime(const time_t *timep)
|
WXDLLEXPORT wxChar *wxCtime(const time_t *timep)
|
||||||
{
|
{
|
||||||
static wxChar buf[128];
|
// normally the string is 26 chars but give one more in case some broken
|
||||||
|
// DOS compiler decides to use "\r\n" instead of "\n" at the end
|
||||||
|
static wxChar buf[27];
|
||||||
|
|
||||||
wxStrncpy( buf, wxConvertMB2WX( ctime( timep ) ), sizeof( buf ) );
|
// ctime() is guaranteed to return a string containing only ASCII
|
||||||
buf[ sizeof( buf ) - 1 ] = _T('\0');
|
// characters, as its format is always the same for any locale
|
||||||
|
wxStrncpy(buf, wxString::FromAscii(ctime(timep)), WXSIZEOF(buf));
|
||||||
|
buf[WXSIZEOF(buf) - 1] = _T('\0');
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user