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();
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());
wxString str;
if (Read(key, & str))
{
- *val = atof(str);
+ *val = wxAtof(str);
return TRUE;
}
else
bool wxConfigBase::Write(const wxString& key, double val)
{
wxString str;
- str.Printf("%f", val);
+ str.Printf(_T("%f"), val);
return Write(key, 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;
}
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 {
#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 };
{
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 ();
{
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 ();
ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt)
{
- return os << (const char *) dt.FormatDate();
+ return os << (const wxChar *) dt.FormatDate();
}
//////////////////////////////////////////////////////////////
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 )
#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"
// function prototypes
// ----------------------------------------------------------------------------
-static inline wxString FindExtension(const char *path);
+static inline wxString FindExtension(const wxChar *path);
// ============================================================================
// implementation
// local functions
// ----------------------------------------------------------------------------
-static wxString FindExtension(const char *path)
+static wxString FindExtension(const wxChar *path)
{
wxString ext;
wxSplitPath(path, NULL, NULL, &ext);
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,
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,
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());
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;
{
// 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())
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++)
if (templates[i]->IsVisible())
{
strings[n] = WXSTRINGCAST templates[i]->m_description;
- data[n] = (char *)templates[i];
+ data[n] = (wxChar *)templates[i];
n ++;
}
}
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++)
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 ++;
}
}
{
m_fileMaxFiles = maxFiles;
m_fileHistoryN = 0;
- m_fileHistory = new char *[m_fileMaxFiles];
+ m_fileHistory = new wxChar *[m_fileMaxFiles];
}
wxFileHistory::~wxFileHistory()
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)
{
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)
{
{
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();
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]));
}
}
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);
}
}
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);
}
}
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)
FILE *fd1;
int ch;
- if ((fd1 = fopen (WXSTRINGCAST filename, "wb")) == NULL)
+ if ((fd1 = fopen (filename.fn_str(), "wb")) == NULL)
{
return FALSE;
}
// 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();
// 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));
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);
}
// ----------------------------------------------------------------------------
#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;
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 )
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());
case 3:
return RightDClick();
default:
- wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDClick");
+ wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDClick"));
}
return FALSE;
case 3:
return RightDown();
default:
- wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDown");
+ wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDown"));
}
return FALSE;
case 3:
return RightUp();
default:
- wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonUp");
+ wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonUp"));
}
return FALSE;
case 3:
return (RightDown() || RightUp() || RightDClick());
default:
- wxFAIL_MSG("invalid parameter in wxMouseEvent::Button");
+ wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::Button"));
}
return FALSE;
case 3:
return RightIsDown();
default:
- wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonIsDown");
+ wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonIsDown"));
}
return FALSE;
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();
// ----------------------------------------------------------------------------
// 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;
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;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ctors
-wxFile::wxFile(const char *szFileName, OpenMode mode)
+wxFile::wxFile(const wxChar *szFileName, OpenMode mode)
{
m_fd = fd_invalid;
m_error = FALSE;
}
// 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));
}
// 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;
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);
// 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
#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()
}
else
{
- wxLogLastError("stat");
+ wxLogLastError(_T("stat"));
}
// we want to create the file with exactly the same access rights as the
{
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;
}
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());
}
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;
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;
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();
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
// 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;
}
}
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++;
while ( isspace(*pEnd) )
pEnd++;
- if ( *pEnd++ != '=' ) {
+ if ( *pEnd++ != _T('=') ) {
wxLogError(_("file '%s', line %d: '=' expected."),
file.GetName(), n + 1);
}
}
// skip whitespace
- while ( isspace(*pEnd) )
+ while ( wxIsspace(*pEnd) )
pEnd++;
pEntry->SetValue(FilterInValue(pEnd), FALSE /* read from file */);
{
wxString str;
if ( Read(key, & str) ) {
- *pl = atol(str);
+ *pl = wxAtol(str);
return TRUE;
}
else {
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();
{
// ltoa() is not ANSI :-(
wxString buf;
- buf.Printf("%ld", lValue);
+ buf.Printf(_T("%ld"), lValue);
return Write(key, buf);
}
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
{
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;
// 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
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();
if ( Parent() )
return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name();
else
- return "";
+ return _T("");
}
// ----------------------------------------------------------------------------
// 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,
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 )
}
ConfigGroup *
-ConfigGroup::FindSubgroup(const char *szName) const
+ConfigGroup::FindSubgroup(const wxChar *szName) const
{
size_t i,
lo = 0,
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 )
delete several of them.
*/
-bool ConfigGroup::DeleteSubgroupByName(const char *szName)
+bool ConfigGroup::DeleteSubgroupByName(const wxChar *szName)
{
return DeleteSubgroup(FindSubgroup(szName));
}
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?
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
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
}
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
}
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'."),
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
}
// we get here only for special characters
- strResult << '\\' << c;
+ strResult << _T('\\') << c;
}
if ( bQuote )
- strResult += '"';
+ strResult += _T('"');
return strResult;
}
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;
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;
}
#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
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));
}
}
{
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
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
}
} // for()
- return wxString(""); // Not found
+ return wxString(_T("")); // Not found
}
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);
}
}
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
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
{
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;
*
*/
-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;
size_t i = len-1;
while (i > 0)
{
- if (buffer.GetChar(i) == '.')
+ if (buffer.GetChar(i) == _T('.'))
{
buffer = buffer.Left(i);
break;
}
// 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];
{
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);
}
}
}
}
// 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 );
/* 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;
} 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--;
/* 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);
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;
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)
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;
// 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
}
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
}
}
// 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;
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__
#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
{
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;
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__
#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
#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++ ;
}
}
#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++;
}
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
if (s)
while (*s)
{
- if (*s == '/')
- *s = '\\';
+ if (*s == _T('/'))
+ *s = _T('\\');
s++;
}
#endif
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)
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);
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
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) ;
}
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);
#ifdef __VMS__
return FALSE;
#elif defined( __WXMAC__ )
- strcpy( gwxMacFileName , dir ) ;
+ wxStrcpy( gwxMacFileName , dir ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
return (rmdir(WXSTRINGCAST gwxMacFileName) == 0);
#else
#ifdef __SALFORDC__
return FALSE; // What to do?
#else
- return (rmdir(WXSTRINGCAST dir) == 0);
+ return (rmdir(FNSTRINGCAST dir.fn_str()) == 0);
#endif
#endif
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 */
#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;
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;
}
wxLogError( _("wxWindows: error finding temporary file name.\n") );
if (buf) buf[0] = 0;
- return (char *) NULL;
+ return (wxChar *) NULL;
#endif
}
static int gs_findFlags = 0;
#endif
-wxString wxFindFirstFile(const char *spec, int flags)
+wxString wxFindFirstFile(const wxChar *spec, int flags)
{
wxString result;
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'"),
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
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;
if ( !path.IsEmpty() )
{
result = path;
- if ( path != '/' )
- result += '/';
+ if ( path != _T('/') )
+ result += _T('/');
}
result += nextDir->d_name;
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;
// 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 )
goto try_again;
if ( !path.IsEmpty() )
- result << path << '\\';
+ result << path << _T('\\');
result << gs_findDataStruct.cFileName;
}
// 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;
}
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__
bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':'));
if (isDriveSpec)
{
- char firstChar = d[0];
+ wxChar firstChar = d[0];
// To upper case
if (firstChar > 90)
wxString wxGetOSDirectory()
{
#ifdef __WINDOWS__
- char buf[256];
+ wxChar buf[256];
GetWindowsDirectory(buf, 256);
return wxString(buf);
#else
}
// 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
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;
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 )
{
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);
}
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;
}
#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
*/
{
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;
}
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;
}
}
}
- while (*pattern == '*')
+ while (*pattern == _T('*'))
pattern++;
- return ((*str == '\0') && (*pattern == '\0'));
+ return ((*str == _T('\0')) && (*pattern == _T('\0')));
};
#endif
// 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}
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);
}
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;
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);
}
}
-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;
}
}
-wxObject *wxHashTable::Get (const char *key) const
+wxObject *wxHashTable::Get (const wxChar *key) const
{
int position = (int) (MakeKey (key) % n);
}
}
-wxObject *wxHashTable::Delete (const char *key)
+wxObject *wxHashTable::Delete (const wxChar *key)
{
int position = (int) (MakeKey (key) % n);
if (!hash_table[position])
}
}
-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])
}
}
-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;
}
{
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 );
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<w) && (y<h), "invalid image index" );
+ wxCHECK_RET( (x>=0) && (y>=0) && (x<w) && (y<h), _T("invalid image index") );
long pos = (y * w + x) * 3;
unsigned char wxImage::GetRed( int x, int y )
{
- wxCHECK_MSG( Ok(), 0, "invalid image" );
+ wxCHECK_MSG( Ok(), 0, _T("invalid image") );
int w = M_IMGDATA->m_width;
int h = M_IMGDATA->m_height;
- wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
+ wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
long pos = (y * w + x) * 3;
unsigned char wxImage::GetGreen( int x, int y )
{
- wxCHECK_MSG( Ok(), 0, "invalid image" );
+ wxCHECK_MSG( Ok(), 0, _T("invalid image") );
int w = M_IMGDATA->m_width;
int h = M_IMGDATA->m_height;
- wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
+ wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
long pos = (y * w + x) * 3;
unsigned char wxImage::GetBlue( int x, int y )
{
- wxCHECK_MSG( Ok(), 0, "invalid image" );
+ wxCHECK_MSG( Ok(), 0, _T("invalid image") );
int w = M_IMGDATA->m_width;
int h = M_IMGDATA->m_height;
- wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
+ wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
long pos = (y * w + x) * 3;
char unsigned *wxImage::GetData() const
{
- wxCHECK_MSG( Ok(), (char unsigned *)NULL, "invalid image" );
+ wxCHECK_MSG( Ok(), (char unsigned *)NULL, _T("invalid image") );
return M_IMGDATA->m_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;
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;
}
}
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;
}
}
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;
}
if (handler == NULL)
{
- wxLogWarning( "No image handler for type %d defined.", type );
+ wxLogWarning( _T("No image handler for type %d defined."), type );
return FALSE;
}
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;
}
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;
}
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;
}
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);
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);
/* 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)
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;
}
}
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;
{
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;
// 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() );
// 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;
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;
}
// check the bitmap
if( !bitmap.Ok() )
{
- wxFAIL_MSG( "invalid bitmap" );
+ wxFAIL_MSG( _T("invalid bitmap") );
return;
}
unsigned char *data = GetData();
if( !data )
{
- wxFAIL_MSG( "could not allocate data for image" );
+ wxFAIL_MSG( _T("could not allocate data for image") );
return;
}
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;
}
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;
{
wxBitmap bitmap;
- wxCHECK_MSG( Ok(), bitmap, "invalid image" );
+ wxCHECK_MSG( Ok(), bitmap, _T("invalid image") );
int width = GetWidth();
int height = GetHeight();
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();
if (!data)
{
gdk_image_destroy( gdk_image );
- wxFAIL_MSG( "couldn't create image" );
+ wxFAIL_MSG( _T("couldn't create image") );
return;
}
{
wxBitmap bitmap;
- wxCHECK_MSG( Ok(), bitmap, "invalid image" );
+ wxCHECK_MSG( Ok(), bitmap, _T("invalid image") );
int width = GetWidth();
int height = GetHeight();
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 ) );
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();
if (!data)
{
XDestroyImage( ximage );
- wxFAIL_MSG( "couldn't create image" );
+ wxFAIL_MSG( _T("couldn't create image") );
return;
}
};
IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule)
-
decod = new gifDecoder(&stream);
if (decod -> readgif(&igif) != E_OK) {
- wxLogDebug("Error reading GIF");
+ wxLogDebug(_T("Error reading GIF"));
delete decod;
return FALSE;
}
bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream )
{
- wxLogDebug("wxGIFHandler is read-only!!");
+ wxLogDebug(_T("wxGIFHandler is read-only!!"));
return FALSE;
}
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;
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 )
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
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;
{
// 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);
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);
{
// 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;
}
}
- wxFAIL_MSG( "invalid index in wxListBase::Item" );
+ wxFAIL_MSG( _T("invalid index in wxListBase::Item") );
return (wxNodeBase *)NULL;
}
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() )
{
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
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;
// 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;
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)
}
// 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
}
// 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;
}
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;
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() )
#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));
}
#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)); \
// 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!
}
// 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));
// 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();
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));
// 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);
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;
}
}
-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()
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
}
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;
}
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 ) {
// 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:
#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
}
{
public:
// ctor & dtor
- wxLogFrame(wxFrame *pParent, wxLogWindow *log, const char *szTitle);
+ wxLogFrame(wxFrame *pParent, wxLogWindow *log, const wxChar *szTitle);
virtual ~wxLogFrame();
// menu callbacks
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;
{
// 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;
// wxLogWindow
// -----------
wxLogWindow::wxLogWindow(wxFrame *pParent,
- const char *szTitle,
+ const wxChar *szTitle,
bool bShow,
bool bDoPass)
{
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 ) {
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();
#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
}
}
// 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;
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;
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
}
}
// 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;
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 ) {
#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 ) ) {
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;
// 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;
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:
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;
}
// 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;
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;
#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;
}
// 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;
}
{
// 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 {
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
{
wxString strIconKey;
- strIconKey << m_strFileType << "\\DefaultIcon";
+ strIconKey << m_strFileType << _T("\\DefaultIcon");
// suppress possible error messages
wxLogNull nolog;
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: <full path to file>, <icon index>
// 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);
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;
if ( key.Open() ) {
// it's the default value of the key
- if ( key.QueryValue("", *desc) ) {
+ if ( key.QueryValue(_T(""), *desc) ) {
return TRUE;
}
}
{
// add the leading point if necessary
wxString str;
- if ( ext[0u] != '.' ) {
- str = '.';
+ if ( ext[0u] != _T('.') ) {
+ str = _T('.');
}
str << 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);
{
// 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;
wxString ext;
wxRegKey key(wxRegKey::HKCR, strKey);
if ( key.Open() ) {
- if ( key.QueryValue("Extension", ext) ) {
+ if ( key.QueryValue(_T("Extension"), ext) ) {
return GetFileTypeFromExtension(ext);
}
}
// 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());
}
// 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();
//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
}
{
// 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);
}
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 */) ) {
// 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;
}
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() )
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
}
// 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
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."),
}
else {
// unquoted string ends at the first space
- for ( pEnd = pc; !isspace(*pEnd); pEnd++ )
+ for ( pEnd = pc; !wxIsspace(*pEnd); pEnd++ )
;
}
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 {
// 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);
}
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() )
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
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
}
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
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;
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);
}
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;
// 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;
// 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(),
break;
default:
- wxFAIL_MSG("unknown field type in mailcap");
+ wxFAIL_MSG(_T("unknown field type in mailcap"));
}
// next token starts immediately after ';'
m_aTypes.Add(strType);
m_aEntries.Add(entry);
- m_aExtensions.Add("");
+ m_aExtensions.Add(_T(""));
m_aDescriptions.Add(strDesc);
}
else {