some sprintf()s replaced with wxString::Printf
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1062 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -220,8 +220,8 @@ bool wxTable::Open(void)
|
|||||||
// Verify that the table exists in the database
|
// Verify that the table exists in the database
|
||||||
if (!pDb->TableExists(tableName))
|
if (!pDb->TableExists(tableName))
|
||||||
{
|
{
|
||||||
char s[128];
|
wxString s;
|
||||||
sprintf(s, "Error opening '%s', table/view does not exist in the database.", tableName);
|
s.Printf("Error opening '%s', table/view does not exist in the database.", tableName);
|
||||||
pDb->LogError(s);
|
pDb->LogError(s);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@@ -694,11 +694,11 @@ bool wxTable::CreateTable(void)
|
|||||||
// For varchars, append the size of the string
|
// For varchars, append the size of the string
|
||||||
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||||
{
|
{
|
||||||
char s[10];
|
|
||||||
// strcat(sqlStmt, "(");
|
// strcat(sqlStmt, "(");
|
||||||
// strcat(sqlStmt, itoa(colDefs[i].SzDataObj, s, 10));
|
// strcat(sqlStmt, itoa(colDefs[i].SzDataObj, s, 10));
|
||||||
// strcat(sqlStmt, ")");
|
// strcat(sqlStmt, ")");
|
||||||
sprintf(s, "(%d)", colDefs[i].SzDataObj);
|
wxString s;
|
||||||
|
s.Printf("(%d)", colDefs[i].SzDataObj);
|
||||||
strcat(sqlStmt, s);
|
strcat(sqlStmt, s);
|
||||||
}
|
}
|
||||||
needComma = TRUE;
|
needComma = TRUE;
|
||||||
@@ -1064,7 +1064,7 @@ void wxTable::GetDeleteStmt(char *pSqlStmt, int typeOfDel, char *pWhereClause)
|
|||||||
void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere)
|
void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere)
|
||||||
{
|
{
|
||||||
bool moreThanOneColumn = FALSE;
|
bool moreThanOneColumn = FALSE;
|
||||||
char colValue[255];
|
wxString colValue;
|
||||||
|
|
||||||
// Loop through the columns building a where clause as you go
|
// Loop through the columns building a where clause as you go
|
||||||
for (int i = 0; i < noCols; i++)
|
for (int i = 0; i < noCols; i++)
|
||||||
@@ -1087,25 +1087,25 @@ void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere)
|
|||||||
switch(colDefs[i].SqlCtype)
|
switch(colDefs[i].SqlCtype)
|
||||||
{
|
{
|
||||||
case SQL_C_CHAR:
|
case SQL_C_CHAR:
|
||||||
sprintf(colValue, "'%s'", (UCHAR FAR *) colDefs[i].PtrDataObj);
|
colValue.Printf("'%s'", (UCHAR FAR *) colDefs[i].PtrDataObj);
|
||||||
break;
|
break;
|
||||||
case SQL_C_SSHORT:
|
case SQL_C_SSHORT:
|
||||||
sprintf(colValue, "%hi", *((SWORD *) colDefs[i].PtrDataObj));
|
colValue.Printf("%hi", *((SWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_USHORT:
|
case SQL_C_USHORT:
|
||||||
sprintf(colValue, "%hu", *((UWORD *) colDefs[i].PtrDataObj));
|
colValue.Printf("%hu", *((UWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_SLONG:
|
case SQL_C_SLONG:
|
||||||
sprintf(colValue, "%li", *((SDWORD *) colDefs[i].PtrDataObj));
|
colValue.Printf("%li", *((SDWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_ULONG:
|
case SQL_C_ULONG:
|
||||||
sprintf(colValue, "%lu", *((UDWORD *) colDefs[i].PtrDataObj));
|
colValue.Printf("%lu", *((UDWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_FLOAT:
|
case SQL_C_FLOAT:
|
||||||
sprintf(colValue, "%.6f", *((SFLOAT *) colDefs[i].PtrDataObj));
|
colValue.Printf("%.6f", *((SFLOAT *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_DOUBLE:
|
case SQL_C_DOUBLE:
|
||||||
sprintf(colValue, "%.6f", *((SDOUBLE *) colDefs[i].PtrDataObj));
|
colValue.Printf("%.6f", *((SDOUBLE *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcat(pWhereClause, colValue);
|
strcat(pWhereClause, colValue);
|
||||||
|
@@ -358,7 +358,6 @@ bool wxDocument::OnSaveModified(void)
|
|||||||
{
|
{
|
||||||
if (IsModified())
|
if (IsModified())
|
||||||
{
|
{
|
||||||
char buf[400];
|
|
||||||
wxString title;
|
wxString title;
|
||||||
GetPrintableName(title);
|
GetPrintableName(title);
|
||||||
|
|
||||||
@@ -368,8 +367,11 @@ bool wxDocument::OnSaveModified(void)
|
|||||||
else
|
else
|
||||||
msgTitle = wxString(_("Warning"));
|
msgTitle = wxString(_("Warning"));
|
||||||
|
|
||||||
sprintf(buf, _("Do you want to save changes to document %s?"), (const char *)title);
|
wxString prompt;
|
||||||
int res = wxMessageBox(buf, msgTitle, wxYES_NO|wxCANCEL|wxICON_QUESTION,
|
prompt.Printf(_("Do you want to save changes to document %s?"),
|
||||||
|
(const char *)title);
|
||||||
|
int res = wxMessageBox(prompt, msgTitle,
|
||||||
|
wxYES_NO|wxCANCEL|wxICON_QUESTION,
|
||||||
GetDocumentWindow());
|
GetDocumentWindow());
|
||||||
if (res == wxNO)
|
if (res == wxNO)
|
||||||
{
|
{
|
||||||
@@ -1003,10 +1005,9 @@ wxDocument *wxDocManager::GetCurrentDocument(void) const
|
|||||||
// Make a default document name
|
// Make a default document name
|
||||||
bool wxDocManager::MakeDefaultName(wxString& name)
|
bool wxDocManager::MakeDefaultName(wxString& name)
|
||||||
{
|
{
|
||||||
char buf[256];
|
name.Printf(_("unnamed%d"), m_defaultDocumentNameCounter);
|
||||||
sprintf(buf, _("unnamed%d"), m_defaultDocumentNameCounter);
|
m_defaultDocumentNameCounter++;
|
||||||
m_defaultDocumentNameCounter ++;
|
|
||||||
name = buf;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,7 +1142,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **WXUNUSED(templat
|
|||||||
{
|
{
|
||||||
// We can only have multiple filters in Windows
|
// We can only have multiple filters in Windows
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
char *descrBuf = new char[1000];
|
char *descrBuf = new char[1000]; // FIXME static buffer
|
||||||
descrBuf[0] = 0;
|
descrBuf[0] = 0;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < noTemplates; i++)
|
for (i = 0; i < noTemplates; i++)
|
||||||
@@ -1788,8 +1789,8 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
|
|||||||
for (i = 0; i < m_fileHistoryN; i++)
|
for (i = 0; i < m_fileHistoryN; i++)
|
||||||
if (m_fileHistory[i])
|
if (m_fileHistory[i])
|
||||||
{
|
{
|
||||||
char buf[400];
|
wxString buf;
|
||||||
sprintf(buf, "&%d %s", i+1, m_fileHistory[i]);
|
buf.Printf("&%d %s", i+1, m_fileHistory[i]);
|
||||||
wxNode* node = m_fileMenus.First();
|
wxNode* node = m_fileMenus.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@@ -1822,14 +1823,14 @@ void wxFileHistory::RemoveMenu(wxMenu *menu)
|
|||||||
void wxFileHistory::Load(wxConfigBase& config)
|
void wxFileHistory::Load(wxConfigBase& config)
|
||||||
{
|
{
|
||||||
m_fileHistoryN = 0;
|
m_fileHistoryN = 0;
|
||||||
char buf[400];
|
wxString buf;
|
||||||
sprintf(buf, "file%d", m_fileHistoryN+1);
|
buf.Printf("file%d", m_fileHistoryN+1);
|
||||||
wxString historyFile("");
|
wxString historyFile;
|
||||||
while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != ""))
|
while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != ""))
|
||||||
{
|
{
|
||||||
m_fileHistory[m_fileHistoryN] = copystring((const char*) historyFile);
|
m_fileHistory[m_fileHistoryN] = copystring((const char*) historyFile);
|
||||||
m_fileHistoryN ++;
|
m_fileHistoryN ++;
|
||||||
sprintf(buf, "file%d", m_fileHistoryN+1);
|
buf.Printf("file%d", m_fileHistoryN+1);
|
||||||
historyFile = "";
|
historyFile = "";
|
||||||
}
|
}
|
||||||
AddFilesToMenu();
|
AddFilesToMenu();
|
||||||
|
@@ -626,9 +626,9 @@ bool wxFileConfig::Write(const wxString& key, const wxString& szValue)
|
|||||||
bool wxFileConfig::Write(const wxString& key, long lValue)
|
bool wxFileConfig::Write(const wxString& key, long lValue)
|
||||||
{
|
{
|
||||||
// ltoa() is not ANSI :-(
|
// ltoa() is not ANSI :-(
|
||||||
char szBuf[40]; // should be good for sizeof(long) <= 16 (128 bits)
|
wxString buf;
|
||||||
sprintf(szBuf, "%ld", lValue);
|
buf.Printf("%ld", lValue);
|
||||||
return Write(key, szBuf);
|
return Write(key, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileConfig::Flush(bool /* bCurrentOnly */)
|
bool wxFileConfig::Flush(bool /* bCurrentOnly */)
|
||||||
|
@@ -80,10 +80,6 @@
|
|||||||
|
|
||||||
#define _MAXPATHLEN 500
|
#define _MAXPATHLEN 500
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern char *wxBuffer;
|
extern char *wxBuffer;
|
||||||
|
|
||||||
void wxPathList::Add (const wxString& path)
|
void wxPathList::Add (const wxString& path)
|
||||||
@@ -955,7 +951,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf)
|
|||||||
#else
|
#else
|
||||||
static short last_temp = 0; // cache last to speed things a bit
|
static short last_temp = 0; // cache last to speed things a bit
|
||||||
// At most 1000 temp files to a process! We use a ring count.
|
// At most 1000 temp files to a process! We use a ring count.
|
||||||
char tmp[100];
|
char tmp[100]; // FIXME static buffer
|
||||||
|
|
||||||
for (short suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000)
|
for (short suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000)
|
||||||
{
|
{
|
||||||
@@ -1029,7 +1025,7 @@ char *wxFindFirstFile(const char *spec, int flags)
|
|||||||
char *wxFindNextFile(void)
|
char *wxFindNextFile(void)
|
||||||
{
|
{
|
||||||
#ifndef __VMS__
|
#ifndef __VMS__
|
||||||
static char buf[400];
|
static char buf[400]; // FIXME static buffer
|
||||||
|
|
||||||
/* MATTHEW: [2] Don't crash if we read too many times */
|
/* MATTHEW: [2] Don't crash if we read too many times */
|
||||||
if (!wxDirStream)
|
if (!wxDirStream)
|
||||||
|
@@ -97,12 +97,14 @@ void wxHTTP::SendHeaders()
|
|||||||
{
|
{
|
||||||
wxNode *head = m_headers.First();
|
wxNode *head = m_headers.First();
|
||||||
|
|
||||||
while (head) {
|
while (head)
|
||||||
|
{
|
||||||
wxString *str = (wxString *)head->Data();
|
wxString *str = (wxString *)head->Data();
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
sprintf(buf, "%s: %s\n\r", head->GetKeyString(), str->GetData());
|
wxString buf;
|
||||||
Write(buf, strlen(buf));
|
buf.Printf("%s: %s\n\r", head->GetKeyString(), str->GetData());
|
||||||
|
|
||||||
|
Write(buf, buf.Len());
|
||||||
|
|
||||||
head = head->Next();
|
head = head->Next();
|
||||||
}
|
}
|
||||||
|
@@ -169,7 +169,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPostScriptModule, wxModule)
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
|
IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPostScriptDC::wxPostScriptDC ()
|
wxPostScriptDC::wxPostScriptDC ()
|
||||||
|
@@ -941,16 +941,6 @@ int wxString::Printf(const char *pszFormat, ...)
|
|||||||
|
|
||||||
int wxString::PrintfV(const char* pszFormat, va_list argptr)
|
int wxString::PrintfV(const char* pszFormat, va_list argptr)
|
||||||
{
|
{
|
||||||
#if defined(__BORLANDC__) || defined(__GNUWIN32__)
|
|
||||||
static char s_szScratch[1024];
|
|
||||||
|
|
||||||
int iLen = vsprintf(s_szScratch, pszFormat, argptr);
|
|
||||||
AllocBeforeWrite(iLen);
|
|
||||||
strcpy(m_pchData, s_szScratch);
|
|
||||||
|
|
||||||
return iLen;
|
|
||||||
#else
|
|
||||||
|
|
||||||
// static buffer to avoid dynamic memory allocation each time
|
// static buffer to avoid dynamic memory allocation each time
|
||||||
static char s_szScratch[1024];
|
static char s_szScratch[1024];
|
||||||
|
|
||||||
@@ -986,7 +976,6 @@ int wxString::PrintfV(const char* pszFormat, va_list argptr)
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
return iLen;
|
return iLen;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -45,8 +45,6 @@ extern "C" void LexFromString(char *buf);
|
|||||||
wxExprDatabase *thewxExprDatabase = NULL;
|
wxExprDatabase *thewxExprDatabase = NULL;
|
||||||
wxExprErrorHandler currentwxExprErrorHandler;
|
wxExprErrorHandler currentwxExprErrorHandler;
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase, wxList)
|
|
||||||
|
|
||||||
wxExpr::wxExpr(const wxString& functor)
|
wxExpr::wxExpr(const wxString& functor)
|
||||||
{
|
{
|
||||||
type = wxExprList;
|
type = wxExprList;
|
||||||
|
Reference in New Issue
Block a user