From: Ove Kaaven Date: Mon, 12 Apr 1999 22:31:12 +0000 (+0000) Subject: It now compiles all these files without warnings in Unicode mode. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/509201463dbd3bce8aff762c664b111a8f2c3412 It now compiles all these files without warnings in Unicode mode. (at least It Works For Me(tm)) I will respond to any complaints when I wake up for another workday (any complaints will prove whether Vadim was right in that it's bound to break things) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 872e8e4b6e..3355392580 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -1136,8 +1136,8 @@ void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) void wxPageSetupDialogData::CalculateIdFromPaperSize() { wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), - "wxThePrintPaperDatabase should not be NULL. " - "Do not create global print dialog data objects." ); + _T("wxThePrintPaperDatabase should not be NULL. " + "Do not create global print dialog data objects.") ); wxSize sz = GetPaperSize(); @@ -1152,8 +1152,8 @@ void wxPageSetupDialogData::CalculateIdFromPaperSize() void wxPageSetupDialogData::CalculatePaperSizeFromId() { wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), - "wxThePrintPaperDatabase should not be NULL. " - "Do not create global print dialog data objects." ); + _T("wxThePrintPaperDatabase should not be NULL. " + "Do not create global print dialog data objects.") ); wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); diff --git a/src/common/config.cpp b/src/common/config.cpp index 4a0935b93c..b9aefd7202 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -124,7 +124,7 @@ bool wxConfigBase::Read(const wxString& key, double* val) const wxString str; if (Read(key, & str)) { - *val = atof(str); + *val = wxAtof(str); return TRUE; } else @@ -187,7 +187,7 @@ bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const bool wxConfigBase::Write(const wxString& key, double val) { wxString str; - str.Printf("%f", val); + str.Printf(_T("%f"), val); return Write(key, str); } @@ -314,7 +314,7 @@ wxString wxExpandEnvVars(const wxString& str) wxString strVarName(str.c_str() + n + 1, m - n - 1); - const char *pszValue = getenv(strVarName); + const wxChar *pszValue = wxGetenv(strVarName); if ( pszValue != NULL ) { strResult += pszValue; } @@ -332,7 +332,7 @@ wxString wxExpandEnvVars(const wxString& str) if ( bracket != Bracket_None ) { if ( m == str.Len() || str[m] != (char)bracket ) { wxLogWarning(_("Environment variables expansion failed: " - "missing '%c' at position %d in '%s'."), + "missing '%c' at position %d in '%s'."), (char)bracket, m + 1, str.c_str()); } else { diff --git a/src/common/date.cpp b/src/common/date.cpp index e3e808ee5c..c8cd9dda8b 100644 --- a/src/common/date.cpp +++ b/src/common/date.cpp @@ -48,13 +48,14 @@ #define ABBR_LENGTH 3 -static const char *dayname[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" +static const wxChar *dayname[] = { + _T("Sunday"), _T("Monday"), _T("Tuesday"), _T("Wednesday"), + _T("Thursday"), _T("Friday"), _T("Saturday") }; -static const char *mname[] = { - "January", "February", "March", "April", "May", "June", "July", "August", - "September", "October", "November", "December" +static const wxChar *mname[] = { + _T("January"), _T("February"), _T("March"), _T("April"), _T("May"), _T("June"), + _T("July"), _T("August"), _T("September"), _T("October"), _T("November"), _T("December") }; static int GauDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -93,20 +94,20 @@ wxDate::wxDate (const wxString& dat) { DisplayFormat=wxMDY; DisplayOptions='\0'; - if (strcmp(dat, "TODAY") == 0 || strcmp(dat, "today") == 0) + if (wxStrcmp(dat, _T("TODAY")) == 0 || wxStrcmp(dat, _T("today")) == 0) { // Sets the current date Set(); } else { - char buf[100]; - strcpy(buf, (char *) (const char *)dat); + wxChar buf[100]; + wxStrcpy(buf, WXSTRINGCAST dat); - char *token = strtok(buf,"/-"); - month = atoi(token); - day = atoi(strtok((char *) NULL,"/-")); - year = atoi(strtok((char *) NULL," ")); + wxChar *save_ptr, *token = wxStrtok(buf,_T("/-"),&save_ptr); + month = wxAtoi(token); + day = wxAtoi(wxStrtok((wxChar *) NULL,_T("/-"),&save_ptr)); + year = wxAtoi(wxStrtok((wxChar *) NULL,_T(" "),&save_ptr)); } mdy_to_julian (); @@ -136,20 +137,20 @@ void wxDate::operator = (const wxString& dat) { DisplayFormat=wxMDY; DisplayOptions='\0'; - if (strcmp(dat, "TODAY") == 0 || strcmp(dat, "today") == 0) + if (wxStrcmp(dat, _T("TODAY")) == 0 || wxStrcmp(dat, _T("today")) == 0) { // Sets the current date Set(); } else { - char buf[100]; - strcpy(buf, (char *)(const char *)dat); + wxChar buf[100]; + wxStrcpy(buf, WXSTRINGCAST dat); - char *token = strtok(buf,"/-"); - month = atoi(token); - day = atoi(strtok((char *) NULL,"/-")); - year = atoi(strtok((char *) NULL," ")); + wxChar *save_ptr, *token = wxStrtok(buf,_T("/-"),&save_ptr); + month = wxAtoi(token); + day = wxAtoi(wxStrtok((wxChar *) NULL,_T("/-"),&save_ptr)); + year = wxAtoi(wxStrtok((wxChar *) NULL,_T(" "),&save_ptr)); } mdy_to_julian (); @@ -281,7 +282,7 @@ bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2) ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt) { - return os << (const char *) dt.FormatDate(); + return os << (const wxChar *) dt.FormatDate(); } ////////////////////////////////////////////////////////////// @@ -345,72 +346,72 @@ wxString wxDate::FormatDate (int type) const if (actualType == -1) actualType = DisplayFormat; - char buf[40]; + wxChar buf[40]; memset( buf, '\0', sizeof(buf) ); switch ( actualType ) { case wxDAY: if ( (day_of_week < 1) || (day_of_week > 7) ) - strcpy(buf, _("invalid day")); + wxStrcpy(buf, _("invalid day")); else - strncpy( buf, _(dayname[day_of_week-1]), - (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); + wxStrncpy( buf, wxGetTranslation(dayname[day_of_week-1]), + (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); return wxString(buf); case wxMONTH: if ( (month < 1) || (month > 12) ) - strcpy(buf, _("invalid month")); + wxStrcpy(buf, _("invalid month")); else - strncpy( buf, _(mname[month-1]), - (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); + wxStrncpy( buf, wxGetTranslation(mname[month-1]), + (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); return wxString(buf); case wxFULL: if ( (month < 1) || (month > 12) || (day_of_week < 0) || (day_of_week > 7) ) { - strcpy(buf, _("invalid date")); + wxStrcpy(buf, _("invalid date")); return wxString(buf); } - strncpy( buf, _(dayname[day_of_week-1]), - (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); - strcat( buf, ", "); - strncat( buf, _(mname[month-1]), - (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); - strcat( buf, " "); - sprintf( buf+strlen(buf), "%d, %d", day, abs(year) ); + wxStrncpy( buf, wxGetTranslation(dayname[day_of_week-1]), + (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); + wxStrcat( buf, _T(", ")); + wxStrncat( buf, wxGetTranslation(mname[month-1]), + (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); + wxStrcat( buf, _T(" ")); + wxSprintf( buf+wxStrlen(buf), _T("%d, %d"), day, abs(year) ); if (year < 0) - strcat(buf,_(" B.C.")); + wxStrcat(buf,_(" B.C.")); return wxString(buf); case wxEUROPEAN: if ( (month < 1) || (month > 12) || (day_of_week < 0) || (day_of_week > 7) ) { - strcpy(buf, _("invalid date")); + wxStrcpy(buf, _("invalid date")); return wxString(buf); } - sprintf(buf,"%d ", day); - strncat(buf, _(mname[month-1]), + wxSprintf(buf,_T("%d "), day); + wxStrncat(buf, wxGetTranslation(mname[month-1]), (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9); - sprintf( buf+strlen(buf), " %d", abs(year) ); + wxSprintf( buf+wxStrlen(buf), _T(" %d"), abs(year) ); if (year < 0) - strcat(buf, _(" B.C.")); + wxStrcat(buf, _(" B.C.")); return wxString(buf); case wxMDY: default: if (day==0 || month==0 || year==0) - strcpy(buf, _("invalid date")); + wxStrcpy(buf, _("invalid date")); else - sprintf( buf+strlen(buf), "%1d/%1d/%02d", month, day, - (DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899) - ? (abs(year) - (abs(year) / 100 * 100)) - : (abs(year)) ); + wxSprintf( buf+wxStrlen(buf), _T("%1d/%1d/%02d"), month, day, + (DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899) + ? (abs(year) - (abs(year) / 100 * 100)) + : (abs(year)) ); return wxString(buf); } - return wxString(""); + return wxString(_T("")); } void wxDate::SetFormat( int format ) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index deb4271735..4d94a0abcf 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -39,7 +39,7 @@ #include "wx/utils.h" #include "wx/app.h" #include "wx/dc.h" - #include "wx/dialog.h" +#include "wx/dialog.h" #include "wx/menu.h" #include "wx/list.h" #include "wx/filedlg.h" @@ -92,7 +92,7 @@ // function prototypes // ---------------------------------------------------------------------------- -static inline wxString FindExtension(const char *path); +static inline wxString FindExtension(const wxChar *path); // ============================================================================ // implementation @@ -102,7 +102,7 @@ static inline wxString FindExtension(const char *path); // local functions // ---------------------------------------------------------------------------- -static wxString FindExtension(const char *path) +static wxString FindExtension(const wxChar *path) { wxString ext; wxSplitPath(path, NULL, NULL, &ext); @@ -279,7 +279,7 @@ bool wxDocument::OnSaveDocument(const wxString& file) else msgTitle = wxString(_("File error")); - ofstream store(file); + ofstream store(file.fn_str()); if (store.fail() || store.bad()) { (void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION, @@ -310,7 +310,7 @@ bool wxDocument::OnOpenDocument(const wxString& file) else msgTitle = wxString(_("File error")); - ifstream store(file); + ifstream store(file.fn_str()); if (store.fail() || store.bad()) { (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION, @@ -402,7 +402,7 @@ bool wxDocument::OnSaveModified() wxString prompt; prompt.Printf(_("Do you want to save changes to document %s?"), - (const char *)title); + (const wxChar *)title); int res = wxMessageBox(prompt, msgTitle, wxYES_NO|wxCANCEL|wxICON_QUESTION, GetDocumentWindow()); @@ -1139,7 +1139,7 @@ wxDocTemplate *wxDocManager::FindTemplateForPath(const wxString& path) for (i = 0; i < m_templates.Number(); i++) { wxDocTemplate *temp = (wxDocTemplate *)m_templates.Nth(i)->Data(); - if (strcmp(temp->GetDefaultExtension(), theExt) == 0) + if (wxStrcmp(temp->GetDefaultExtension(), theExt) == 0) { theTemplate = temp; break; @@ -1170,18 +1170,18 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, { // add a '|' to separate this filter from the previous one if ( !descrBuf.IsEmpty() ) - descrBuf << '|'; + descrBuf << _T('|'); descrBuf << templates[i]->GetDescription() - << " (" << templates[i]->GetFileFilter() << ") |" + << _T(" (") << templates[i]->GetFileFilter() << _T(") |") << templates[i]->GetFileFilter(); } } #else - wxString descrBuf = "*.*"; + wxString descrBuf = _T("*.*"); #endif - wxString pathTmp = wxFileSelector(_("Select a file"), "", "", "", + wxString pathTmp = wxFileSelector(_("Select a file"), _T(""), _T(""), _T(""), descrBuf, 0, wxTheApp->GetTopWindow()); if (!pathTmp.IsEmpty()) @@ -1229,8 +1229,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, int noTemplates) { - char **strings = new char *[noTemplates]; - char **data = new char *[noTemplates]; + wxChar **strings = new wxChar *[noTemplates]; + wxChar **data = new wxChar *[noTemplates]; int i; int n = 0; for (i = 0; i < noTemplates; i++) @@ -1238,7 +1238,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, if (templates[i]->IsVisible()) { strings[n] = WXSTRINGCAST templates[i]->m_description; - data[n] = (char *)templates[i]; + data[n] = (wxChar *)templates[i]; n ++; } } @@ -1266,8 +1266,8 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, int noTemplates) { - char **strings = new char *[noTemplates]; - char **data = new char *[noTemplates]; + wxChar **strings = new wxChar *[noTemplates]; + wxChar **data = new wxChar *[noTemplates]; int i; int n = 0; for (i = 0; i < noTemplates; i++) @@ -1275,7 +1275,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, if (templates[i]->IsVisible() && (templates[i]->GetViewName() != "")) { strings[n] = WXSTRINGCAST templates[i]->m_viewTypeName; - data[n] = (char *)templates[i]; + data[n] = (wxChar *)templates[i]; n ++; } } @@ -1763,7 +1763,7 @@ wxFileHistory::wxFileHistory(int maxFiles) { m_fileMaxFiles = maxFiles; m_fileHistoryN = 0; - m_fileHistory = new char *[m_fileMaxFiles]; + m_fileHistory = new wxChar *[m_fileMaxFiles]; } wxFileHistory::~wxFileHistory() @@ -1792,7 +1792,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file) if (m_fileHistoryN == m_fileMaxFiles) { delete[] m_fileHistory[m_fileMaxFiles-1]; - m_fileHistory[m_fileMaxFiles-1] = (char *) NULL; + m_fileHistory[m_fileMaxFiles-1] = (wxChar *) NULL; } if (m_fileHistoryN < m_fileMaxFiles) { @@ -1818,7 +1818,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file) if (m_fileHistory[i]) { wxString buf; - buf.Printf("&%d %s", i+1, m_fileHistory[i]); + buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]); wxNode* node = m_fileMenus.First(); while (node) { @@ -1853,13 +1853,13 @@ void wxFileHistory::Load(wxConfigBase& config) { m_fileHistoryN = 0; wxString buf; - buf.Printf("file%d", m_fileHistoryN+1); + buf.Printf(_T("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_fileHistory[m_fileHistoryN] = copystring((const wxChar*) historyFile); m_fileHistoryN ++; - buf.Printf("file%d", m_fileHistoryN+1); + buf.Printf(_T("file%d"), m_fileHistoryN+1); historyFile = ""; } AddFilesToMenu(); @@ -1871,7 +1871,7 @@ void wxFileHistory::Save(wxConfigBase& config) for (i = 0; i < m_fileHistoryN; i++) { wxString buf; - buf.Printf("file%d", i+1); + buf.Printf(_T("file%d"), i+1); config.Write(buf, wxString(m_fileHistory[i])); } } @@ -1892,7 +1892,7 @@ void wxFileHistory::AddFilesToMenu() if (m_fileHistory[i]) { wxString buf; - buf.Printf("&%d %s", i+1, m_fileHistory[i]); + buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]); menu->Append(wxID_FILE1+i, buf); } } @@ -1912,7 +1912,7 @@ void wxFileHistory::AddFilesToMenu(wxMenu* menu) if (m_fileHistory[i]) { wxString buf; - buf.Printf("&%d %s", i+1, m_fileHistory[i]); + buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]); menu->Append(wxID_FILE1+i, buf); } } @@ -1929,7 +1929,7 @@ bool wxTransferFileToStream(const wxString& filename, ostream& stream) FILE *fd1; int ch; - if ((fd1 = fopen (WXSTRINGCAST filename, "rb")) == NULL) + if ((fd1 = fopen (filename.fn_str(), "rb")) == NULL) return FALSE; while ((ch = getc (fd1)) != EOF) @@ -1944,7 +1944,7 @@ bool wxTransferStreamToFile(istream& stream, const wxString& filename) FILE *fd1; int ch; - if ((fd1 = fopen (WXSTRINGCAST filename, "wb")) == NULL) + if ((fd1 = fopen (filename.fn_str(), "wb")) == NULL) { return FALSE; } diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 80f7006759..07d31a52ae 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -250,7 +250,7 @@ void wxBaseArray::Add(long lItem, CMPFUNC fnCompare) // add item at the given position void wxBaseArray::Insert(long lItem, size_t nIndex) { - wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArray::Insert" ); + wxCHECK_RET( nIndex <= m_nCount, _T("bad index in wxArray::Insert") ); Grow(); @@ -263,7 +263,7 @@ void wxBaseArray::Insert(long lItem, size_t nIndex) // removes item from array (by index) void wxBaseArray::Remove(size_t nIndex) { - wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArray::Remove" ); + wxCHECK_RET( nIndex <= m_nCount, _T("bad index in wxArray::Remove") ); memmove(&m_pItems[nIndex], &m_pItems[nIndex + 1], (m_nCount - nIndex - 1)*sizeof(long)); @@ -276,7 +276,7 @@ void wxBaseArray::Remove(long lItem) int iIndex = Index(lItem); wxCHECK_RET( iIndex != wxNOT_FOUND, - "removing inexistent item in wxArray::Remove" ); + _T("removing inexistent item in wxArray::Remove") ); Remove((size_t)iIndex); } diff --git a/src/common/dynlib.cpp b/src/common/dynlib.cpp index cf218301c2..b4a60768fb 100644 --- a/src/common/dynlib.cpp +++ b/src/common/dynlib.cpp @@ -40,17 +40,17 @@ // ---------------------------------------------------------------------------- #if defined(HAVE_DLOPEN) - #define wxDllOpen(lib) dlopen(lib, RTLD_LAZY) - #define wxDllGetSymbol(handle, name) dlsym(handle, (char *)name) + #define wxDllOpen(lib) dlopen(lib.fn_str(), RTLD_LAZY) + #define wxDllGetSymbol(handle, name) dlsym(handle, name.mb_str()) #define wxDllClose dlclose #elif defined(HAVE_SHL_LOAD) - #define wxDllOpen(lib) shl_load(lib, BIND_DEFERRED, 0) + #define wxDllOpen(lib) shl_load(lib.fn_str(), BIND_DEFERRED, 0) #define wxDllClose shl_unload - static inline void *wxDllGetSymbol(shl_t handle, const char *name) + static inline void *wxDllGetSymbol(shl_t handle, const wxString& name) { void *sym; - if ( shl_findsym(&handle, name, TYPE_UNDEFINED, &sym) == 0 ) + if ( shl_findsym(&handle, name.mb_str(), TYPE_UNDEFINED, &sym) == 0 ) return sym; else return (void *)0; @@ -179,9 +179,7 @@ void *wxLibrary::GetSymbol(const wxString& symbname) symbol = (void *)symAddress ; } #else - // VZ: hmm... why is WXSTRINGCAST needed? if it's really modified, we - // should make a copy of it - symbol = wxDllGetSymbol(m_handle, WXSTRINGCAST symbname); + symbol = wxDllGetSymbol(m_handle, symbname); #endif if ( !symbol ) @@ -234,7 +232,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name) const char *envLibPath = getenv("LD_LIBRARY_PATH"); if ( envLibPath ) libPath << ':' << envLibPath; - wxStringTokenizer tokenizer(libPath, ':'); + wxStringTokenizer tokenizer(libPath, _T(':')); while ( tokenizer.HasMoreToken() ) { wxString fullname(tokenizer.NextToken()); diff --git a/src/common/event.cpp b/src/common/event.cpp index c64449a3a5..904178bc7b 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -171,7 +171,7 @@ bool wxMouseEvent::ButtonDClick(int but) const case 3: return RightDClick(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDClick"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDClick")); } return FALSE; @@ -192,7 +192,7 @@ bool wxMouseEvent::ButtonDown(int but) const case 3: return RightDown(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDown"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDown")); } return FALSE; @@ -212,7 +212,7 @@ bool wxMouseEvent::ButtonUp(int but) const case 3: return RightUp(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonUp"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonUp")); } return FALSE; @@ -231,7 +231,7 @@ bool wxMouseEvent::Button(int but) const case 3: return (RightDown() || RightUp() || RightDClick()); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::Button"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::Button")); } return FALSE; @@ -249,7 +249,7 @@ bool wxMouseEvent::ButtonIsDown(int but) const case 3: return RightIsDown(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonIsDown"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonIsDown")); } return FALSE; @@ -511,7 +511,7 @@ void wxEvtHandler::Connect( int id, int lastId, bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) { wxCHECK_MSG( m_dynamicEvents, FALSE, - "caller should check that we have dynamic events" ); + _T("caller should check that we have dynamic events") ); int commandId = event.GetId(); diff --git a/src/common/file.cpp b/src/common/file.cpp index 366a3842d7..5cf0152d8a 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -156,16 +156,23 @@ // ---------------------------------------------------------------------------- // static functions // ---------------------------------------------------------------------------- -bool wxFile::Exists(const char *name) +bool wxFile::Exists(const wxChar *name) { struct stat st; +#if wxUSE_UNICODE && wxMBFILES + wxCharBuffer fname = wxConv_file.cWC2MB(name); + return !access(fname, 0) && + !stat(MBSTRINGCAST fname, &st) && + (st.st_mode & S_IFREG); +#else return !access(name, 0) && - !stat((char*) name, &st) && + !stat((wxChar*) name, &st) && (st.st_mode & S_IFREG); +#endif } -bool wxFile::Access(const char *name, OpenMode mode) +bool wxFile::Access(const wxChar *name, OpenMode mode) { int how = 0; @@ -179,10 +186,10 @@ bool wxFile::Access(const char *name, OpenMode mode) break; default: - wxFAIL_MSG("bad wxFile::Access mode parameter."); + wxFAIL_MSG(_T("bad wxFile::Access mode parameter.")); } - return access(name, how) == 0; + return access(wxFNCONV(name), how) == 0; } // ---------------------------------------------------------------------------- @@ -190,7 +197,7 @@ bool wxFile::Access(const char *name, OpenMode mode) // ---------------------------------------------------------------------------- // ctors -wxFile::wxFile(const char *szFileName, OpenMode mode) +wxFile::wxFile(const wxChar *szFileName, OpenMode mode) { m_fd = fd_invalid; m_error = FALSE; @@ -205,11 +212,11 @@ wxFile::~wxFile() } // create the file, fail if it already exists and bOverwrite -bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode) +bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) { // if bOverwrite we create a new file or truncate the existing one, // otherwise we only create the new file and fail if it already exists - int fd = open(szFileName, + int fd = open(wxFNCONV(szFileName), O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL) ACCESS(accessMode)); @@ -224,7 +231,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode) } // open the file -bool wxFile::Open(const char *szFileName, OpenMode mode, int accessMode) +bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) { int flags = O_BINARY; @@ -246,7 +253,7 @@ bool wxFile::Open(const char *szFileName, OpenMode mode, int accessMode) break; } - int fd = open(szFileName, flags ACCESS(accessMode)); + int fd = open(wxFNCONV(szFileName), flags ACCESS(accessMode)); if ( fd == -1 ) { wxLogSysError(_("can't open file '%s'"), szFileName); @@ -474,21 +481,21 @@ bool wxTempFile::Open(const wxString& strName) // different partitions for example). Unfortunately, the only standard // (POSIX) temp file creation function tmpnam() can't do it. #if defined(__UNIX__) || defined(__WXSTUBS__)|| defined( __WXMAC__ ) - static const char *szMktempSuffix = "XXXXXX"; + static const wxChar *szMktempSuffix = _T("XXXXXX"); m_strTemp << strName << szMktempSuffix; - mktemp((char *)m_strTemp.c_str()); // will do because length doesn't change + mktemp(MBSTRINGCAST m_strTemp.mb_str()); // will do because length doesn't change #else // Windows wxString strPath; wxSplitPath(strName, &strPath, NULL, NULL); if ( strPath.IsEmpty() ) - strPath = '.'; // GetTempFileName will fail if we give it empty string + strPath = _T('.'); // GetTempFileName will fail if we give it empty string #ifdef __WIN32__ - if ( !GetTempFileName(strPath, "wx_",0, m_strTemp.GetWriteBuf(MAX_PATH)) ) + if ( !GetTempFileName(strPath, _T("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) ) #else // Not sure why MSVC++ 1.5 header defines first param as BYTE - bug? - if ( !GetTempFileName((BYTE) (const char*) strPath, "wx_",0, m_strTemp.GetWriteBuf(MAX_PATH)) ) + if ( !GetTempFileName((BYTE) (const wxChar*) strPath, _T("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) ) #endif - wxLogLastError("GetTempFileName"); + wxLogLastError(_T("GetTempFileName")); m_strTemp.UngetWriteBuf(); #endif // Windows/Unix @@ -496,7 +503,7 @@ bool wxTempFile::Open(const wxString& strName) #ifdef __UNIX__ // create the file with the same mode as the original one under Unix struct stat st; - if ( stat(strName, &st) == 0 ) + if ( stat(strName.fn_str(), &st) == 0 ) { // this assumes that only lower bits of st_mode contain the access // rights, but it's true for at least all Unices which have S_IXXXX() @@ -506,7 +513,7 @@ bool wxTempFile::Open(const wxString& strName) } else { - wxLogLastError("stat"); + wxLogLastError(_T("stat")); } // we want to create the file with exactly the same access rights as the @@ -538,12 +545,12 @@ bool wxTempFile::Commit() { m_file.Close(); - if ( wxFile::Exists(m_strName) && remove(m_strName) != 0 ) { + if ( wxFile::Exists(m_strName) && remove(m_strName.fn_str()) != 0 ) { wxLogSysError(_("can't remove file '%s'"), m_strName.c_str()); return FALSE; } - if ( rename(m_strTemp, m_strName) != 0 ) { + if ( rename(m_strTemp.fn_str(), m_strName.fn_str()) != 0 ) { wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str()); return FALSE; } @@ -554,6 +561,6 @@ bool wxTempFile::Commit() void wxTempFile::Discard() { m_file.Close(); - if ( remove(m_strTemp) != 0 ) + if ( remove(m_strTemp.fn_str()) != 0 ) wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str()); } diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index cc1567b4ee..4b44249b6e 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -90,17 +90,17 @@ wxString wxFileConfig::GetGlobalDir() wxString strDir; #ifdef __UNIX__ - strDir = "/etc/"; + strDir = _T("/etc/"); #elif defined(__WXSTUBS__) - wxASSERT_MSG( FALSE, "TODO" ) ; + wxASSERT_MSG( FALSE, _T("TODO") ) ; #elif defined(__WXMAC__) - wxASSERT_MSG( FALSE, "TODO" ) ; + wxASSERT_MSG( FALSE, _T("TODO") ) ; #else // Windows - char szWinDir[MAX_PATH]; + wxChar szWinDir[MAX_PATH]; ::GetWindowsDirectory(szWinDir, MAX_PATH); strDir = szWinDir; - strDir << '\\'; + strDir << _T('\\'); #endif // Unix/Windows return strDir; @@ -113,42 +113,42 @@ wxString wxFileConfig::GetLocalDir() wxGetHomeDir(&strDir); #ifdef __UNIX__ - if (strDir.Last() != '/') strDir << '/'; + if (strDir.Last() != _T('/')) strDir << _T('/'); #else - if (strDir.Last() != '\\') strDir << '\\'; + if (strDir.Last() != _T('\\')) strDir << _T('\\'); #endif return strDir; } -wxString wxFileConfig::GetGlobalFileName(const char *szFile) +wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile) { wxString str = GetGlobalDir(); str << szFile; - if ( strchr(szFile, '.') == NULL ) + if ( wxStrchr(szFile, _T('.')) == NULL ) #ifdef __UNIX__ - str << ".conf"; + str << _T(".conf"); #else // Windows - str << ".ini"; + str << _T(".ini"); #endif // UNIX/Win return str; } -wxString wxFileConfig::GetLocalFileName(const char *szFile) +wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) { wxString str = GetLocalDir(); #ifdef __UNIX__ - str << '.'; + str << _T('.'); #endif str << szFile; #ifdef __WXMSW__ - if ( strchr(szFile, '.') == NULL ) - str << ".ini"; + if ( wxStrchr(szFile, _T('.')) == NULL ) + str << _T(".ini"); #endif return str; @@ -265,8 +265,8 @@ wxFileConfig::~wxFileConfig() void wxFileConfig::Parse(wxTextFile& file, bool bLocal) { - const char *pStart; - const char *pEnd; + const wxChar *pStart; + const wxChar *pEnd; wxString strLine; size_t nLineCount = file.GetLineCount(); @@ -278,22 +278,22 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) LineListAppend(strLine); // skip leading spaces - for ( pStart = strLine; isspace(*pStart); pStart++ ) + for ( pStart = strLine; wxIsspace(*pStart); pStart++ ) ; // skip blank/comment lines - if ( *pStart == '\0'|| *pStart == ';' || *pStart == '#' ) + if ( *pStart == _T('\0')|| *pStart == _T(';') || *pStart == _T('#') ) continue; - if ( *pStart == '[' ) { // a new group + if ( *pStart == _T('[') ) { // a new group pEnd = pStart; - while ( *++pEnd != ']' ) { - if ( *pEnd == '\n' || *pEnd == '\0' ) + while ( *++pEnd != _T(']') ) { + if ( *pEnd == _T('\n') || *pEnd == _T('\0') ) break; } - if ( *pEnd != ']' ) { + if ( *pEnd != _T(']') ) { wxLogError(_("file '%s': unexpected character %c at line %d."), file.GetName(), *pEnd, n + 1); continue; // skip this line @@ -313,15 +313,15 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) // check that there is nothing except comments left on this line bool bCont = TRUE; - while ( *++pEnd != '\0' && bCont ) { + while ( *++pEnd != _T('\0') && bCont ) { switch ( *pEnd ) { - case '#': - case ';': + case _T('#'): + case _T(';'): bCont = FALSE; break; - case ' ': - case '\t': + case _T(' '): + case _T('\t'): // ignore whitespace ('\n' impossible here) break; @@ -334,9 +334,9 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) } } else { // a key - const char *pEnd = pStart; - while ( !isspace(*pEnd) ) { - if ( *pEnd == '\\' ) { + const wxChar *pEnd = pStart; + while ( !wxIsspace(*pEnd) ) { + if ( *pEnd == _T('\\') ) { // next character may be space or not - still take it because it's // quoted pEnd++; @@ -351,7 +351,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) while ( isspace(*pEnd) ) pEnd++; - if ( *pEnd++ != '=' ) { + if ( *pEnd++ != _T('=') ) { wxLogError(_("file '%s', line %d: '=' expected."), file.GetName(), n + 1); } @@ -389,7 +389,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) } // skip whitespace - while ( isspace(*pEnd) ) + while ( wxIsspace(*pEnd) ) pEnd++; pEntry->SetValue(FilterInValue(pEnd), FALSE /* read from file */); @@ -574,7 +574,7 @@ bool wxFileConfig::Read(const wxString& key, long *pl) const { wxString str; if ( Read(key, & str) ) { - *pl = atol(str); + *pl = wxAtol(str); return TRUE; } else { @@ -589,7 +589,7 @@ bool wxFileConfig::Write(const wxString& key, const wxString& szValue) wxString strName = path.Name(); if ( strName.IsEmpty() ) { // setting the value of a group is an error - wxASSERT_MSG( IsEmpty(szValue), "can't set value of a group!" ); + wxASSERT_MSG( wxIsEmpty(szValue), _T("can't set value of a group!") ); // ... except if it's empty in which case it's a way to force it's creation m_pCurrentGroup->SetDirty(); @@ -623,7 +623,7 @@ bool wxFileConfig::Write(const wxString& key, long lValue) { // ltoa() is not ANSI :-( wxString buf; - buf.Printf("%ld", lValue); + buf.Printf(_T("%ld"), lValue); return Write(key, buf); } @@ -708,7 +708,7 @@ bool wxFileConfig::DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso) if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) { if ( m_pCurrentGroup != m_pRootGroup ) { ConfigGroup *pGroup = m_pCurrentGroup; - SetPath(".."); // changes m_pCurrentGroup! + SetPath(_T("..")); // changes m_pCurrentGroup! m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name()); } //else: never delete the root group @@ -728,12 +728,10 @@ bool wxFileConfig::DeleteAll() { CleanUp(); - const char *szFile = m_strLocalFile; + if ( remove(m_strLocalFile.fn_str()) == -1 ) + wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str()); - if ( remove(szFile) == -1 ) - wxLogSysError(_("can't delete user configuration file '%s'"), szFile); - - m_strLocalFile = m_strGlobalFile = ""; + m_strLocalFile = m_strGlobalFile = _T(""); Init(); return TRUE; @@ -905,7 +903,7 @@ LineList *ConfigGroup::GetGroupLine() // this group wasn't present in local config file, add it now if ( pParent != NULL ) { wxString strFullName; - strFullName << "[" << (GetFullName().c_str() + 1) << "]"; // +1: no '/' + strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/' m_pLine = m_pConfig->LineListInsert(strFullName, pParent->GetLastGroupLine()); pParent->SetLastGroup(this); // we're surely after all the others @@ -963,7 +961,7 @@ void ConfigGroup::Rename(const wxString& newName) LineList *line = GetGroupLine(); wxString strFullName; - strFullName << "[" << (GetFullName().c_str() + 1) << "]"; // +1: no '/' + strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/' line->SetText(strFullName); SetDirty(); @@ -974,7 +972,7 @@ wxString ConfigGroup::GetFullName() const if ( Parent() ) return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name(); else - return ""; + return _T(""); } // ---------------------------------------------------------------------------- @@ -983,7 +981,7 @@ wxString ConfigGroup::GetFullName() const // use binary search because the array is sorted ConfigEntry * -ConfigGroup::FindEntry(const char *szName) const +ConfigGroup::FindEntry(const wxChar *szName) const { size_t i, lo = 0, @@ -996,9 +994,9 @@ ConfigGroup::FindEntry(const char *szName) const pEntry = m_aEntries[i]; #if wxCONFIG_CASE_SENSITIVE - res = strcmp(pEntry->Name(), szName); + res = wxStrcmp(pEntry->Name(), szName); #else - res = Stricmp(pEntry->Name(), szName); + res = wxStricmp(pEntry->Name(), szName); #endif if ( res > 0 ) @@ -1013,7 +1011,7 @@ ConfigGroup::FindEntry(const char *szName) const } ConfigGroup * -ConfigGroup::FindSubgroup(const char *szName) const +ConfigGroup::FindSubgroup(const wxChar *szName) const { size_t i, lo = 0, @@ -1026,9 +1024,9 @@ ConfigGroup::FindSubgroup(const char *szName) const pGroup = m_aSubgroups[i]; #if wxCONFIG_CASE_SENSITIVE - res = strcmp(pGroup->Name(), szName); + res = wxStrcmp(pGroup->Name(), szName); #else - res = Stricmp(pGroup->Name(), szName); + res = wxStricmp(pGroup->Name(), szName); #endif if ( res > 0 ) @@ -1081,7 +1079,7 @@ ConfigGroup::AddSubgroup(const wxString& strName) delete several of them. */ -bool ConfigGroup::DeleteSubgroupByName(const char *szName) +bool ConfigGroup::DeleteSubgroupByName(const wxChar *szName) { return DeleteSubgroup(FindSubgroup(szName)); } @@ -1153,7 +1151,7 @@ bool ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup) return TRUE; } -bool ConfigGroup::DeleteEntry(const char *szName) +bool ConfigGroup::DeleteEntry(const wxChar *szName) { ConfigEntry *pEntry = FindEntry(szName); wxCHECK( pEntry != NULL, FALSE ); // deleting non existing item? @@ -1272,7 +1270,7 @@ void ConfigEntry::SetValue(const wxString& strValue, bool bUser) if ( bUser ) { wxString strVal = FilterOutValue(strValue); wxString strLine; - strLine << m_strName << " = " << strVal; + strLine << m_strName << _T(" = ") << strVal; if ( m_pLine != NULL ) { // entry was read from the local config file, just modify the line @@ -1309,9 +1307,9 @@ int CompareEntries(ConfigEntry *p1, ConfigEntry *p2) { #if wxCONFIG_CASE_SENSITIVE - return strcmp(p1->Name(), p2->Name()); + return wxStrcmp(p1->Name(), p2->Name()); #else - return Stricmp(p1->Name(), p2->Name()); + return wxStricmp(p1->Name(), p2->Name()); #endif } @@ -1319,9 +1317,9 @@ int CompareGroups(ConfigGroup *p1, ConfigGroup *p2) { #if wxCONFIG_CASE_SENSITIVE - return strcmp(p1->Name(), p2->Name()); + return wxStrcmp(p1->Name(), p2->Name()); #else - return Stricmp(p1->Name(), p2->Name()); + return wxStricmp(p1->Name(), p2->Name()); #endif } @@ -1338,31 +1336,31 @@ static wxString FilterInValue(const wxString& str) bool bQuoted = !str.IsEmpty() && str[0] == '"'; for ( size_t n = bQuoted ? 1 : 0; n < str.Len(); n++ ) { - if ( str[n] == '\\' ) { + if ( str[n] == _T('\\') ) { switch ( str[++n] ) { - case 'n': - strResult += '\n'; + case _T('n'): + strResult += _T('\n'); break; - case 'r': - strResult += '\r'; + case _T('r'): + strResult += _T('\r'); break; - case 't': - strResult += '\t'; + case _T('t'): + strResult += _T('\t'); break; - case '\\': - strResult += '\\'; + case _T('\\'): + strResult += _T('\\'); break; - case '"': - strResult += '"'; + case _T('"'): + strResult += _T('"'); break; } } else { - if ( str[n] != '"' || !bQuoted ) + if ( str[n] != _T('"') || !bQuoted ) strResult += str[n]; else if ( n != str.Len() - 1 ) { wxLogWarning(_("unexpected \" at position %d in '%s'."), @@ -1385,33 +1383,33 @@ static wxString FilterOutValue(const wxString& str) strResult.Alloc(str.Len()); // quoting is necessary to preserve spaces in the beginning of the string - bool bQuote = isspace(str[0]) || str[0] == '"'; + bool bQuote = wxIsspace(str[0]) || str[0] == _T('"'); if ( bQuote ) - strResult += '"'; + strResult += _T('"'); - char c; + wxChar c; for ( size_t n = 0; n < str.Len(); n++ ) { switch ( str[n] ) { - case '\n': - c = 'n'; + case _T('\n'): + c = _T('n'); break; - case '\r': - c = 'r'; + case _T('\r'): + c = _T('r'); break; - case '\t': - c = 't'; + case _T('\t'): + c = _T('t'); break; - case '\\': - c = '\\'; + case _T('\\'): + c = _T('\\'); break; - case '"': + case _T('"'): if ( bQuote ) { - c = '"'; + c = _T('"'); break; } //else: fall through @@ -1422,11 +1420,11 @@ static wxString FilterOutValue(const wxString& str) } // we get here only for special characters - strResult << '\\' << c; + strResult << _T('\\') << c; } if ( bQuote ) - strResult += '"'; + strResult += _T('"'); return strResult; } @@ -1437,8 +1435,8 @@ static wxString FilterInEntryName(const wxString& str) wxString strResult; strResult.Alloc(str.Len()); - for ( const char *pc = str.c_str(); *pc != '\0'; pc++ ) { - if ( *pc == '\\' ) + for ( const wxChar *pc = str.c_str(); *pc != '\0'; pc++ ) { + if ( *pc == _T('\\') ) pc++; strResult += *pc; @@ -1453,15 +1451,15 @@ static wxString FilterOutEntryName(const wxString& str) wxString strResult; strResult.Alloc(str.Len()); - for ( const char *pc = str.c_str(); *pc != '\0'; pc++ ) { - char c = *pc; + for ( const wxChar *pc = str.c_str(); *pc != _T('\0'); pc++ ) { + wxChar c = *pc; // we explicitly allow some of "safe" chars and 8bit ASCII characters // which will probably never have special meaning // NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR // should *not* be quoted - if ( !isalnum(c) && !strchr("@_/-!.*%", c) && ((c & 0x80) == 0) ) - strResult += '\\'; + if ( !wxIsalnum(c) && !wxStrchr(_T("@_/-!.*%"), c) && ((c & 0x80) == 0) ) + strResult += _T('\\'); strResult += c; } diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index e3c2d2410f..fd63c60c7e 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -98,11 +98,11 @@ #define _MAXPATHLEN 500 -extern char *wxBuffer; +extern wxChar *wxBuffer; #ifdef __WXMAC__ - extern char gwxMacFileName[] ; - extern char gwxMacFileName2[] ; - extern char gwxMacFileName3[] ; + extern wxChar gwxMacFileName[] ; + extern wxChar gwxMacFileName2[] ; + extern wxChar gwxMacFileName3[] ; #endif #if !USE_SHARED_LIBRARIES @@ -111,31 +111,31 @@ extern char *wxBuffer; void wxPathList::Add (const wxString& path) { - wxStringList::Add ((char *)(const char *)path); + wxStringList::Add (WXSTRINGCAST path); } // Add paths e.g. from the PATH environment variable void wxPathList::AddEnvList (const wxString& envVariable) { - static const char PATH_TOKS[] = + static const wxChar PATH_TOKS[] = #ifdef __WINDOWS__ - " ;"; // Don't seperate with colon in DOS (used for drive) + _T(" ;"); // Don't seperate with colon in DOS (used for drive) #else - " :;"; + _T(" :;"); #endif - char *val = getenv (WXSTRINGCAST envVariable); + wxChar *val = wxGetenv (WXSTRINGCAST envVariable); if (val && *val) { - char *s = copystring (val); - char *token = strtok (s, PATH_TOKS); + wxChar *s = copystring (val); + wxChar *save_ptr, *token = wxStrtok (s, PATH_TOKS, &save_ptr); if (token) { Add (copystring (token)); while (token) { - if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL) + if ((token = wxStrtok ((wxChar *) NULL, PATH_TOKS, &save_ptr)) != NULL) Add (wxString(token)); } } @@ -160,7 +160,7 @@ bool wxPathList::Member (const wxString& path) { for (wxNode * node = First (); node != NULL; node = node->Next ()) { - wxString path2((char *) node->Data ()); + wxString path2((wxChar *) node->Data ()); if ( #if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__) // Case INDEPENDENT @@ -180,20 +180,20 @@ wxString wxPathList::FindValidPath (const wxString& file) if (wxFileExists (wxExpandPath(wxBuffer, file))) return wxString(wxBuffer); - char buf[_MAXPATHLEN]; - strcpy(buf, wxBuffer); + wxChar buf[_MAXPATHLEN]; + wxStrcpy(buf, wxBuffer); - char *filename = (char*) NULL; /* shut up buggy egcs warning */ - filename = IsAbsolutePath (buf) ? wxFileNameFromPath (buf) : (char *)buf; + wxChar *filename = (wxChar*) NULL; /* shut up buggy egcs warning */ + filename = IsAbsolutePath (buf) ? wxFileNameFromPath (buf) : (wxChar *)buf; for (wxNode * node = First (); node; node = node->Next ()) { - char *path = (char *) node->Data (); - strcpy (wxBuffer, path); - char ch = wxBuffer[strlen(wxBuffer)-1]; - if (ch != '\\' && ch != '/') - strcat (wxBuffer, "/"); - strcat (wxBuffer, filename); + wxChar *path = (wxChar *) node->Data (); + wxStrcpy (wxBuffer, path); + wxChar ch = wxBuffer[wxStrlen(wxBuffer)-1]; + if (ch != _T('\\') && ch != _T('/')) + wxStrcat (wxBuffer, _T("/")); + wxStrcat (wxBuffer, filename); #ifdef __WINDOWS__ Unix2DosFilename (wxBuffer); #endif @@ -203,7 +203,7 @@ wxString wxPathList::FindValidPath (const wxString& file) } } // for() - return wxString(""); // Not found + return wxString(_T("")); // Not found } wxString wxPathList::FindAbsoluteValidPath (const wxString& file) @@ -213,22 +213,22 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) return f; else { - char buf[500]; + wxChar buf[500]; wxGetWorkingDirectory(buf, 499); - int len = (int)strlen(buf); - char lastCh = 0; + int len = (int)wxStrlen(buf); + wxChar lastCh = 0; if (len > 0) lastCh = buf[len-1]; - if (lastCh != '/' && lastCh != '\\') + if (lastCh != _T('/') && lastCh != _T('\\')) { #ifdef __WINDOWS__ - strcat(buf, "\\"); + wxStrcat(buf, _T("\\")); #else - strcat(buf, "/"); + wxStrcat(buf, _T("/")); #endif } - strcat(buf, (const char *)f); - strcpy(wxBuffer, buf); + wxStrcat(buf, (const wxChar *)f); + wxStrcpy(wxBuffer, buf); return wxString(wxBuffer); } } @@ -243,9 +243,9 @@ wxFileExists (const wxString& filename) return TRUE; #elif defined(__WXMAC__) struct stat stbuf; - strcpy( gwxMacFileName , filename ) ; + wxStrcpy( gwxMacFileName , filename ) ; wxUnix2MacFilename( gwxMacFileName ) ; - if (gwxMacFileName && stat ((char *)(const char *)gwxMacFileName, &stbuf) == 0) + if (gwxMacFileName && stat (WXSTRINGCAST gwxMacFileName, &stbuf) == 0) return TRUE; return FALSE ; #else @@ -256,7 +256,7 @@ wxFileExists (const wxString& filename) struct stat stbuf; #endif - if ((filename != "") && stat ((char *)(const char *)filename, &stbuf) == 0) + if ((filename != _T("")) && stat (FNSTRINGCAST filename.fn_str(), &stbuf) == 0) return TRUE; return FALSE; #endif @@ -279,13 +279,13 @@ wxIsAbsolutePath (const wxString& filename) { if (filename != "") { - if (filename[0] == '/' + if (filename[0] == _T('/') #ifdef __VMS__ - || (filename[0] == '[' && filename[1] != '.') + || (filename[0] == _T('[') && filename[1] != _T('.')) #endif #ifdef __WINDOWS__ /* MSDOS */ - || filename[0] == '\\' || (isalpha (filename[0]) && filename[1] == ':') + || filename[0] == _T('\\') || (wxIsalpha (filename[0]) && filename[1] == _T(':')) #endif ) return TRUE; @@ -299,13 +299,13 @@ wxIsAbsolutePath (const wxString& filename) * */ -void wxStripExtension(char *buffer) +void wxStripExtension(wxChar *buffer) { - int len = strlen(buffer); + int len = wxStrlen(buffer); int i = len-1; while (i > 0) { - if (buffer[i] == '.') + if (buffer[i] == _T('.')) { buffer[i] = 0; break; @@ -320,7 +320,7 @@ void wxStripExtension(wxString& buffer) size_t i = len-1; while (i > 0) { - if (buffer.GetChar(i) == '.') + if (buffer.GetChar(i) == _T('.')) { buffer = buffer.Left(i); break; @@ -330,18 +330,18 @@ void wxStripExtension(wxString& buffer) } // Destructive removal of /./ and /../ stuff -char *wxRealPath (char *path) +wxChar *wxRealPath (wxChar *path) { #ifdef __WXMSW__ - static const char SEP = '\\'; + static const wxChar SEP = _T('\\'); Unix2DosFilename(path); #else - static const char SEP = '/'; + static const wxChar SEP = _T('/'); #endif if (path[0] && path[1]) { /* MATTHEW: special case "/./x" */ - char *p; - if (path[2] == SEP && path[1] == '.') + wxChar *p; + if (path[2] == SEP && path[1] == _T('.')) p = &path[0]; else p = &path[2]; @@ -349,32 +349,32 @@ char *wxRealPath (char *path) { if (*p == SEP) { - if (p[1] == '.' && p[2] == '.' && (p[3] == SEP || p[3] == '\0')) + if (p[1] == _T('.') && p[2] == _T('.') && (p[3] == SEP || p[3] == _T('\0'))) { - char *q; + wxChar *q; for (q = p - 1; q >= path && *q != SEP; q--); - if (q[0] == SEP && (q[1] != '.' || q[2] != '.' || q[3] != SEP) + if (q[0] == SEP && (q[1] != _T('.') || q[2] != _T('.') || q[3] != SEP) && (q - 1 <= path || q[-1] != SEP)) { - strcpy (q, p + 3); - if (path[0] == '\0') + wxStrcpy (q, p + 3); + if (path[0] == _T('\0')) { path[0] = SEP; - path[1] = '\0'; + path[1] = _T('\0'); } #ifdef __WXMSW__ /* Check that path[2] is NULL! */ - else if (path[1] == ':' && !path[2]) + else if (path[1] == _T(':') && !path[2]) { path[2] = SEP; - path[3] = '\0'; + path[3] = _T('\0'); } #endif p = q - 1; } } - else if (p[1] == '.' && (p[2] == SEP || p[2] == '\0')) - strcpy (p, p + 2); + else if (p[1] == _T('.') && (p[2] == SEP || p[2] == _T('\0'))) + wxStrcpy (p, p + 2); } } } @@ -382,24 +382,24 @@ char *wxRealPath (char *path) } // Must be destroyed -char *wxCopyAbsolutePath(const wxString& filename) +wxChar *wxCopyAbsolutePath(const wxString& filename) { - if (filename == "") - return (char *) NULL; + if (filename == _T("")) + return (wxChar *) NULL; if (! IsAbsolutePath(wxExpandPath(wxBuffer, filename))) { - char buf[_MAXPATHLEN]; - buf[0] = '\0'; + wxChar buf[_MAXPATHLEN]; + buf[0] = _T('\0'); wxGetWorkingDirectory(buf, WXSIZEOF(buf)); - char ch = buf[strlen(buf) - 1]; + wxChar ch = buf[wxStrlen(buf) - 1]; #ifdef __WXMSW__ - if (ch != '\\' && ch != '/') - strcat(buf, "\\"); + if (ch != _T('\\') && ch != _T('/')) + wxStrcat(buf, _T("\\")); #else - if (ch != '/') - strcat(buf, "/"); + if (ch != _T('/')) + wxStrcat(buf, _T("/")); #endif - strcat(buf, wxBuffer); + wxStrcat(buf, wxBuffer); return copystring( wxRealPath(buf) ); } return copystring( wxBuffer ); @@ -428,52 +428,52 @@ char *wxCopyAbsolutePath(const wxString& filename) /* input name in name, pathname output to buf. */ -char *wxExpandPath(char *buf, const char *name) +wxChar *wxExpandPath(wxChar *buf, const wxChar *name) { - register char *d, *s, *nm; - char lnm[_MAXPATHLEN]; + register wxChar *d, *s, *nm; + wxChar lnm[_MAXPATHLEN]; int q; // Some compilers don't like this line. -// const char trimchars[] = "\n \t"; +// const wxChar trimchars[] = _T("\n \t"); - char trimchars[4]; - trimchars[0] = '\n'; - trimchars[1] = ' '; - trimchars[2] = '\t'; + wxChar trimchars[4]; + trimchars[0] = _T('\n'); + trimchars[1] = _T(' '); + trimchars[2] = _T('\t'); trimchars[3] = 0; #ifdef __WXMSW__ - const char SEP = '\\'; + const wxChar SEP = _T('\\'); #else - const char SEP = '/'; + const wxChar SEP = _T('/'); #endif - buf[0] = '\0'; - if (name == NULL || *name == '\0') + buf[0] = _T('\0'); + if (name == NULL || *name == _T('\0')) return buf; nm = copystring(name); // Make a scratch copy - char *nm_tmp = nm; + wxChar *nm_tmp = nm; /* Skip leading whitespace and cr */ - while (strchr((char *)trimchars, *nm) != NULL) + while (wxStrchr((wxChar *)trimchars, *nm) != NULL) nm++; /* And strip off trailing whitespace and cr */ - s = nm + (q = strlen(nm)) - 1; - while (q-- && strchr((char *)trimchars, *s) != NULL) - *s = '\0'; + s = nm + (q = wxStrlen(nm)) - 1; + while (q-- && wxStrchr((wxChar *)trimchars, *s) != NULL) + *s = _T('\0'); s = nm; d = lnm; #ifdef __WXMSW__ q = FALSE; #else - q = nm[0] == '\\' && nm[1] == '~'; + q = nm[0] == _T('\\') && nm[1] == _T('~'); #endif /* Expand inline environment variables */ while ((*d++ = *s)) { #ifndef __WXMSW__ - if (*s == '\\') { + if (*s == _T('\\')) { if ((*(d - 1) = *++s)) { s++; continue; @@ -482,21 +482,21 @@ char *wxExpandPath(char *buf, const char *name) } else #endif #ifdef __WXMSW__ - if (*s++ == '$' && (*s == '{' || *s == ')')) + if (*s++ == _T('$') && (*s == _T('{') || *s == _T(')'))) #else - if (*s++ == '$') + if (*s++ == _T('$')) #endif { - register char *start = d; - register int braces = (*s == '{' || *s == '('); - register char *value; + register wxChar *start = d; + register int braces = (*s == _T('{') || *s == _T('(')); + register wxChar *value; while ((*d++ = *s)) - if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') ) + if (braces ? (*s == _T('}') || *s == _T(')')) : !(wxIsalnum(*s) || *s == _T('_')) ) break; else s++; *--d = 0; - value = getenv(braces ? start + 1 : start); + value = wxGetenv(braces ? start + 1 : start); if (value) { for ((d = start - 1); (*d++ = *value++);); d--; @@ -508,20 +508,20 @@ char *wxExpandPath(char *buf, const char *name) /* Expand ~ and ~user */ nm = lnm; - s = ""; - if (nm[0] == '~' && !q) + s = _T(""); + if (nm[0] == _T('~') && !q) { /* prefix ~ */ if (nm[1] == SEP || nm[1] == 0) { /* ~/filename */ - if ((s = wxGetUserHome("")) != NULL) { + if ((s = wxGetUserHome(_T(""))) != NULL) { if (*++nm) nm++; } } else { /* ~user/filename */ - register char *nnm; - register char *home; + register wxChar *nnm; + register wxChar *home; for (s = nm; *s && *s != SEP; s++); int was_sep; /* MATTHEW: Was there a separator, or NULL? */ was_sep = (*s == SEP); @@ -530,7 +530,7 @@ char *wxExpandPath(char *buf, const char *name) if ((home = wxGetUserHome(wxString(nm + 1))) == NULL) { if (was_sep) /* replace only if it was there: */ *s = SEP; - s = ""; + s = _T(""); } else { nm = nnm; s = home; @@ -541,7 +541,7 @@ char *wxExpandPath(char *buf, const char *name) d = buf; if (s && *s) { /* MATTHEW: s could be NULL if user '~' didn't exist */ /* Copy home dir */ - while ('\0' != (*d++ = *s++)) + while (_T('\0') != (*d++ = *s++)) /* loop */; // Handle root home if (d - 1 > buf && *(d - 2) != SEP) @@ -563,49 +563,49 @@ char *wxExpandPath(char *buf, const char *name) The call wxExpandPath can convert these back! */ -char * +wxChar * wxContractPath (const wxString& filename, const wxString& envname, const wxString& user) { - static char dest[_MAXPATHLEN]; + static wxChar dest[_MAXPATHLEN]; - if (filename == "") - return (char *) NULL; + if (filename == _T("")) + return (wxChar *) NULL; - strcpy (dest, WXSTRINGCAST filename); + wxStrcpy (dest, WXSTRINGCAST filename); #ifdef __WXMSW__ Unix2DosFilename(dest); #endif // Handle environment - char *val = (char *) NULL; - char *tcp = (char *) NULL; - if (envname != WXSTRINGCAST NULL && (val = getenv (WXSTRINGCAST envname)) != NULL && - (tcp = strstr (dest, val)) != NULL) + wxChar *val = (wxChar *) NULL; + wxChar *tcp = (wxChar *) NULL; + if (envname != WXSTRINGCAST NULL && (val = wxGetenv (WXSTRINGCAST envname)) != NULL && + (tcp = wxStrstr (dest, val)) != NULL) { - strcpy (wxBuffer, tcp + strlen (val)); - *tcp++ = '$'; - *tcp++ = '{'; - strcpy (tcp, WXSTRINGCAST envname); - strcat (tcp, "}"); - strcat (tcp, wxBuffer); + wxStrcpy (wxBuffer, tcp + wxStrlen (val)); + *tcp++ = _T('$'); + *tcp++ = _T('{'); + wxStrcpy (tcp, WXSTRINGCAST envname); + wxStrcat (tcp, _T("}")); + wxStrcat (tcp, wxBuffer); } // Handle User's home (ignore root homes!) size_t len = 0; if ((val = wxGetUserHome (user)) != NULL && - (len = strlen(val)) > 2 && - strncmp(dest, val, len) == 0) + (len = wxStrlen(val)) > 2 && + wxStrncmp(dest, val, len) == 0) { - strcpy(wxBuffer, "~"); - if (user != "") - strcat(wxBuffer, (const char*) user); + wxStrcpy(wxBuffer, _T("~")); + if (user != _T("")) + wxStrcat(wxBuffer, (const wxChar*) user); #ifdef __WXMSW__ // strcat(wxBuffer, "\\"); #else // strcat(wxBuffer, "/"); #endif - strcat(wxBuffer, dest + len); - strcpy (dest, wxBuffer); + wxStrcat(wxBuffer, dest + len); + wxStrcpy (dest, wxBuffer); } return dest; @@ -613,25 +613,25 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin // Return just the filename, not the path // (basename) -char *wxFileNameFromPath (char *path) +wxChar *wxFileNameFromPath (wxChar *path) { if (path) { - register char *tcp; + register wxChar *tcp; - tcp = path + strlen (path); + tcp = path + wxStrlen (path); while (--tcp >= path) { - if (*tcp == '/' || *tcp == '\\' + if (*tcp == _T('/') || *tcp == _T('\\') #ifdef __VMS__ - || *tcp == ':' || *tcp == ']') + || *tcp == _T(':') || *tcp == _T(']')) #else ) #endif return tcp + 1; } /* while */ #ifdef __WXMSW__ - if (isalpha (*path) && *(path + 1) == ':') + if (wxIsalpha (*path) && *(path + 1) == _T(':')) return path + 2; #endif } @@ -640,25 +640,25 @@ char *wxFileNameFromPath (char *path) wxString wxFileNameFromPath (const wxString& path1) { - if (path1 != "") + if (path1 != _T("")) { - char *path = WXSTRINGCAST path1 ; - register char *tcp; + wxChar *path = WXSTRINGCAST path1 ; + register wxChar *tcp; - tcp = path + strlen (path); + tcp = path + wxStrlen (path); while (--tcp >= path) { - if (*tcp == '/' || *tcp == '\\' + if (*tcp == _T('/') || *tcp == _T('\\') #ifdef __VMS__ - || *tcp == ':' || *tcp == ']') + || *tcp == _T(':') || *tcp == _T(']')) #else ) #endif return wxString(tcp + 1); } /* while */ #ifdef __WXMSW__ - if (isalpha (*path) && *(path + 1) == ':') + if (wxIsalpha (*path) && *(path + 1) == _T(':')) return wxString(path + 2); #endif } @@ -668,17 +668,17 @@ wxString wxFileNameFromPath (const wxString& path1) } // Return just the directory, or NULL if no directory -char * -wxPathOnly (char *path) +wxChar * +wxPathOnly (wxChar *path) { if (path && *path) { - static char buf[_MAXPATHLEN]; + static wxChar buf[_MAXPATHLEN]; // Local copy - strcpy (buf, path); + wxStrcpy (buf, path); - int l = strlen(path); + int l = wxStrlen(path); bool done = FALSE; int i = l - 1; @@ -687,7 +687,7 @@ wxPathOnly (char *path) while (!done && i > -1) { // ] is for VMS - if (path[i] == '/' || path[i] == '\\' || path[i] == ']') + if (path[i] == _T('/') || path[i] == _T('\\') || path[i] == _T(']')) { done = TRUE; #ifdef __VMS__ @@ -703,17 +703,17 @@ wxPathOnly (char *path) #ifdef __WXMSW__ // Try Drive specifier - if (isalpha (buf[0]) && buf[1] == ':') + if (wxIsalpha (buf[0]) && buf[1] == _T(':')) { // A:junk --> A:. (since A:.\junk Not A:\junk) - buf[2] = '.'; - buf[3] = '\0'; + buf[2] = _T('.'); + buf[3] = _T('\0'); return buf; } #endif } - return (char *) NULL; + return (wxChar *) NULL; } // Return just the directory, or NULL if no directory @@ -721,10 +721,10 @@ wxString wxPathOnly (const wxString& path) { if (path != "") { - char buf[_MAXPATHLEN]; + wxChar buf[_MAXPATHLEN]; // Local copy - strcpy (buf, WXSTRINGCAST path); + wxStrcpy (buf, WXSTRINGCAST path); int l = path.Length(); bool done = FALSE; @@ -735,7 +735,7 @@ wxString wxPathOnly (const wxString& path) while (!done && i > -1) { // ] is for VMS - if (path[i] == '/' || path[i] == '\\' || path[i] == ']') + if (path[i] == _T('/') || path[i] == _T('\\') || path[i] == _T(']')) { done = TRUE; #ifdef __VMS__ @@ -751,17 +751,17 @@ wxString wxPathOnly (const wxString& path) #ifdef __WXMSW__ // Try Drive specifier - if (isalpha (buf[0]) && buf[1] == ':') + if (wxIsalpha (buf[0]) && buf[1] == _T(':')) { // A:junk --> A:. (since A:.\junk Not A:\junk) - buf[2] = '.'; - buf[3] = '\0'; + buf[2] = _T('.'); + buf[3] = _T('\0'); return wxString(buf); } #endif } - return wxString(""); + return wxString(_T("")); } // Utility for converting delimiters in DOS filenames to UNIX style @@ -770,50 +770,50 @@ wxString wxPathOnly (const wxString& path) #ifdef __WXMAC__ void -wxMac2UnixFilename (char *s) +wxMac2UnixFilename (wxChar *s) { if (s) { - memmove( s+1 , s ,strlen( s ) + 1) ; - if ( *s == ':' ) - *s = '.' ; + memmove( s+1 , s ,(strlen( s ) + 1)*sizeof(wxChar)) ; + if ( *s == _T(':') ) + *s = _T('.') ; else - *s = '/' ; + *s = _T('/') ; while (*s) { - if (*s == ':') - *s = '/'; + if (*s == _T(':')) + *s = _T('/'); else - *s = tolower(*s); // Case INDEPENDENT + *s = wxTolower(*s); // Case INDEPENDENT s++; } } } void -wxUnix2MacFilename (char *s) +wxUnix2MacFilename (wxChar *s) { if (s) { - if ( *s == '.' ) + if ( *s == _T('.') ) { // relative path , since it goes on with slash which is translated to a : - memmove( s , s+1 ,strlen( s ) ) ; + memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ; } - else if ( *s == '/' ) + else if ( *s == _T('/') ) { // absolute path -> on mac just start with the drive name - memmove( s , s+1 ,strlen( s ) ) ; + memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ; } else { - wxASSERT_MSG( 1 , "unkown path beginning" ) ; + wxASSERT_MSG( 1 , _T("unknown path beginning") ) ; } while (*s) { - if (*s == '/' || *s == '\\') - *s = ':'; + if (*s == _T('/') || *s == _T('\\')) + *s = _T(':'); s++ ; } @@ -821,16 +821,16 @@ wxUnix2MacFilename (char *s) } #endif void -wxDos2UnixFilename (char *s) +wxDos2UnixFilename (wxChar *s) { if (s) while (*s) { - if (*s == '\\') - *s = '/'; + if (*s == _T('\\')) + *s = _T('/'); #ifdef __WXMSW__ else - *s = tolower(*s); // Case INDEPENDENT + *s = wxTolower(*s); // Case INDEPENDENT #endif s++; } @@ -838,9 +838,9 @@ wxDos2UnixFilename (char *s) void #ifdef __WXMSW__ -wxUnix2DosFilename (char *s) +wxUnix2DosFilename (wxChar *s) #else -wxUnix2DosFilename (char *WXUNUSED(s)) +wxUnix2DosFilename (wxChar *WXUNUSED(s)) #endif { // Yes, I really mean this to happen under DOS only! JACS @@ -848,8 +848,8 @@ wxUnix2DosFilename (char *WXUNUSED(s)) if (s) while (*s) { - if (*s == '/') - *s = '\\'; + if (*s == _T('/')) + *s = _T('\\'); s++; } #endif @@ -859,27 +859,27 @@ wxUnix2DosFilename (char *WXUNUSED(s)) bool wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3) { - char *outfile = wxGetTempFileName("cat"); + wxChar *outfile = wxGetTempFileName("cat"); FILE *fp1 = (FILE *) NULL; FILE *fp2 = (FILE *) NULL; FILE *fp3 = (FILE *) NULL; // Open the inputs and outputs #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; + wxStrcpy( gwxMacFileName , file1 ) ; wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; + wxStrcpy( gwxMacFileName2 , file2) ; wxUnix2MacFilename( gwxMacFileName2 ) ; - strcpy( gwxMacFileName3 , outfile) ; + wxStrcpy( gwxMacFileName3 , outfile) ; wxUnix2MacFilename( gwxMacFileName3 ) ; if ((fp1 = fopen (gwxMacFileName, "rb")) == NULL || (fp2 = fopen (gwxMacFileName2, "rb")) == NULL || (fp3 = fopen (gwxMacFileName3, "wb")) == NULL) #else - if ((fp1 = fopen (WXSTRINGCAST file1, "rb")) == NULL || - (fp2 = fopen (WXSTRINGCAST file2, "rb")) == NULL || - (fp3 = fopen (outfile, "wb")) == NULL) + if ((fp1 = fopen (FNSTRINGCAST file1.fn_str(), "rb")) == NULL || + (fp2 = fopen (FNSTRINGCAST file2.fn_str(), "rb")) == NULL || + (fp3 = fopen (wxFNCONV(outfile), "wb")) == NULL) #endif { if (fp1) @@ -915,18 +915,18 @@ wxCopyFile (const wxString& file1, const wxString& file2) int ch; #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; + wxStrcpy( gwxMacFileName , file1 ) ; wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; + wxStrcpy( gwxMacFileName2 , file2) ; wxUnix2MacFilename( gwxMacFileName2 ) ; if ((fd1 = fopen (gwxMacFileName, "rb")) == NULL) return FALSE; if ((fd2 = fopen (gwxMacFileName2, "wb")) == NULL) #else - if ((fd1 = fopen (WXSTRINGCAST file1, "rb")) == NULL) + if ((fd1 = fopen (FNSTRINGCAST file1.fn_str(), "rb")) == NULL) return FALSE; - if ((fd2 = fopen (WXSTRINGCAST file2, "wb")) == NULL) + if ((fd2 = fopen (FNSTRINGCAST file2.fn_str(), "wb")) == NULL) #endif { fclose (fd1); @@ -945,16 +945,16 @@ bool wxRenameFile (const wxString& file1, const wxString& file2) { #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; + wxStrcpy( gwxMacFileName , file1 ) ; wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; + wxStrcpy( gwxMacFileName2 , file2) ; wxUnix2MacFilename( gwxMacFileName2 ) ; if (0 == rename (gwxMacFileName, gwxMacFileName2)) return TRUE; #else // Normal system call - if (0 == rename (WXSTRINGCAST file1, WXSTRINGCAST file2)) + if (0 == rename (FNSTRINGCAST file1.fn_str(), FNSTRINGCAST file2.fn_str())) return TRUE; #endif // Try to copy @@ -969,13 +969,13 @@ wxRenameFile (const wxString& file1, const wxString& file2) bool wxRemoveFile(const wxString& file) { #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) - int flag = remove(WXSTRINGCAST file); + int flag = remove(FNSTRINGCAST file.fn_str()); #elif defined( __WXMAC__ ) - strcpy( gwxMacFileName , file ) ; + wxStrcpy( gwxMacFileName , file ) ; wxUnix2MacFilename( gwxMacFileName ) ; int flag = unlink(gwxMacFileName); #else - int flag = unlink(WXSTRINGCAST file); + int flag = unlink(FNSTRINGCAST file.fn_str()); #endif return (flag == 0) ; } @@ -983,19 +983,19 @@ bool wxRemoveFile(const wxString& file) bool wxMkdir(const wxString& dir, int perm) { #if defined( __WXMAC__ ) - strcpy( gwxMacFileName , dir ) ; + wxStrcpy( gwxMacFileName , dir ) ; wxUnix2MacFilename( gwxMacFileName ) ; - const char *dirname = gwxMacFileName; + const wxChar *dirname = gwxMacFileName; #else // !Mac - const char *dirname = dir.c_str(); + const wxChar *dirname = dir.c_str(); #endif // Mac/!Mac // assume mkdir() has 2 args on non Windows platforms and on Windows too // for the GNU compiler #if !defined(__WXMSW__) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) - if ( mkdir(dirname, perm) != 0 ) + if ( mkdir(wxFNCONV(dirname), perm) != 0 ) #else // MSW - if ( mkdir(dirname) != 0 ) + if ( mkdir(wxFNCONV(dirname)) != 0 ) #endif // !MSW/MSW { wxLogSysError(_("Directory '%s' couldn't be created"), dirname); @@ -1011,7 +1011,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) #ifdef __VMS__ return FALSE; #elif defined( __WXMAC__ ) - strcpy( gwxMacFileName , dir ) ; + wxStrcpy( gwxMacFileName , dir ) ; wxUnix2MacFilename( gwxMacFileName ) ; return (rmdir(WXSTRINGCAST gwxMacFileName) == 0); #else @@ -1019,7 +1019,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) #ifdef __SALFORDC__ return FALSE; // What to do? #else - return (rmdir(WXSTRINGCAST dir) == 0); + return (rmdir(FNSTRINGCAST dir.fn_str()) == 0); #endif #endif @@ -1032,7 +1032,7 @@ bool wxDirExists(const wxString& dir) return FALSE; #elif !defined(__WXMSW__) struct stat sbuf; - return (stat(dir, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE; + return (stat(dir.fn_str(), &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE; #else /* MATTHEW: [6] Always use same code for Win32, call FindClose */ @@ -1072,13 +1072,13 @@ bool wxDirExists(const wxString& dir) #endif // does the path exists? (may have or not '/' or '\\' at the end) -bool wxPathExists(const char *pszPathName) +bool wxPathExists(const wxChar *pszPathName) { // Windows API returns -1 from stat for "c:\dir\" if "c:\dir" exists // OTOH, we should change "d:" to "d:\" and leave "\" as is. wxString strPath(pszPathName); - if ( wxEndsWithPathSeparator(pszPathName) && pszPathName[1] != '\0' ) - strPath.Last() = '\0'; + if ( wxEndsWithPathSeparator(pszPathName) && pszPathName[1] != _T('\0') ) + strPath.Last() = _T('\0'); #ifdef __SALFORDC__ struct _stat st; @@ -1086,44 +1086,44 @@ bool wxPathExists(const char *pszPathName) struct stat st; #endif - return stat((char*) (const char*) strPath, &st) == 0 && (st.st_mode & S_IFDIR); + return stat(FNSTRINGCAST strPath.fn_str(), &st) == 0 && (st.st_mode & S_IFDIR); } // Get a temporary filename, opening and closing the file. -char *wxGetTempFileName(const wxString& prefix, char *buf) +wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf) { #ifdef __WINDOWS__ #ifndef __WIN32__ - char tmp[144]; + wxChar tmp[144]; ::GetTempFileName(0, WXSTRINGCAST prefix, 0, tmp); #else - char tmp[MAX_PATH]; - char tmpPath[MAX_PATH]; + wxChar tmp[MAX_PATH]; + wxChar tmpPath[MAX_PATH]; ::GetTempPath(MAX_PATH, tmpPath); ::GetTempFileName(tmpPath, WXSTRINGCAST prefix, 0, tmp); #endif - if (buf) strcpy(buf, tmp); + if (buf) wxStrcpy(buf, tmp); else buf = copystring(tmp); return 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]; // FIXME static buffer + wxChar tmp[100]; // FIXME static buffer for (short suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000) { - sprintf (tmp, "/tmp/%s%d.%03x", WXSTRINGCAST prefix, (int) getpid (), (int) suffix); + wxSprintf (tmp, _T("/tmp/%s%d.%03x"), WXSTRINGCAST prefix, (int) getpid (), (int) suffix); if (!wxFileExists( tmp )) { // Touch the file to create it (reserve name) - FILE *fd = fopen (tmp, "w"); + FILE *fd = fopen (wxFNCONV(tmp), "w"); if (fd) fclose (fd); last_temp = suffix; if (buf) - strcpy( buf, tmp); + wxStrcpy( buf, tmp); else buf = copystring( tmp ); return buf; @@ -1131,7 +1131,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) } wxLogError( _("wxWindows: error finding temporary file name.\n") ); if (buf) buf[0] = 0; - return (char *) NULL; + return (wxChar *) NULL; #endif } @@ -1148,7 +1148,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) static int gs_findFlags = 0; #endif -wxString wxFindFirstFile(const char *spec, int flags) +wxString wxFindFirstFile(const wxChar *spec, int flags) { wxString result; @@ -1165,13 +1165,13 @@ wxString wxFindFirstFile(const char *spec, int flags) wxString path(wxPathOnly(gs_strFileSpec)); // special case: path is really "/" - if ( !path && gs_strFileSpec[0u] == '/' ) - path = '/'; + if ( !path && gs_strFileSpec[0u] == _T('/') ) + path = _T('/'); // path is empty => Local directory if ( !path ) - path = '.'; + path = _T('.'); - gs_dirStream = opendir(path); + gs_dirStream = opendir(path.fn_str()); if ( !gs_dirStream ) { wxLogSysError(_("Can not enumerate files in directory '%s'"), @@ -1191,7 +1191,7 @@ wxString wxFindNextFile() wxString result; #ifndef __VMS__ - wxCHECK_MSG( gs_dirStream, result, "must call wxFindFirstFile first" ); + wxCHECK_MSG( gs_dirStream, result, _T("must call wxFindFirstFile first") ); // Find path only so we can concatenate // found file onto path @@ -1199,8 +1199,8 @@ wxString wxFindNextFile() wxString name(wxFileNameFromPath(gs_strFileSpec)); /* MATTHEW: special case: path is really "/" */ - if ( !path && gs_strFileSpec[0u] == '/') - path = '/'; + if ( !path && gs_strFileSpec[0u] == _T('/')) + path = _T('/'); // Do the reading struct dirent *nextDir; @@ -1214,8 +1214,8 @@ wxString wxFindNextFile() if ( !path.IsEmpty() ) { result = path; - if ( path != '/' ) - result += '/'; + if ( path != _T('/') ) + result += _T('/'); } result += nextDir->d_name; @@ -1268,7 +1268,7 @@ wxString wxFindNextFile() static wxString gs_strFileSpec; static int gs_findFlags = 0; -wxString wxFindFirstFile(const char *spec, int flags) +wxString wxFindFirstFile(const wxChar *spec, int flags) { wxString result; @@ -1278,7 +1278,7 @@ wxString wxFindFirstFile(const char *spec, int flags) // Find path only so we can concatenate found file onto path wxString path(wxPathOnly(gs_strFileSpec)); if ( !path.IsEmpty() ) - result << path << '\\'; + result << path << _T('\\'); #ifdef __WIN32__ if ( gs_hFileStruct != INVALID_HANDLE_VALUE ) @@ -1371,7 +1371,7 @@ try_again: goto try_again; if ( !path.IsEmpty() ) - result << path << '\\'; + result << path << _T('\\'); result << gs_findDataStruct.cFileName; } @@ -1418,18 +1418,34 @@ try_again: // Get current working directory. // If buf is NULL, allocates space using new, else // copies into buf. -char *wxGetWorkingDirectory(char *buf, int sz) +wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) { if (!buf) - buf = new char[sz+1]; + buf = new wxChar[sz+1]; +#if wxUSE_UNICODE + char *cbuf = new char[sz+1]; +#ifdef _MSC_VER + if (_getcwd(cbuf, sz) == NULL) { +#else + if (getcwd(cbuf, sz) == NULL) { +#endif + delete [] cbuf; +#else #ifdef _MSC_VER if (_getcwd(buf, sz) == NULL) { #else if (getcwd(buf, sz) == NULL) { #endif - buf[0] = '.'; - buf[1] = '\0'; +#endif + buf[0] = _T('.'); + buf[1] = _T('\0'); + } +#if wxUSE_UNICODE + else { + wxConv_file.MB2WC(buf, cbuf, sz); + delete [] cbuf; } +#endif return buf; } @@ -1447,7 +1463,7 @@ wxString wxGetCwd() bool wxSetWorkingDirectory(const wxString& d) { #if defined( __UNIX__ ) || defined( __WXMAC__ ) - return (chdir(d) == 0); + return (chdir(d.fn_str()) == 0); #elif defined(__WINDOWS__) #ifdef __WIN32__ @@ -1457,7 +1473,7 @@ bool wxSetWorkingDirectory(const wxString& d) bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':')); if (isDriveSpec) { - char firstChar = d[0]; + wxChar firstChar = d[0]; // To upper case if (firstChar > 90) @@ -1484,7 +1500,7 @@ bool wxSetWorkingDirectory(const wxString& d) wxString wxGetOSDirectory() { #ifdef __WINDOWS__ - char buf[256]; + wxChar buf[256]; GetWindowsDirectory(buf, 256); return wxString(buf); #else @@ -1502,10 +1518,10 @@ bool wxEndsWithPathSeparator(const char *pszFileName) } // find a file in a list of directories, returns false if not found -bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) +bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile) { // we assume that it's not empty - wxCHECK_MSG( !IsEmpty(pszFile), FALSE, + wxCHECK_MSG( !wxIsEmpty(pszFile), FALSE, _("empty file name in wxFindFileInPath")); // skip path separator in the beginning of the file name if present @@ -1513,14 +1529,14 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) pszFile++; // copy the path (strtok will modify it) - char *szPath = new char[strlen(pszPath) + 1]; - strcpy(szPath, pszPath); + wxChar *szPath = new wxChar[wxStrlen(pszPath) + 1]; + wxStrcpy(szPath, pszPath); wxString strFile; - char *pc; - for ( pc = strtok(szPath, wxPATH_SEP); + wxChar *pc, *save_ptr; + for ( pc = wxStrtok(szPath, wxPATH_SEP, &save_ptr); pc != NULL; - pc = strtok((char *) NULL, wxPATH_SEP) ) + pc = wxStrtok((wxChar *) NULL, wxPATH_SEP, &save_ptr) ) { // search for the file in this directory strFile = pc; @@ -1539,23 +1555,23 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) return pc != NULL; // if true => we breaked from the loop } -void WXDLLEXPORT wxSplitPath(const char *pszFileName, +void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, wxString *pstrPath, wxString *pstrName, wxString *pstrExt) { // it can be empty, but it shouldn't be NULL - wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" ); + wxCHECK_RET( pszFileName, _T("NULL file name in wxSplitPath") ); - const char *pDot = strrchr(pszFileName, wxFILE_SEP_EXT); + const wxChar *pDot = wxStrrchr(pszFileName, wxFILE_SEP_EXT); #ifdef __WXMSW__ // under Windows we understand both separators - const char *pSepUnix = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX); - const char *pSepDos = strrchr(pszFileName, wxFILE_SEP_PATH_DOS); - const char *pLastSeparator = pSepUnix > pSepDos ? pSepUnix : pSepDos; + const wxChar *pSepUnix = wxStrrchr(pszFileName, wxFILE_SEP_PATH_UNIX); + const wxChar *pSepDos = wxStrrchr(pszFileName, wxFILE_SEP_PATH_DOS); + const wxChar *pLastSeparator = pSepUnix > pSepDos ? pSepUnix : pSepDos; #else // assume Unix - const char *pLastSeparator = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX); + const wxChar *pLastSeparator = wxStrrchr(pszFileName, wxFILE_SEP_PATH_UNIX); if ( pDot == pszFileName ) { @@ -1580,8 +1596,8 @@ void WXDLLEXPORT wxSplitPath(const char *pszFileName, if ( pstrName ) { - const char *start = pLastSeparator ? pLastSeparator + 1 : pszFileName; - const char *end = pDot ? pDot : pszFileName + strlen(pszFileName); + const wxChar *start = pLastSeparator ? pLastSeparator + 1 : pszFileName; + const wxChar *end = pDot ? pDot : pszFileName + wxStrlen(pszFileName); *pstrName = wxString(start, end - start); } @@ -1602,12 +1618,12 @@ void WXDLLEXPORT wxSplitPath(const char *pszFileName, bool wxIsWild( const wxString& pattern ) { wxString tmp = pattern; - char *pat = WXSTRINGCAST(tmp); + wxChar *pat = WXSTRINGCAST(tmp); while (*pat) { switch (*pat++) { - case '?': case '*': case '[': case '{': + case _T('?'): case _T('*'): case _T('['): case _T('{'): return TRUE; - case '\\': + case _T('\\'): if (!*pat++) return FALSE; } @@ -1619,10 +1635,11 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) #if defined(HAVE_FNMATCH_H) { +// this probably won't work well for multibyte chars in Unicode mode? if(dot_special) - return fnmatch(pat.c_str(), text.c_str(), FNM_PERIOD) == 0; + return fnmatch(pat.fn_str(), text.fn_str(), FNM_PERIOD) == 0; else - return fnmatch(pat.c_str(), text.c_str(), 0) == 0; + return fnmatch(pat.fn_str(), text.fn_str(), 0) == 0; } #else @@ -1633,64 +1650,64 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) */ { wxString tmp1 = pat; - char *pattern = WXSTRINGCAST(tmp1); + wxChar *pattern = WXSTRINGCAST(tmp1); wxString tmp2 = text; - char *str = WXSTRINGCAST(tmp2); - char c; - char *cp; + wxChar *str = WXSTRINGCAST(tmp2); + wxChar c; + wxChar *cp; bool done = FALSE, ret_code, ok; // Below is for vi fans - const char OB = '{', CB = '}'; + const wxChar OB = _T('{'), CB = _T('}'); // dot_special means '.' only matches '.' - if (dot_special && *str == '.' && *pattern != *str) + if (dot_special && *str == _T('.') && *pattern != *str) return FALSE; - while ((*pattern != '\0') && (!done) - && (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) { + while ((*pattern != _T('\0')) && (!done) + && (((*str==_T('\0'))&&((*pattern==OB)||(*pattern==_T('*'))))||(*str!=_T('\0')))) { switch (*pattern) { - case '\\': + case _T('\\'): pattern++; - if (*pattern != '\0') + if (*pattern != _T('\0')) pattern++; break; - case '*': + case _T('*'): pattern++; ret_code = FALSE; - while ((*str!='\0') + while ((*str!=_T('\0')) && (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) /*loop*/; if (ret_code) { - while (*str != '\0') + while (*str != _T('\0')) str++; - while (*pattern != '\0') + while (*pattern != _T('\0')) pattern++; } break; - case '[': + case _T('['): pattern++; repeat: - if ((*pattern == '\0') || (*pattern == ']')) { + if ((*pattern == _T('\0')) || (*pattern == _T(']'))) { done = TRUE; break; } - if (*pattern == '\\') { + if (*pattern == _T('\\')) { pattern++; - if (*pattern == '\0') { + if (*pattern == _T('\0')) { done = TRUE; break; } } - if (*(pattern + 1) == '-') { + if (*(pattern + 1) == _T('-')) { c = *pattern; pattern += 2; - if (*pattern == ']') { + if (*pattern == _T(']')) { done = TRUE; break; } - if (*pattern == '\\') { + if (*pattern == _T('\\')) { pattern++; - if (*pattern == '\0') { + if (*pattern == _T('\0')) { done = TRUE; break; } @@ -1704,51 +1721,51 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) goto repeat; } pattern++; - while ((*pattern != ']') && (*pattern != '\0')) { - if ((*pattern == '\\') && (*(pattern + 1) != '\0')) + while ((*pattern != _T(']')) && (*pattern != _T('\0'))) { + if ((*pattern == _T('\\')) && (*(pattern + 1) != _T('\0'))) pattern++; pattern++; } - if (*pattern != '\0') { + if (*pattern != _T('\0')) { pattern++, str++; } break; - case '?': + case _T('?'): pattern++; str++; break; case OB: pattern++; - while ((*pattern != CB) && (*pattern != '\0')) { + while ((*pattern != CB) && (*pattern != _T('\0'))) { cp = str; ok = TRUE; - while (ok && (*cp != '\0') && (*pattern != '\0') - && (*pattern != ',') && (*pattern != CB)) { - if (*pattern == '\\') + while (ok && (*cp != _T('\0')) && (*pattern != _T('\0')) + && (*pattern != _T(',')) && (*pattern != CB)) { + if (*pattern == _T('\\')) pattern++; ok = (*pattern++ == *cp++); } - if (*pattern == '\0') { + if (*pattern == _T('\0')) { ok = FALSE; done = TRUE; break; } else if (ok) { str = cp; - while ((*pattern != CB) && (*pattern != '\0')) { - if (*++pattern == '\\') { + while ((*pattern != CB) && (*pattern != _T('\0'))) { + if (*++pattern == _T('\\')) { if (*++pattern == CB) pattern++; } } } else { - while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { - if (*++pattern == '\\') { - if (*++pattern == CB || *pattern == ',') + while (*pattern!=CB && *pattern!=_T(',') && *pattern!=_T('\0')) { + if (*++pattern == _T('\\')) { + if (*++pattern == CB || *pattern == _T(',')) pattern++; } } } - if (*pattern != '\0') + if (*pattern != _T('\0')) pattern++; } break; @@ -1760,9 +1777,9 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) } } } - while (*pattern == '*') + while (*pattern == _T('*')) pattern++; - return ((*str == '\0') && (*pattern == '\0')); + return ((*str == _T('\0')) && (*pattern == _T('\0'))); }; #endif diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index eae3619cec..154c2c7008 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -148,91 +148,91 @@ void wxColourDatabase::Initialize () // Added: Not all struct cdef { - char *name; + wxChar *name; int r,g,b; }; cdef cc; static cdef table[]={ // #ifdef __WXMSW__ - {"AQUAMARINE",112, 219, 147}, - {"BLACK",0, 0, 0}, - {"BLUE", 0, 0, 255}, - {"BLUE VIOLET", 159, 95, 159}, - {"BROWN", 165, 42, 42}, - {"CADET BLUE", 95, 159, 159}, - {"CORAL", 255, 127, 0}, - {"CORNFLOWER BLUE", 66, 66, 111}, - {"CYAN", 0, 255, 255}, - {"DARK GREY", 47, 47, 47}, // ? - - {"DARK GREEN", 47, 79, 47}, - {"DARK OLIVE GREEN", 79, 79, 47}, - {"DARK ORCHID", 153, 50, 204}, - {"DARK SLATE BLUE", 107, 35, 142}, - {"DARK SLATE GREY", 47, 79, 79}, - {"DARK TURQUOISE", 112, 147, 219}, - {"DIM GREY", 84, 84, 84}, - {"FIREBRICK", 142, 35, 35}, - {"FOREST GREEN", 35, 142, 35}, - {"GOLD", 204, 127, 50}, - {"GOLDENROD", 219, 219, 112}, - {"GREY", 128, 128, 128}, - {"GREEN", 0, 255, 0}, - {"GREEN YELLOW", 147, 219, 112}, - {"INDIAN RED", 79, 47, 47}, - {"KHAKI", 159, 159, 95}, - {"LIGHT BLUE", 191, 216, 216}, - {"LIGHT GREY", 192, 192, 192}, - {"LIGHT STEEL BLUE", 143, 143, 188}, - {"LIME GREEN", 50, 204, 50}, - {"LIGHT MAGENTA", 255, 0, 255}, - {"MAGENTA", 255, 0, 255}, - {"MAROON", 142, 35, 107}, - {"MEDIUM AQUAMARINE", 50, 204, 153}, - {"MEDIUM GREY", 100, 100, 100}, - {"MEDIUM BLUE", 50, 50, 204}, - {"MEDIUM FOREST GREEN", 107, 142, 35}, - {"MEDIUM GOLDENROD", 234, 234, 173}, - {"MEDIUM ORCHID", 147, 112, 219}, - {"MEDIUM SEA GREEN", 66, 111, 66}, - {"MEDIUM SLATE BLUE", 127, 0, 255}, - {"MEDIUM SPRING GREEN", 127, 255, 0}, - {"MEDIUM TURQUOISE", 112, 219, 219}, - {"MEDIUM VIOLET RED", 219, 112, 147}, - {"MIDNIGHT BLUE", 47, 47, 79}, - {"NAVY", 35, 35, 142}, - {"ORANGE", 204, 50, 50}, - {"ORANGE RED", 255, 0, 127}, - {"ORCHID", 219, 112, 219}, - {"PALE GREEN", 143, 188, 143}, - {"PINK", 188, 143, 234}, - {"PLUM", 234, 173, 234}, - {"PURPLE", 176, 0, 255}, - {"RED", 255, 0, 0}, - {"SALMON", 111, 66, 66}, - {"SEA GREEN", 35, 142, 107}, - {"SIENNA", 142, 107, 35}, - {"SKY BLUE", 50, 153, 204}, - {"SLATE BLUE", 0, 127, 255}, - {"SPRING GREEN", 0, 255, 127}, - {"STEEL BLUE", 35, 107, 142}, - {"TAN", 219, 147, 112}, - {"THISTLE", 216, 191, 216}, - {"TURQUOISE", 173, 234, 234}, - {"VIOLET", 79, 47, 79}, - {"VIOLET RED", 204, 50, 153}, - {"WHEAT", 216, 216, 191}, - {"WHITE", 255, 255, 255}, - {"YELLOW", 255, 255, 0}, - {"YELLOW GREEN", 153, 204, 50}, + {_T("AQUAMARINE"),112, 219, 147}, + {_T("BLACK"),0, 0, 0}, + {_T("BLUE"), 0, 0, 255}, + {_T("BLUE VIOLET"), 159, 95, 159}, + {_T("BROWN"), 165, 42, 42}, + {_T("CADET BLUE"), 95, 159, 159}, + {_T("CORAL"), 255, 127, 0}, + {_T("CORNFLOWER BLUE"), 66, 66, 111}, + {_T("CYAN"), 0, 255, 255}, + {_T("DARK GREY"), 47, 47, 47}, // ? + + {_T("DARK GREEN"), 47, 79, 47}, + {_T("DARK OLIVE GREEN"), 79, 79, 47}, + {_T("DARK ORCHID"), 153, 50, 204}, + {_T("DARK SLATE BLUE"), 107, 35, 142}, + {_T("DARK SLATE GREY"), 47, 79, 79}, + {_T("DARK TURQUOISE"), 112, 147, 219}, + {_T("DIM GREY"), 84, 84, 84}, + {_T("FIREBRICK"), 142, 35, 35}, + {_T("FOREST GREEN"), 35, 142, 35}, + {_T("GOLD"), 204, 127, 50}, + {_T("GOLDENROD"), 219, 219, 112}, + {_T("GREY"), 128, 128, 128}, + {_T("GREEN"), 0, 255, 0}, + {_T("GREEN YELLOW"), 147, 219, 112}, + {_T("INDIAN RED"), 79, 47, 47}, + {_T("KHAKI"), 159, 159, 95}, + {_T("LIGHT BLUE"), 191, 216, 216}, + {_T("LIGHT GREY"), 192, 192, 192}, + {_T("LIGHT STEEL BLUE"), 143, 143, 188}, + {_T("LIME GREEN"), 50, 204, 50}, + {_T("LIGHT MAGENTA"), 255, 0, 255}, + {_T("MAGENTA"), 255, 0, 255}, + {_T("MAROON"), 142, 35, 107}, + {_T("MEDIUM AQUAMARINE"), 50, 204, 153}, + {_T("MEDIUM GREY"), 100, 100, 100}, + {_T("MEDIUM BLUE"), 50, 50, 204}, + {_T("MEDIUM FOREST GREEN"), 107, 142, 35}, + {_T("MEDIUM GOLDENROD"), 234, 234, 173}, + {_T("MEDIUM ORCHID"), 147, 112, 219}, + {_T("MEDIUM SEA GREEN"), 66, 111, 66}, + {_T("MEDIUM SLATE BLUE"), 127, 0, 255}, + {_T("MEDIUM SPRING GREEN"), 127, 255, 0}, + {_T("MEDIUM TURQUOISE"), 112, 219, 219}, + {_T("MEDIUM VIOLET RED"), 219, 112, 147}, + {_T("MIDNIGHT BLUE"), 47, 47, 79}, + {_T("NAVY"), 35, 35, 142}, + {_T("ORANGE"), 204, 50, 50}, + {_T("ORANGE RED"), 255, 0, 127}, + {_T("ORCHID"), 219, 112, 219}, + {_T("PALE GREEN"), 143, 188, 143}, + {_T("PINK"), 188, 143, 234}, + {_T("PLUM"), 234, 173, 234}, + {_T("PURPLE"), 176, 0, 255}, + {_T("RED"), 255, 0, 0}, + {_T("SALMON"), 111, 66, 66}, + {_T("SEA GREEN"), 35, 142, 107}, + {_T("SIENNA"), 142, 107, 35}, + {_T("SKY BLUE"), 50, 153, 204}, + {_T("SLATE BLUE"), 0, 127, 255}, + {_T("SPRING GREEN"), 0, 255, 127}, + {_T("STEEL BLUE"), 35, 107, 142}, + {_T("TAN"), 219, 147, 112}, + {_T("THISTLE"), 216, 191, 216}, + {_T("TURQUOISE"), 173, 234, 234}, + {_T("VIOLET"), 79, 47, 79}, + {_T("VIOLET RED"), 204, 50, 153}, + {_T("WHEAT"), 216, 216, 191}, + {_T("WHITE"), 255, 255, 255}, + {_T("YELLOW"), 255, 255, 0}, + {_T("YELLOW GREEN"), 153, 204, 50}, // #endif #if defined(__WXGTK__) || defined(__X__) - {"MEDIUM GOLDENROD", 234, 234, 173}, - {"MEDIUM FOREST GREEN", 107, 142, 35}, - {"LIGHT MAGENTA", 255, 0, 255}, - {"MEDIUM GREY", 100, 100, 100}, + {_T("MEDIUM GOLDENROD"), 234, 234, 173}, + {_T("MEDIUM FOREST GREEN"), 107, 142, 35}, + {_T("LIGHT MAGENTA"), 255, 0, 255}, + {_T("MEDIUM GREY"), 100, 100, 100}, #endif {0,0,0,0} @@ -331,7 +331,7 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const if (col->Red () == red && col->Green () == green && col->Blue () == blue) { - const char *found = node->GetKeyString(); + const wxChar *found = node->GetKeyString(); if (found) return wxString(found); } diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 69b17fd56e..691d70832c 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -92,7 +92,7 @@ void wxHashTable::Put (long key, long value, wxObject * object) hash_table[position]->Append (value, object); } -void wxHashTable::Put (long key, const char *value, wxObject * object) +void wxHashTable::Put (long key, const wxChar *value, wxObject * object) { // Should NEVER be long k = (long) key; @@ -120,7 +120,7 @@ void wxHashTable::Put (long key, wxObject * object) hash_table[position]->Append (k, object); } -void wxHashTable::Put (const char *key, wxObject * object) +void wxHashTable::Put (const wxChar *key, wxObject * object) { int position = (int) (MakeKey (key) % n); @@ -150,7 +150,7 @@ wxObject *wxHashTable::Get (long key, long value) const } } -wxObject *wxHashTable::Get (long key, const char *value) const +wxObject *wxHashTable::Get (long key, const wxChar *value) const { // Should NEVER be long k = (long) key; @@ -187,7 +187,7 @@ wxObject *wxHashTable::Get (long key) const } } -wxObject *wxHashTable::Get (const char *key) const +wxObject *wxHashTable::Get (const wxChar *key) const { int position = (int) (MakeKey (key) % n); @@ -224,7 +224,7 @@ wxObject *wxHashTable::Delete (long key) } } -wxObject *wxHashTable::Delete (const char *key) +wxObject *wxHashTable::Delete (const wxChar *key) { int position = (int) (MakeKey (key) % n); if (!hash_table[position]) @@ -267,7 +267,7 @@ wxObject *wxHashTable::Delete (long key, int value) } } -wxObject *wxHashTable::Delete (long key, const char *value) +wxObject *wxHashTable::Delete (long key, const wxChar *value) { int position = (int) (key % n); if (!hash_table[position]) @@ -286,12 +286,12 @@ wxObject *wxHashTable::Delete (long key, const char *value) } } -long wxHashTable::MakeKey (const char *string) const +long wxHashTable::MakeKey (const wxChar *string) const { long int_key = 0; while (*string) - int_key += (unsigned char) *string++; + int_key += (wxUChar) *string++; return int_key; } diff --git a/src/common/image.cpp b/src/common/image.cpp index a95fe7784a..0aaa5d908d 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -156,15 +156,15 @@ wxImage wxImage::Scale( int width, int height ) { wxImage image; - wxCHECK_MSG( Ok(), image, "invlaid image" ); + wxCHECK_MSG( Ok(), image, _T("invalid image") ); - wxCHECK_MSG( (width > 0) && (height > 0), image, "invalid image size" ); + wxCHECK_MSG( (width > 0) && (height > 0), image, _T("invalid image size") ); image.Create( width, height ); char unsigned *data = image.GetData(); - wxCHECK_MSG( data, image, "unable to create image" ); + wxCHECK_MSG( data, image, _T("unable to create image") ); if (M_IMGDATA->m_hasMask) image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue ); @@ -193,12 +193,12 @@ wxImage wxImage::Scale( int width, int height ) void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ) { - wxCHECK_RET( Ok(), "invalid image" ); + wxCHECK_RET( Ok(), _T("invalid image") ); int w = M_IMGDATA->m_width; int h = M_IMGDATA->m_height; - wxCHECK_RET( (x>=0) && (y>=0) && (x=0) && (y>=0) && (xm_width; int h = M_IMGDATA->m_height; - wxCHECK_MSG( (x>=0) && (y>=0) && (x=0) && (y>=0) && (xm_width; int h = M_IMGDATA->m_height; - wxCHECK_MSG( (x>=0) && (y>=0) && (x=0) && (y>=0) && (xm_width; int h = M_IMGDATA->m_height; - wxCHECK_MSG( (x>=0) && (y>=0) && (x=0) && (y>=0) && (xm_data; } void wxImage::SetData( char unsigned *data ) { - wxCHECK_RET( Ok(), "invalid image" ); + wxCHECK_RET( Ok(), _T("invalid image") ); memcpy(M_IMGDATA->m_data, data, M_IMGDATA->m_width * M_IMGDATA->m_height * 3); } void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) { - wxCHECK_RET( Ok(), "invalid image" ); + wxCHECK_RET( Ok(), _T("invalid image") ); M_IMGDATA->m_maskRed = r; M_IMGDATA->m_maskGreen = g; @@ -280,49 +280,49 @@ void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) unsigned char wxImage::GetMaskRed() const { - wxCHECK_MSG( Ok(), 0, "invalid image" ); + wxCHECK_MSG( Ok(), 0, _T("invalid image") ); return M_IMGDATA->m_maskRed; } unsigned char wxImage::GetMaskGreen() const { - wxCHECK_MSG( Ok(), 0, "invalid image" ); + wxCHECK_MSG( Ok(), 0, _T("invalid image") ); return M_IMGDATA->m_maskGreen; } unsigned char wxImage::GetMaskBlue() const { - wxCHECK_MSG( Ok(), 0, "invalid image" ); + wxCHECK_MSG( Ok(), 0, _T("invalid image") ); return M_IMGDATA->m_maskBlue; } void wxImage::SetMask( bool mask ) { - wxCHECK_RET( Ok(), "invalid image" ); + wxCHECK_RET( Ok(), _T("invalid image") ); M_IMGDATA->m_hasMask = mask; } bool wxImage::HasMask() const { - wxCHECK_MSG( Ok(), FALSE, "invalid image" ); + wxCHECK_MSG( Ok(), FALSE, _T("invalid image") ); return M_IMGDATA->m_hasMask; } int wxImage::GetWidth() const { - wxCHECK_MSG( Ok(), 0, "invalid image" ); + wxCHECK_MSG( Ok(), 0, _T("invalid image") ); return M_IMGDATA->m_width; } int wxImage::GetHeight() const { - wxCHECK_MSG( Ok(), 0, "invalid image" ); + wxCHECK_MSG( Ok(), 0, _T("invalid image") ); return M_IMGDATA->m_height; } @@ -337,7 +337,7 @@ bool wxImage::LoadFile( const wxString& filename, long type ) } else { - wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() ); + wxLogError( _T("Can't load image from file '%s': file does not exist."), filename.c_str() ); return FALSE; } @@ -356,7 +356,7 @@ bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype ) } else { - wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() ); + wxLogError( _T("Can't load image from file '%s': file does not exist."), filename.c_str() ); return FALSE; } @@ -400,7 +400,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type ) if (handler == NULL) { - wxLogWarning( "No image handler for type %d defined.", type ); + wxLogWarning( _T("No image handler for type %d defined."), type ); return FALSE; } @@ -418,7 +418,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype ) if (handler == NULL) { - wxLogWarning( "No image handler for type %s defined.", mimetype.GetData() ); + wxLogWarning( _T("No image handler for type %s defined."), mimetype.GetData() ); return FALSE; } @@ -428,13 +428,13 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype ) bool wxImage::SaveFile( wxOutputStream& stream, int type ) { - wxCHECK_MSG( Ok(), FALSE, "invalid image" ); - + wxCHECK_MSG( Ok(), FALSE, _T("invalid image") ); + wxImageHandler *handler = FindHandler(type); - + if (handler == NULL) { - wxLogWarning( "No image handler for type %d defined.", type ); + wxLogWarning( _T("No image handler for type %d defined."), type ); return FALSE; } @@ -444,13 +444,13 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype ) { - wxCHECK_MSG( Ok(), FALSE, "invalid image" ); + wxCHECK_MSG( Ok(), FALSE, _T("invalid image") ); wxImageHandler *handler = FindHandlerMime(mimetype); if (handler == NULL) { - wxLogWarning( "No image handler for type %s defined.", mimetype.GetData() ); + wxLogWarning( _T("No image handler for type %s defined."), mimetype.GetData() ); return FALSE; } @@ -630,12 +630,12 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) int height = (int)dbuf[1]; if (width > 32767) { - wxLogError( "Image width > 32767 pixels for file\n" ); + wxLogError( _T("Image width > 32767 pixels for file\n") ); return FALSE; } if (height > 32767) { - wxLogError( "Image height > 32767 pixels for file\n" ); + wxLogError( _T("Image height > 32767 pixels for file\n") ); return FALSE; } stream.Read(&word, 2); @@ -644,14 +644,14 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) bpp = (int)word; if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32) { - wxLogError( "unknown bitdepth in file\n" ); + wxLogError( _T("unknown bitdepth in file\n") ); return FALSE; } stream.Read(dbuf, 4 * 4); comp = (int)dbuf[0]; if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS) { - wxLogError( "unknown encoding in Windows BMP file\n" ); + wxLogError( _T("unknown encoding in Windows BMP file\n") ); return FALSE; } stream.Read(dbuf, 4 * 2); @@ -661,7 +661,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) /* some more sanity checks */ if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32))) { - wxLogError( "encoding of BMP doesn't match bitdepth\n" ); + wxLogError( _T("encoding of BMP doesn't match bitdepth\n") ); return FALSE; } if (bpp < 16) @@ -670,7 +670,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) if (!cmap) { - wxLogError( "Cannot allocate RAM for color map in BMP file\n" ); + wxLogError( _T("Cannot allocate RAM for color map in BMP file\n") ); return FALSE; } } @@ -681,7 +681,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) ptr = image->GetData(); if (!ptr) { - wxLogError( "Cannot allocate RAM for RGB data in file\n" ); + wxLogError( _T("Cannot allocate RAM for RGB data in file\n") ); if (cmap) free(cmap); return FALSE; @@ -795,7 +795,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) { if (comp == BI_RLE4) { - wxLogError( "can't deal with 4bit encoded yet.\n"); + wxLogError( _T("can't deal with 4bit encoded yet.\n") ); image->Destroy(); free(cmap); return FALSE; @@ -973,7 +973,7 @@ wxBitmap wxImage::ConvertToBitmap() const // set bitmap parameters wxBitmap bitmap; - wxCHECK_MSG( Ok(), bitmap, "invalid image" ); + wxCHECK_MSG( Ok(), bitmap, _T("invalid image") ); bitmap.SetWidth( width ); bitmap.SetHeight( bmpHeight ); bitmap.SetDepth( wxDisplayDepth() ); @@ -981,7 +981,7 @@ wxBitmap wxImage::ConvertToBitmap() const // create a DIB header int headersize = sizeof(BITMAPINFOHEADER); LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); - wxCHECK_MSG( lpDIBh, bitmap, "could not allocate memory for DIB header" ); + wxCHECK_MSG( lpDIBh, bitmap, _T("could not allocate memory for DIB header") ); // Fill in the DIB header lpDIBh->bmiHeader.biSize = headersize; lpDIBh->bmiHeader.biWidth = (DWORD)width; @@ -1002,7 +1002,7 @@ wxBitmap wxImage::ConvertToBitmap() const lpBits = (unsigned char *)malloc( lpDIBh->bmiHeader.biSizeImage ); if( !lpBits ) { - wxFAIL_MSG( "could not allocate memory for DIB" ); + wxFAIL_MSG( _T("could not allocate memory for DIB") ); free( lpDIBh ); return bitmap; } @@ -1145,7 +1145,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) // check the bitmap if( !bitmap.Ok() ) { - wxFAIL_MSG( "invalid bitmap" ); + wxFAIL_MSG( _T("invalid bitmap") ); return; } @@ -1156,7 +1156,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) unsigned char *data = GetData(); if( !data ) { - wxFAIL_MSG( "could not allocate data for image" ); + wxFAIL_MSG( _T("could not allocate data for image") ); return; } @@ -1176,7 +1176,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); if( !lpDIBh ) { - wxFAIL_MSG( "could not allocate data for DIB header" ); + wxFAIL_MSG( _T("could not allocate data for DIB header") ); free( data ); return; } @@ -1198,7 +1198,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage ); if( !lpBits ) { - wxFAIL_MSG( "could not allocate data for DIB" ); + wxFAIL_MSG( _T("could not allocate data for DIB") ); free( data ); free( lpDIBh ); return; @@ -1281,7 +1281,7 @@ wxBitmap wxImage::ConvertToBitmap() const { wxBitmap bitmap; - wxCHECK_MSG( Ok(), bitmap, "invalid image" ); + wxCHECK_MSG( Ok(), bitmap, _T("invalid image") ); int width = GetWidth(); int height = GetHeight(); @@ -1460,13 +1460,13 @@ wxBitmap wxImage::ConvertToBitmap() const wxImage::wxImage( const wxBitmap &bitmap ) { - wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); + wxCHECK_RET( bitmap.Ok(), _T("invalid bitmap") ); GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); - wxCHECK_RET( gdk_image, "couldn't create image" ); + wxCHECK_RET( gdk_image, _T("couldn't create image") ); Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); @@ -1474,7 +1474,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) if (!data) { gdk_image_destroy( gdk_image ); - wxFAIL_MSG( "couldn't create image" ); + wxFAIL_MSG( _T("couldn't create image") ); return; } @@ -1554,7 +1554,7 @@ wxBitmap wxImage::ConvertToBitmap() const { wxBitmap bitmap; - wxCHECK_MSG( Ok(), bitmap, "invalid image" ); + wxCHECK_MSG( Ok(), bitmap, _T("invalid image") ); int width = GetWidth(); int height = GetHeight(); @@ -1758,7 +1758,7 @@ wxBitmap wxImage::ConvertToBitmap() const wxImage::wxImage( const wxBitmap &bitmap ) { - wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); + wxCHECK_RET( bitmap.Ok(), _T("invalid bitmap") ); Display *dpy = (Display*) wxGetDisplay(); Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) ); @@ -1770,7 +1770,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) bitmap.GetWidth(), bitmap.GetHeight(), AllPlanes, ZPixmap ); - wxCHECK_RET( ximage, "couldn't create image" ); + wxCHECK_RET( ximage, _T("couldn't create image") ); Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); @@ -1778,7 +1778,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) if (!data) { XDestroyImage( ximage ); - wxFAIL_MSG( "couldn't create image" ); + wxFAIL_MSG( _T("couldn't create image") ); return; } @@ -1891,4 +1891,3 @@ public: }; IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule) - diff --git a/src/common/imaggif.cpp b/src/common/imaggif.cpp index 0d83a397c9..02b1499707 100644 --- a/src/common/imaggif.cpp +++ b/src/common/imaggif.cpp @@ -390,7 +390,7 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream ) decod = new gifDecoder(&stream); if (decod -> readgif(&igif) != E_OK) { - wxLogDebug("Error reading GIF"); + wxLogDebug(_T("Error reading GIF")); delete decod; return FALSE; } @@ -427,7 +427,7 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream ) bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream ) { - wxLogDebug("wxGIFHandler is read-only!!"); + wxLogDebug(_T("wxGIFHandler is read-only!!")); return FALSE; } diff --git a/src/common/list.cpp b/src/common/list.cpp index 8bc94a8c64..49e3268059 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -59,12 +59,12 @@ bool wxListKey::operator==(wxListKeyValue value) const switch ( m_keyType ) { default: - wxFAIL_MSG("bad key type."); + wxFAIL_MSG(_T("bad key type.")); // let compiler optimize the line above away in release build // by not putting return here... case wxKEY_STRING: - return strcmp(m_key.string, value.string) == 0; + return wxStrcmp(m_key.string, value.string) == 0; case wxKEY_INTEGER: return m_key.integer == value.integer; @@ -95,11 +95,11 @@ wxNodeBase::wxNodeBase(wxListBase *list, case wxKEY_STRING: // to be free()d later - m_key.string = strdup(key.GetString()); + m_key.string = wxStrdup(key.GetString()); break; default: - wxFAIL_MSG("invalid key type"); + wxFAIL_MSG(_T("invalid key type")); } if ( previous ) @@ -127,7 +127,7 @@ wxNodeBase::~wxNodeBase() int wxNodeBase::IndexOf() const { - wxCHECK_MSG( m_list, wxNOT_FOUND, "node doesn't belong to a list in IndexOf"); + wxCHECK_MSG( m_list, wxNOT_FOUND, _T("node doesn't belong to a list in IndexOf")); // It would be more efficient to implement IndexOf() completely inside // wxListBase (only traverse the list once), but this is probably a more @@ -170,7 +170,7 @@ wxListBase::wxListBase(size_t count, void *elements[]) void wxListBase::DoCopy(const wxListBase& list) { wxASSERT_MSG( !list.m_destroy, - "copying list which owns it's elements is a bad idea" ); + _T("copying list which owns it's elements is a bad idea") ); m_count = list.m_count; m_destroy = list.m_destroy; @@ -217,7 +217,7 @@ wxNodeBase *wxListBase::Append(void *object) { // all objects in a keyed list should have a key wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL, - "need a key for the object to append" ); + _T("need a key for the object to append") ); wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object); @@ -229,18 +229,18 @@ wxNodeBase *wxListBase::Append(long key, void *object) wxCHECK_MSG( (m_keyType == wxKEY_INTEGER) || (m_keyType == wxKEY_NONE && m_count == 0), (wxNodeBase *)NULL, - "can't append object with numeric key to this list" ); + _T("can't append object with numeric key to this list") ); wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key); return AppendCommon(node); } -wxNodeBase *wxListBase::Append (const char *key, void *object) +wxNodeBase *wxListBase::Append (const wxChar *key, void *object) { wxCHECK_MSG( (m_keyType == wxKEY_STRING) || (m_keyType == wxKEY_NONE && m_count == 0), (wxNodeBase *)NULL, - "can't append object with string key to this list" ); + _T("can't append object with string key to this list") ); wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key); return AppendCommon(node); @@ -250,10 +250,10 @@ wxNodeBase *wxListBase::Insert(wxNodeBase *position, void *object) { // all objects in a keyed list should have a key wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL, - "need a key for the object to insert" ); + _T("need a key for the object to insert") ); wxCHECK_MSG( !position || position->m_list == this, (wxNodeBase *)NULL, - "can't insert before a node from another list" ); + _T("can't insert before a node from another list") ); // previous and next node for the node being inserted wxNodeBase *prev, *next; @@ -295,7 +295,7 @@ wxNodeBase *wxListBase::Item(size_t n) const } } - wxFAIL_MSG( "invalid index in wxListBase::Item" ); + wxFAIL_MSG( _T("invalid index in wxListBase::Item") ); return (wxNodeBase *)NULL; } @@ -303,7 +303,7 @@ wxNodeBase *wxListBase::Item(size_t n) const wxNodeBase *wxListBase::Find(const wxListKey& key) const { wxASSERT_MSG( m_keyType == key.GetKeyType(), - "this list is not keyed on the type of this key" ); + _T("this list is not keyed on the type of this key") ); for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) { @@ -356,9 +356,9 @@ void wxListBase::DoDeleteNode(wxNodeBase *node) wxNodeBase *wxListBase::DetachNode(wxNodeBase *node) { - wxCHECK_MSG( node, NULL, "detaching NULL wxNodeBase" ); + wxCHECK_MSG( node, NULL, _T("detaching NULL wxNodeBase") ); wxCHECK_MSG( node->m_list == this, NULL, - "detaching node which is not from this list" ); + _T("detaching node which is not from this list") ); // update the list wxNodeBase **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next @@ -524,13 +524,13 @@ void wxStringListNode::DeleteData() delete [] (char *)GetData(); } -bool wxStringList::Delete(const char *s) +bool wxStringList::Delete(const wxChar *s) { wxStringListNode *current; for ( current = GetFirst(); current; current = current->GetNext() ) { - if ( strcmp(current->GetData(), s) == 0 ) + if ( wxStrcmp(current->GetData(), s) == 0 ) { DeleteNode(current); return TRUE; @@ -554,7 +554,7 @@ void wxStringList::DoCopy(const wxStringList& other) // Variable argument list, terminated by a zero // Makes new storage for the strings -wxStringList::wxStringList (const char *first, ...) +wxStringList::wxStringList (const wxChar *first, ...) { if ( !first ) return; @@ -562,12 +562,12 @@ wxStringList::wxStringList (const char *first, ...) va_list ap; va_start(ap, first); - const char *s = first; + const wxChar *s = first; for (;;) { Add(s); - s = va_arg(ap, const char *); + s = va_arg(ap, const wxChar *); // if (s == NULL) #ifdef __WXMSW__ if ((int) s == 0) @@ -581,13 +581,13 @@ wxStringList::wxStringList (const char *first, ...) } // Only makes new strings if arg is TRUE -char **wxStringList::ListToArray(bool new_copies) const +wxChar **wxStringList::ListToArray(bool new_copies) const { - char **string_array = new char *[GetCount()]; + wxChar **string_array = new wxChar *[GetCount()]; wxStringListNode *node = GetFirst(); for (size_t i = 0; i < GetCount(); i++) { - char *s = node->GetData(); + wxChar *s = node->GetData(); if ( new_copies ) string_array[i] = copystring(s); else @@ -599,12 +599,12 @@ char **wxStringList::ListToArray(bool new_copies) const } // Checks whether s is a member of the list -bool wxStringList::Member(const char *s) const +bool wxStringList::Member(const wxChar *s) const { for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() ) { - const char *s1 = node->GetData(); - if (s == s1 || strcmp (s, s1) == 0) + const wxChar *s1 = node->GetData(); + if (s == s1 || wxStrcmp (s, s1) == 0) return TRUE; } @@ -614,17 +614,17 @@ bool wxStringList::Member(const char *s) const static int wx_comparestrings(const void *arg1, const void *arg2) { - char **s1 = (char **) arg1; - char **s2 = (char **) arg2; + wxChar **s1 = (wxChar **) arg1; + wxChar **s2 = (wxChar **) arg2; - return strcmp (*s1, *s2); + return wxStrcmp (*s1, *s2); } // Sort a list of strings - deallocates old nodes, allocates new void wxStringList::Sort() { size_t N = GetCount(); - char **array = new char *[N]; + wxChar **array = new wxChar *[N]; wxStringListNode *node; size_t i = 0; @@ -633,7 +633,7 @@ void wxStringList::Sort() array[i++] = node->GetData(); } - qsort (array, N, sizeof (char *), wx_comparestrings); + qsort (array, N, sizeof (wxChar *), wx_comparestrings); i = 0; for ( node = GetFirst(); node; node = node->GetNext() ) diff --git a/src/common/log.cpp b/src/common/log.cpp index 050ee0c3d3..1ba8688083 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -93,15 +93,15 @@ static wxFrame *gs_pFrame; // FIXME MT-unsafe #define LOG_BUFFER_SIZE (4096) // static buffer for error messages (FIXME MT-unsafe) -static char s_szBuf[LOG_BUFFER_SIZE]; +static wxChar s_szBuf[LOG_BUFFER_SIZE]; // generic log function -void wxLogGeneric(wxLogLevel level, const char *szFormat, ...) +void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...) { if ( wxLog::GetActiveTarget() != NULL ) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(level, s_szBuf, time(NULL)); @@ -109,12 +109,12 @@ void wxLogGeneric(wxLogLevel level, const char *szFormat, ...) } #define IMPLEMENT_LOG_FUNCTION(level) \ - void wxLog##level(const char *szFormat, ...) \ + void wxLog##level(const wxChar *szFormat, ...) \ { \ if ( wxLog::GetActiveTarget() != NULL ) { \ va_list argptr; \ va_start(argptr, szFormat); \ - vsprintf(s_szBuf, szFormat, argptr); \ + wxVsprintf(s_szBuf, szFormat, argptr); \ va_end(argptr); \ \ wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \ @@ -130,13 +130,13 @@ IMPLEMENT_LOG_FUNCTION(Status) // accepts an additional argument which tells to which frame the output should // be directed -void wxLogStatus(wxFrame *pFrame, const char *szFormat, ...) +void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...) { wxLog *pLog = wxLog::GetActiveTarget(); if ( pLog != NULL ) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxASSERT( gs_pFrame == NULL ); // should be reset! @@ -147,13 +147,13 @@ void wxLogStatus(wxFrame *pFrame, const char *szFormat, ...) } // same as info, but only if 'verbose' mode is on -void wxLogVerbose(const char *szFormat, ...) +void wxLogVerbose(const wxChar *szFormat, ...) { wxLog *pLog = wxLog::GetActiveTarget(); if ( pLog != NULL && pLog->GetVerbose() ) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL)); @@ -163,33 +163,33 @@ void wxLogVerbose(const char *szFormat, ...) // debug functions #ifdef __WXDEBUG__ #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \ - void wxLog##level(const char *szFormat, ...) \ + void wxLog##level(const wxChar *szFormat, ...) \ { \ if ( wxLog::GetActiveTarget() != NULL ) { \ va_list argptr; \ va_start(argptr, szFormat); \ - vsprintf(s_szBuf, szFormat, argptr); \ + wxVsprintf(s_szBuf, szFormat, argptr); \ va_end(argptr); \ \ wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \ } \ } - void wxLogTrace(const char *mask, const char *szFormat, ...) + void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...) { wxLog *pLog = wxLog::GetActiveTarget(); if ( pLog != NULL && wxLog::IsAllowedTraceMask(mask) ) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); } } - void wxLogTrace(wxTraceMask mask, const char *szFormat, ...) + void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...) { wxLog *pLog = wxLog::GetActiveTarget(); @@ -199,7 +199,7 @@ void wxLogVerbose(const char *szFormat, ...) if ( pLog != NULL && ((pLog->GetTraceMask() & mask) == mask) ) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); @@ -219,28 +219,28 @@ IMPLEMENT_LOG_DEBUG_FUNCTION(Trace) // common part of both wxLogSysError void wxLogSysErrorHelper(long lErrCode) { - char szErrMsg[LOG_BUFFER_SIZE / 2]; - sprintf(szErrMsg, _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode)); - strncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - strlen(s_szBuf)); + wxChar szErrMsg[LOG_BUFFER_SIZE / 2]; + wxSprintf(szErrMsg, _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode)); + wxStrncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - wxStrlen(s_szBuf)); wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL)); } -void WXDLLEXPORT wxLogSysError(const char *szFormat, ...) +void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLogSysErrorHelper(wxSysErrorCode()); } -void WXDLLEXPORT wxLogSysError(long lErrCode, const char *szFormat, ...) +void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...) { va_list argptr; va_start(argptr, szFormat); - vsprintf(s_szBuf, szFormat, argptr); + wxVsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLogSysErrorHelper(lErrCode); @@ -311,7 +311,7 @@ void wxLog::RemoveTraceMask(const wxString& str) ms_aTraceMasks.Remove((size_t)index); } -void wxLog::DoLog(wxLogLevel level, const char *szString, time_t t) +void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { wxString str; @@ -354,9 +354,9 @@ void wxLog::DoLog(wxLogLevel level, const char *szString, time_t t) } } -void wxLog::DoLogString(const char *WXUNUSED(szString), time_t t) +void wxLog::DoLogString(const wxChar *WXUNUSED(szString), time_t t) { - wxFAIL_MSG("DoLogString must be overriden if it's called."); + wxFAIL_MSG(_T("DoLogString must be overriden if it's called.")); } void wxLog::Flush() @@ -376,18 +376,18 @@ wxLogStderr::wxLogStderr(FILE *fp) m_fp = fp; } -void wxLogStderr::DoLogString(const char *szString, time_t t) +void wxLogStderr::DoLogString(const wxChar *szString, time_t t) { wxString str(szString); - str << '\n'; + str << _T('\n'); - fputs(str, m_fp); + fputs(str.mb_str(), m_fp); fflush(m_fp); // under Windows, programs usually don't have stderr at all, so make show the // messages also under debugger #ifdef __WXMSW__ - OutputDebugString(str + '\r'); + OutputDebugString(str + _T('\r')); #endif // MSW } @@ -404,7 +404,7 @@ wxLogStream::wxLogStream(ostream *ostr) m_ostr = ostr; } -void wxLogStream::DoLogString(const char *szString, time_t t) +void wxLogStream::DoLogString(const wxChar *szString, time_t t) { (*m_ostr) << szString << endl << flush; } @@ -469,10 +469,10 @@ void wxLogGui::Flush() if ( nLines > 25 ) // don't put too many lines in message box break; - str << m_aMessages[n - 1] << "\n"; + str << m_aMessages[n - 1] << _T("\n"); } - const char *title; + const wxChar *title; long style; if ( m_bErrors ) { @@ -496,7 +496,7 @@ void wxLogGui::Flush() // the default behaviour is to discard all informational messages if there // are any errors/warnings. -void wxLogGui::DoLog(wxLogLevel level, const char *szString, time_t t) +void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { switch ( level ) { case wxLOG_Info: @@ -532,12 +532,12 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString, time_t t) #ifdef __WXMSW__ // don't prepend debug/trace here: it goes to the // debug window anyhow, but do put a timestamp - OutputDebugString(wxString(szString) + "\n\r"); + OutputDebugString(wxString(szString) + _T("\n\r")); #else // send them to stderr fprintf(stderr, "%s: %s\n", level == wxLOG_Trace ? "Trace" : "Debug", - szString); + (const char*)wxConv_libc.cWX2MB(szString)); fflush(stderr); #endif } @@ -586,7 +586,7 @@ class wxLogFrame : public wxFrame { public: // ctor & dtor - wxLogFrame(wxFrame *pParent, wxLogWindow *log, const char *szTitle); + wxLogFrame(wxFrame *pParent, wxLogWindow *log, const wxChar *szTitle); virtual ~wxLogFrame(); // menu callbacks @@ -626,7 +626,7 @@ BEGIN_EVENT_TABLE(wxLogFrame, wxFrame) EVT_CLOSE(wxLogFrame::OnCloseWindow) END_EVENT_TABLE() -wxLogFrame::wxLogFrame(wxFrame *pParent, wxLogWindow *log, const char *szTitle) +wxLogFrame::wxLogFrame(wxFrame *pParent, wxLogWindow *log, const wxChar *szTitle) : wxFrame(pParent, -1, szTitle) { m_log = log; @@ -667,7 +667,7 @@ void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event)) { // get the file name // ----------------- - const char *szFileName = wxSaveFileSelector("log", "txt", "log.txt"); + const wxChar *szFileName = wxSaveFileSelector(_T("log"), _T("txt"), _T("log.txt")); if ( szFileName == NULL ) { // cancelled return; @@ -747,7 +747,7 @@ wxLogFrame::~wxLogFrame() // wxLogWindow // ----------- wxLogWindow::wxLogWindow(wxFrame *pParent, - const char *szTitle, + const wxChar *szTitle, bool bShow, bool bDoPass) { @@ -773,7 +773,7 @@ void wxLogWindow::Flush() m_bHasMessages = FALSE; } -void wxLogWindow::DoLog(wxLogLevel level, const char *szString, time_t t) +void wxLogWindow::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { // first let the previous logger show it if ( m_pOldLog != NULL && m_bPassMessages ) { @@ -812,7 +812,7 @@ void wxLogWindow::DoLog(wxLogLevel level, const char *szString, time_t t) m_bHasMessages = TRUE; } -void wxLogWindow::DoLogString(const char *szString, time_t t) +void wxLogWindow::DoLogString(const wxChar *szString, time_t t) { // put the text into our window wxTextCtrl *pText = m_pLogFrame->TextCtrl(); @@ -824,7 +824,7 @@ void wxLogWindow::DoLogString(const char *szString, time_t t) #endif // Windows pText->WriteText(szString); - pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n") + pText->WriteText(_T("\n")); // "\n" ok here (_not_ "\r\n") // TODO ensure that the line can be seen } @@ -924,14 +924,14 @@ unsigned long wxSysErrorCode() } // get error message from system -const char *wxSysErrorMsg(unsigned long nErrCode) +const wxChar *wxSysErrorMsg(unsigned long nErrCode) { if ( nErrCode == 0 ) nErrCode = wxSysErrorCode(); #ifdef __WXMSW__ #ifdef __WIN32__ - static char s_szBuf[LOG_BUFFER_SIZE / 2]; + static wxChar s_szBuf[LOG_BUFFER_SIZE / 2]; // get error message from system LPVOID lpMsgBuf; @@ -942,17 +942,17 @@ const char *wxSysErrorMsg(unsigned long nErrCode) 0, NULL); // copy it to our buffer and free memory - strncpy(s_szBuf, (const char *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); - s_szBuf[WXSIZEOF(s_szBuf) - 1] = '\0'; + wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); + s_szBuf[WXSIZEOF(s_szBuf) - 1] = _T('\0'); LocalFree(lpMsgBuf); // returned string is capitalized and ended with '\r\n' - bad - s_szBuf[0] = (char)tolower(s_szBuf[0]); - size_t len = strlen(s_szBuf); + s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]); + size_t len = wxStrlen(s_szBuf); if ( len > 0 ) { // truncate string - if ( s_szBuf[len - 2] == '\r' ) - s_szBuf[len - 2] = '\0'; + if ( s_szBuf[len - 2] == _T('\r') ) + s_szBuf[len - 2] = _T('\0'); } return s_szBuf; @@ -961,7 +961,13 @@ const char *wxSysErrorMsg(unsigned long nErrCode) return NULL; #endif // Win16/32 #else // Unix +#if wxUSE_UNICODE + static wxChar s_szBuf[LOG_BUFFER_SIZE / 2]; + wxConv_libc.MB2WC(s_szBuf, strerror(nErrCode), WXSIZEOF(s_szBuf) -1); + return s_szBuf; +#else return strerror(nErrCode); +#endif #endif // Win/Unix } @@ -990,7 +996,7 @@ void Trap() } // this function is called when an assert fails -void wxOnAssert(const char *szFile, int nLine, const char *szMsg) +void wxOnAssert(const char *szFile, int nLine, const wxChar *szMsg) { // this variable can be set to true to suppress "assert failure" messages static bool s_bNoAsserts = FALSE; @@ -1007,23 +1013,27 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) s_bInAssert = TRUE; - char szBuf[LOG_BUFFER_SIZE]; + wxChar szBuf[LOG_BUFFER_SIZE]; // make life easier for people using VC++ IDE: clicking on the message // will take us immediately to the place of the failed assert #ifdef __VISUALC__ - sprintf(szBuf, "%s(%d): assert failed", szFile, nLine); + sprintf(szBuf, _T("%s(%d): assert failed"), szFile, nLine); #else // !VC++ // make the error message more clear for all the others - sprintf(szBuf, "Assert failed in file %s at line %d", szFile, nLine); +#ifdef wxSprintf + wxSprintf(szBuf, _T("Assert failed in file %s at line %d"), szFile, nLine); +#else + wxSprintf(szBuf, _T("Assert failed in file %hs at line %d"), szFile, nLine); +#endif #endif // VC/!VC if ( szMsg != NULL ) { - strcat(szBuf, ": "); - strcat(szBuf, szMsg); + wxStrcat(szBuf, _T(": ")); + wxStrcat(szBuf, szMsg); } else { - strcat(szBuf, "."); + wxStrcat(szBuf, _T(".")); } if ( !s_bNoAsserts ) { @@ -1035,9 +1045,9 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) #else // this message is intentionally not translated - it is for // developpers only - strcat(szBuf, "\nDo you want to stop the program?" + wxStrcat(szBuf, _T("\nDo you want to stop the program?" "\nYou can also choose [Cancel] to suppress " - "further warnings."); + "further warnings.")); switch ( wxMessageBox(szBuf, _("Debug"), wxYES_NO | wxCANCEL | wxICON_STOP ) ) { diff --git a/src/common/mimetype.cpp b/src/common/mimetype.cpp index 4cc2d843db..901d85ffb1 100644 --- a/src/common/mimetype.cpp +++ b/src/common/mimetype.cpp @@ -233,7 +233,7 @@ public: break; } - wxASSERT_MSG( n == pos, "invalid position in MailCapEntry::Insert" ); + wxASSERT_MSG( n == pos, _T("invalid position in MailCapEntry::Insert") ); m_next = cur->m_next; cur->m_next = this; @@ -241,7 +241,7 @@ public: // append this element to the list void Append(MailCapEntry *next) { - wxCHECK_RET( next != NULL, "Append()ing to what?" ); + wxCHECK_RET( next != NULL, _T("Append()ing to what?") ); // FIXME slooow... MailCapEntry *cur; @@ -250,7 +250,7 @@ public: cur->m_next = this; - wxASSERT_MSG( !m_next, "Append()ing element already in the list?" ); + wxASSERT_MSG( !m_next, _T("Append()ing element already in the list?") ); } private: @@ -349,57 +349,57 @@ wxString wxFileType::ExpandCommand(const wxString& command, bool hasFilename = FALSE; wxString str; - for ( const char *pc = command.c_str(); *pc != '\0'; pc++ ) { - if ( *pc == '%' ) { + for ( const wxChar *pc = command.c_str(); *pc != _T('\0'); pc++ ) { + if ( *pc == _T('%') ) { switch ( *++pc ) { - case 's': + case _T('s'): // '%s' expands into file name (quoted because it might // contain spaces) - except if there are already quotes // there because otherwise some programs may get confused // by double double quotes #if 0 - if ( *(pc - 2) == '"' ) + if ( *(pc - 2) == _T('"') ) str << params.GetFileName(); else - str << '"' << params.GetFileName() << '"'; + str << _T('"') << params.GetFileName() << _T('"'); #endif str << params.GetFileName(); hasFilename = TRUE; break; - case 't': + case _T('t'): // '%t' expands into MIME type (quote it too just to be // consistent) - str << '\'' << params.GetMimeType() << '\''; + str << _T('\'') << params.GetMimeType() << _T('\''); break; - case '{': + case _T('{'): { - const char *pEnd = strchr(pc, '}'); + const wxChar *pEnd = wxStrchr(pc, _T('}')); if ( pEnd == NULL ) { wxString mimetype; wxLogWarning(_("Unmatched '{' in an entry for " "mime type %s."), params.GetMimeType().c_str()); - str << "%{"; + str << _T("%{"); } else { wxString param(pc + 1, pEnd - pc - 1); - str << '\'' << params.GetParamValue(param) << '\''; + str << _T('\'') << params.GetParamValue(param) << _T('\''); pc = pEnd; } } break; - case 'n': - case 'F': + case _T('n'): + case _T('F'): // TODO %n is the number of parts, %F is an array containing // the names of temp files these parts were written to // and their mime types. break; default: - wxLogDebug("Unknown field %%%c in command '%s'.", + wxLogDebug(_T("Unknown field %%%c in command '%s'."), *pc, command.c_str()); str << *pc; } @@ -412,7 +412,7 @@ wxString wxFileType::ExpandCommand(const wxString& command, // metamail(1) man page states that if the mailcap entry doesn't have '%s' // the program will accept the data on stdin: so give it to it! if ( !hasFilename && !str.IsEmpty() ) { - str << " < '" << params.GetFileName() << '\''; + str << _T(" < '") << params.GetFileName() << _T('\''); } return str; @@ -469,16 +469,16 @@ wxFileType::GetPrintCommand(wxString *printCmd, bool wxMimeTypesManager::IsOfType(const wxString& mimeType, const wxString& wildcard) { - wxASSERT_MSG( mimeType.Find('*') == wxNOT_FOUND, - "first MIME type can't contain wildcards" ); + wxASSERT_MSG( mimeType.Find(_T('*')) == wxNOT_FOUND, + _T("first MIME type can't contain wildcards") ); // all comparaisons are case insensitive (2nd arg of IsSameAs() is FALSE) - if ( wildcard.BeforeFirst('/').IsSameAs(mimeType.BeforeFirst('/'), FALSE) ) + if ( wildcard.BeforeFirst(_T('/')).IsSameAs(mimeType.BeforeFirst(_T('/')), FALSE) ) { - wxString strSubtype = wildcard.AfterFirst('/'); + wxString strSubtype = wildcard.AfterFirst(_T('/')); - if ( strSubtype == '*' || - strSubtype.IsSameAs(mimeType.AfterFirst('/'), FALSE) ) + if ( strSubtype == _T('*') || + strSubtype.IsSameAs(mimeType.AfterFirst(_T('/')), FALSE) ) { // matches (either exactly or it's a wildcard) return TRUE; @@ -526,27 +526,27 @@ bool wxMimeTypesManager::ReadMimeTypes(const wxString& filename) #ifdef __WXMSW__ -bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const +bool wxFileTypeImpl::GetCommand(wxString *command, const wxChar *verb) const { // suppress possible error messages wxLogNull nolog; wxString strKey; - strKey << m_strFileType << "\\shell\\" << verb << "\\command"; + strKey << m_strFileType << _T("\\shell\\") << verb << _T("\\command"); wxRegKey key(wxRegKey::HKCR, strKey); if ( key.Open() ) { // it's the default value of the key - if ( key.QueryValue("", *command) ) { + if ( key.QueryValue(_T(""), *command) ) { // transform it from '%1' to '%s' style format string // NB: we don't make any attempt to verify that the string is valid, // i.e. doesn't contain %2, or second %1 or .... But we do make // sure that we return a string with _exactly_ one '%s'! size_t len = command->Len(); for ( size_t n = 0; n < len; n++ ) { - if ( command->GetChar(n) == '%' && - (n + 1 < len) && command->GetChar(n + 1) == '1' ) { + if ( command->GetChar(n) == _T('%') && + (n + 1 < len) && command->GetChar(n + 1) == _T('1') ) { // replace it with '%s' - command->SetChar(n + 1, 's'); + command->SetChar(n + 1, _T('s')); return TRUE; } @@ -554,7 +554,7 @@ bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const // we didn't find any '%1'! // HACK: append the filename at the end, hope that it will do - *command << " %s"; + *command << _T(" %s"); return TRUE; } @@ -585,8 +585,8 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const { // suppress possible error messages wxLogNull nolog; - wxRegKey key(wxRegKey::HKCR, /*m_strFileType*/ "." + m_ext); - if ( key.Open() && key.QueryValue("Content Type", *mimeType) ) { + wxRegKey key(wxRegKey::HKCR, /*m_strFileType*/ _T(".") + m_ext); + if ( key.Open() && key.QueryValue(_T("Content Type"), *mimeType) ) { return TRUE; } else { @@ -597,7 +597,7 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const bool wxFileTypeImpl::GetIcon(wxIcon *icon) const { wxString strIconKey; - strIconKey << m_strFileType << "\\DefaultIcon"; + strIconKey << m_strFileType << _T("\\DefaultIcon"); // suppress possible error messages wxLogNull nolog; @@ -606,18 +606,18 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon) const if ( key.Open() ) { wxString strIcon; // it's the default value of the key - if ( key.QueryValue("", strIcon) ) { + if ( key.QueryValue(_T(""), strIcon) ) { // the format is the following: , // NB: icon index may be negative as well as positive and the full // path may contain the environment variables inside '%' - wxString strFullPath = strIcon.BeforeLast(','), - strIndex = strIcon.AfterLast(','); + wxString strFullPath = strIcon.BeforeLast(_T(',')), + strIndex = strIcon.AfterLast(_T(',')); // index may be omitted, in which case BeforeLast(',') is empty and // AfterLast(',') is the whole string if ( strFullPath.IsEmpty() ) { strFullPath = strIndex; - strIndex = "0"; + strIndex = _T("0"); } wxString strExpPath = wxExpandEnvVars(strFullPath); @@ -627,7 +627,7 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon) const switch ( (int)hIcon ) { case 0: // means no icons were found case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/... - wxLogDebug("incorrect registry entry '%s': no such icon.", + wxLogDebug(_T("incorrect registry entry '%s': no such icon."), key.GetName().c_str()); break; @@ -650,7 +650,7 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const if ( key.Open() ) { // it's the default value of the key - if ( key.QueryValue("", *desc) ) { + if ( key.QueryValue(_T(""), *desc) ) { return TRUE; } } @@ -664,8 +664,8 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) { // add the leading point if necessary wxString str; - if ( ext[0u] != '.' ) { - str = '.'; + if ( ext[0u] != _T('.') ) { + str = _T('.'); } str << ext; @@ -676,7 +676,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) wxRegKey key(wxRegKey::HKCR, str); if ( key.Open() ) { // it's the default value of the key - if ( key.QueryValue("", strFileType) ) { + if ( key.QueryValue(_T(""), strFileType) ) { // create the new wxFileType object wxFileType *fileType = new wxFileType; fileType->m_impl->SetFileType(strFileType); @@ -696,7 +696,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) { // HACK I don't know of any official documentation which mentions this // location, but as a matter of fact IE uses it, so why not we? - static const char *szMimeDbase = "MIME\\Database\\Content Type\\"; + static const wxChar *szMimeDbase = _T("MIME\\Database\\Content Type\\"); wxString strKey = szMimeDbase; strKey << mimeType; @@ -707,7 +707,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) wxString ext; wxRegKey key(wxRegKey::HKCR, strKey); if ( key.Open() ) { - if ( key.QueryValue("Extension", ext) ) { + if ( key.QueryValue(_T("Extension"), ext) ) { return GetFileTypeFromExtension(ext); } } @@ -727,14 +727,14 @@ wxFileTypeImpl::GetEntry(const wxFileType::MessageParameters& params) const // notice that an empty command would always succeed (it's ok) command = wxFileType::ExpandCommand(entry->GetTestCmd(), params); - if ( command.IsEmpty() || (system(command) == 0) ) { + if ( command.IsEmpty() || (wxSystem(command) == 0) ) { // ok, passed - wxLogTrace("Test '%s' for mime type '%s' succeeded.", + wxLogTrace(_T("Test '%s' for mime type '%s' succeeded."), command.c_str(), params.GetMimeType().c_str()); break; } else { - wxLogTrace("Test '%s' for mime type '%s' failed.", + wxLogTrace(_T("Test '%s' for mime type '%s' failed."), command.c_str(), params.GetMimeType().c_str()); } @@ -772,8 +772,8 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) // one extension in the space or comma delimitid list wxString strExt; - for ( const char *p = strExtensions; ; p++ ) { - if ( *p == ' ' || *p == ',' || *p == '\0' ) { + for ( const wxChar *p = strExtensions; ; p++ ) { + if ( *p == _T(' ') || *p == _T(',') || *p == _T('\0') ) { if ( !strExt.IsEmpty() ) { extensions.Add(strExt); strExt.Empty(); @@ -781,13 +781,13 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) //else: repeated spaces (shouldn't happen, but it's not that // important if it does happen) - if ( *p == '\0' ) + if ( *p == _T('\0') ) break; } - else if ( *p == '.' ) { + else if ( *p == _T('.') ) { // remove the dot from extension (but only if it's the first char) if ( !strExt.IsEmpty() ) { - strExt += '.'; + strExt += _T('.'); } //else: no, don't append it } @@ -804,40 +804,40 @@ wxMimeTypesManagerImpl::wxMimeTypesManagerImpl() { // directories where we look for mailcap and mime.types by default // (taken from metamail(1) sources) - static const char *aStandardLocations[] = + static const wxChar *aStandardLocations[] = { - "/etc", - "/usr/etc", - "/usr/local/etc", - "/etc/mail", - "/usr/public/lib" + _T("/etc"), + _T("/usr/etc"), + _T("/usr/local/etc"), + _T("/etc/mail"), + _T("/usr/public/lib") }; // first read the system wide file(s) for ( size_t n = 0; n < WXSIZEOF(aStandardLocations); n++ ) { wxString dir = aStandardLocations[n]; - wxString file = dir + "/mailcap"; + wxString file = dir + _T("/mailcap"); if ( wxFile::Exists(file) ) { ReadMailcap(file); } - file = dir + "/mime.types"; + file = dir + _T("/mime.types"); if ( wxFile::Exists(file) ) { ReadMimeTypes(file); } } - wxString strHome = getenv("HOME"); + wxString strHome = wxGetenv(_T("HOME")); // and now the users mailcap - wxString strUserMailcap = strHome + "/.mailcap"; + wxString strUserMailcap = strHome + _T("/.mailcap"); if ( wxFile::Exists(strUserMailcap) ) { ReadMailcap(strUserMailcap); } // read the users mime.types - wxString strUserMimeTypes = strHome + "/.mime.types"; + wxString strUserMimeTypes = strHome + _T("/.mime.types"); if ( wxFile::Exists(strUserMimeTypes) ) { ReadMimeTypes(strUserMimeTypes); } @@ -850,8 +850,8 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) for ( size_t n = 0; n < count; n++ ) { wxString extensions = m_aExtensions[n]; while ( !extensions.IsEmpty() ) { - wxString field = extensions.BeforeFirst(' '); - extensions = extensions.AfterFirst(' '); + wxString field = extensions.BeforeFirst(_T(' ')); + extensions = extensions.AfterFirst(_T(' ')); // consider extensions as not being case-sensitive if ( field.IsSameAs(ext, FALSE /* no case */) ) { @@ -881,12 +881,12 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) // then try to find "text/*" as match for "text/plain" (for example) // NB: if mimeType doesn't contain '/' at all, BeforeFirst() will return // the whole string - ok. - wxString strCategory = mimetype.BeforeFirst('/'); + wxString strCategory = mimetype.BeforeFirst(_T('/')); size_t nCount = m_aTypes.Count(); for ( size_t n = 0; n < nCount; n++ ) { - if ( (m_aTypes[n].BeforeFirst('/') == strCategory ) && - m_aTypes[n].AfterFirst('/') == "*" ) { + if ( (m_aTypes[n].BeforeFirst(_T('/')) == strCategory ) && + m_aTypes[n].AfterFirst(_T('/')) == _T("*") ) { index = n; break; } @@ -907,7 +907,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) { - wxLogTrace("--- Parsing mime.types file '%s' ---", strFileName.c_str()); + wxLogTrace(_T("--- Parsing mime.types file '%s' ---"), strFileName.c_str()); wxTextFile file(strFileName); if ( !file.Open() ) @@ -917,7 +917,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) wxString strMimeType, strDesc, strExtensions; size_t nLineCount = file.GetLineCount(); - const char *pc = NULL; + const wxChar *pc = NULL; for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) { if ( pc == NULL ) { // now we're at the start of the line @@ -929,29 +929,29 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) } // skip whitespace - while ( isspace(*pc) ) + while ( wxIsspace(*pc) ) pc++; // comment? - if ( *pc == '#' ) { + if ( *pc == _T('#') ) { // skip the whole line pc = NULL; continue; } // detect file format - const char *pEqualSign = strchr(pc, '='); + const wxChar *pEqualSign = wxStrchr(pc, _T('=')); if ( pEqualSign == NULL ) { // brief format // ------------ // first field is mime type - for ( strMimeType.Empty(); !isspace(*pc) && *pc != '\0'; pc++ ) { + for ( strMimeType.Empty(); !wxIsspace(*pc) && *pc != _T('\0'); pc++ ) { strMimeType += *pc; } // skip whitespace - while ( isspace(*pc) ) + while ( wxIsspace(*pc) ) pc++; // take all the rest of the string @@ -968,13 +968,13 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) wxString strLHS(pc, pEqualSign - pc); // eat whitespace - for ( pc = pEqualSign + 1; isspace(*pc); pc++ ) + for ( pc = pEqualSign + 1; wxIsspace(*pc); pc++ ) ; - const char *pEnd; - if ( *pc == '"' ) { + const wxChar *pEnd; + if ( *pc == _T('"') ) { // the string is quoted and ends at the matching quote - pEnd = strchr(++pc, '"'); + pEnd = wxStrchr(++pc, _T('"')); if ( pEnd == NULL ) { wxLogWarning(_("Mime.types file %s, line %d: unterminated " "quoted string."), @@ -983,7 +983,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) } else { // unquoted string ends at the first space - for ( pEnd = pc; !isspace(*pEnd); pEnd++ ) + for ( pEnd = pc; !wxIsspace(*pEnd); pEnd++ ) ; } @@ -991,30 +991,30 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) wxString strRHS(pc, pEnd - pc); // check what follows this entry - if ( *pEnd == '"' ) { + if ( *pEnd == _T('"') ) { // skip this quote pEnd++; } - for ( pc = pEnd; isspace(*pc); pc++ ) + for ( pc = pEnd; wxIsspace(*pc); pc++ ) ; // if there is something left, it may be either a '\\' to continue // the line or the next field of the same entry - bool entryEnded = *pc == '\0', + bool entryEnded = *pc == _T('\0'), nextFieldOnSameLine = FALSE; if ( !entryEnded ) { - nextFieldOnSameLine = ((*pc != '\\') || (pc[1] != '\0')); + nextFieldOnSameLine = ((*pc != _T('\\')) || (pc[1] != _T('\0'))); } // now see what we got - if ( strLHS == "type" ) { + if ( strLHS == _T("type") ) { strMimeType = strRHS; } - else if ( strLHS == "desc" ) { + else if ( strLHS == _T("desc") ) { strDesc = strRHS; } - else if ( strLHS == "exts" ) { + else if ( strLHS == _T("exts") ) { strExtensions = strRHS; } else { @@ -1037,10 +1037,10 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) // although it doesn't seem to be covered by RFCs, some programs // (notably Netscape) create their entries with several comma // separated extensions (RFC mention the spaces only) - strExtensions.Replace(",", " "); + strExtensions.Replace(_T(","), _T(" ")); // also deal with the leading dot - if ( !strExtensions.IsEmpty() && strExtensions[0] == '.' ) { + if ( !strExtensions.IsEmpty() && strExtensions[0] == _T('.') ) { strExtensions.erase(0, 1); } @@ -1075,7 +1075,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, bool fallback) { - wxLogTrace("--- Parsing mailcap file '%s' ---", strFileName.c_str()); + wxLogTrace(_T("--- Parsing mailcap file '%s' ---"), strFileName.c_str()); wxTextFile file(strFileName); if ( !file.Open() ) @@ -1092,14 +1092,14 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, size_t nLineCount = file.GetLineCount(); for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) { // now we're at the start of the line - const char *pc = file[nLine].c_str(); + const wxChar *pc = file[nLine].c_str(); // skip whitespace - while ( isspace(*pc) ) + while ( wxIsspace(*pc) ) pc++; // comment or empty string? - if ( *pc == '#' || *pc == '\0' ) + if ( *pc == _T('#') || *pc == _T('\0') ) continue; // no, do parse @@ -1125,10 +1125,10 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, curField; // accumulator for ( bool cont = TRUE; cont; pc++ ) { switch ( *pc ) { - case '\\': + case _T('\\'): // interpret the next character literally (notice that // backslash can be used for line continuation) - if ( *++pc == '\0' ) { + if ( *++pc == _T('\0') ) { // fetch the next line. // pc currently points to nowhere, but after the next @@ -1142,12 +1142,12 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, } break; - case '\0': + case _T('\0'): cont = FALSE; // end of line reached, exit the loop // fall through - case ';': + case _T(';'): // store this field and start looking for the next one // trim whitespaces from both sides @@ -1156,9 +1156,9 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, switch ( currentToken ) { case Field_Type: strType = curField; - if ( strType.Find('/') == wxNOT_FOUND ) { + if ( strType.Find(_T('/')) == wxNOT_FOUND ) { // we interpret "type" as "type/*" - strType += "/*"; + strType += _T("/*"); } currentToken = Field_OpenCmd; @@ -1176,22 +1176,22 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, bool ok = TRUE; // is this something of the form foo=bar? - const char *pEq = strchr(curField, '='); + const wxChar *pEq = wxStrchr(curField, _T('=')); if ( pEq != NULL ) { - wxString lhs = curField.BeforeFirst('='), - rhs = curField.AfterFirst('='); + wxString lhs = curField.BeforeFirst(_T('=')), + rhs = curField.AfterFirst(_T('=')); lhs.Trim(TRUE); // from right rhs.Trim(FALSE); // from left - if ( lhs == "print" ) + if ( lhs == _T("print") ) strPrintCmd = rhs; - else if ( lhs == "test" ) + else if ( lhs == _T("test") ) strTest = rhs; - else if ( lhs == "description" ) { + else if ( lhs == _T("description") ) { // it might be quoted - if ( rhs[0u] == '"' && - rhs.Last() == '"' ) { + if ( rhs[0u] == _T('"') && + rhs.Last() == _T('"') ) { strDesc = wxString(rhs.c_str() + 1, rhs.Len() - 2); } @@ -1199,10 +1199,10 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, strDesc = rhs; } } - else if ( lhs == "compose" || - lhs == "composetyped" || - lhs == "notes" || - lhs == "edit" ) + else if ( lhs == _T("compose") || + lhs == _T("composetyped") || + lhs == _T("notes") || + lhs == _T("edit") ) ; // ignore else ok = FALSE; @@ -1213,11 +1213,11 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, // TODO support the flags: // 1. create an xterm for 'needsterminal' // 2. append "| $PAGER" for 'copiousoutput' - if ( curField == "needsterminal" ) + if ( curField == _T("needsterminal") ) needsterminal = TRUE; - else if ( curField == "copiousoutput" ) + else if ( curField == _T("copiousoutput") ) copiousoutput = TRUE; - else if ( curField == "textualnewlines" ) + else if ( curField == _T("textualnewlines") ) ; // ignore else ok = FALSE; @@ -1232,9 +1232,9 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, // programmer wxLogDebug ( - "Mailcap file %s, line %d: unknown " + _T("Mailcap file %s, line %d: unknown " "field '%s' for the MIME type " - "'%s' ignored.", + "'%s' ignored."), strFileName.c_str(), nLine + 1, curField.c_str(), @@ -1248,7 +1248,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, break; default: - wxFAIL_MSG("unknown field type in mailcap"); + wxFAIL_MSG(_T("unknown field type in mailcap")); } // next token starts immediately after ';' @@ -1278,7 +1278,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, m_aTypes.Add(strType); m_aEntries.Add(entry); - m_aExtensions.Add(""); + m_aExtensions.Add(_T("")); m_aDescriptions.Add(strDesc); } else {