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