Lots of small changes to prevent glibc from crashing

when converting ansi strings to unicode. After
   this, you can use and display east asian locales
   in wxGTK, which looks sorta funny...


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-10-23 17:32:15 +00:00
parent 8dcb2ef2ee
commit f8300041bd
14 changed files with 154 additions and 124 deletions

View File

@@ -43,12 +43,7 @@ public:
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
const wxString& name = wxCalendarNameStr)
{
Init();
(void)Create(parent, id, date, pos, size, style, name);
}
const wxString& name = wxCalendarNameStr);
bool Create(wxWindow *parent,
wxWindowID id,

View File

@@ -44,7 +44,7 @@ class WXDLLEXPORT wxImageHandler: public wxObject
{
public:
wxImageHandler()
: m_name(""), m_extension(""), m_mime(), m_type(0)
: m_name(wxT("")), m_extension(wxT("")), m_mime(), m_type(0)
{ }
#if wxUSE_STREAMS

View File

@@ -25,23 +25,23 @@
class WXDLLEXPORT wxGIFHandler : public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxGIFHandler)
public:
inline wxGIFHandler()
{
m_name = "GIF file";
m_extension = "gif";
m_type = wxBITMAP_TYPE_GIF;
m_mime = "image/gif";
};
inline wxGIFHandler()
{
m_name = wxT("GIF file");
m_extension = wxT("gif");
m_type = wxBITMAP_TYPE_GIF;
m_mime = wxT("image/gif");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxGIFHandler)
};
#endif

View File

@@ -24,8 +24,6 @@
class WXDLLEXPORT wxIFFHandler : public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxIFFHandler)
public:
wxIFFHandler()
{
@@ -33,13 +31,16 @@ public:
m_extension = wxT("iff");
m_type = wxBITMAP_TYPE_IFF;
m_mime = wxT("image/x-iff");
};
}
#if wxUSE_STREAMS
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1);
virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=TRUE);
virtual bool DoCanRead(wxInputStream& stream);
#endif
private:
DECLARE_DYNAMIC_CLASS(wxIFFHandler)
};
#endif // wxUSE_IMAGE && wxUSE_IFF

View File

@@ -23,23 +23,23 @@
#if wxUSE_LIBJPEG
class WXDLLEXPORT wxJPEGHandler: public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxJPEGHandler)
public:
inline wxJPEGHandler()
{
m_name = "JPEG file";
m_extension = "jpg";
m_type = wxBITMAP_TYPE_JPEG;
m_mime = "image/jpeg";
};
inline wxJPEGHandler()
{
m_name = wxT("JPEG file");
m_extension = wxT("jpg");
m_type = wxBITMAP_TYPE_JPEG;
m_mime = wxT("image/jpeg");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxJPEGHandler)
};
#endif

View File

@@ -24,23 +24,23 @@
#if wxUSE_PCX
class WXDLLEXPORT wxPCXHandler : public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxPCXHandler)
public:
inline wxPCXHandler()
{
m_name = "PCX file";
m_extension = "pcx";
m_type = wxBITMAP_TYPE_PCX;
m_mime = "image/pcx";
};
inline wxPCXHandler()
{
m_name = wxT("PCX file");
m_extension = wxT("pcx");
m_type = wxBITMAP_TYPE_PCX;
m_mime = wxT("image/pcx");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif // wxUSE_STREAMS
private:
DECLARE_DYNAMIC_CLASS(wxPCXHandler)
};
#endif // wxUSE_PCX

View File

@@ -23,23 +23,23 @@
#if wxUSE_LIBPNG
class WXDLLEXPORT wxPNGHandler: public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxPNGHandler)
public:
inline wxPNGHandler()
{
m_name = "PNG file";
m_extension = "png";
m_type = wxBITMAP_TYPE_PNG;
m_mime = "image/png";
};
inline wxPNGHandler()
{
m_name = wxT("PNG file");
m_extension = wxT("png");
m_type = wxBITMAP_TYPE_PNG;
m_mime = wxT("image/png");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxPNGHandler)
};
#endif

View File

@@ -23,23 +23,23 @@
#if wxUSE_PNM
class WXDLLEXPORT wxPNMHandler : public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxPNMHandler)
public:
inline wxPNMHandler()
{
m_name = "PNM file";
m_extension = "pnm";
m_type = wxBITMAP_TYPE_PNM;
m_mime = "image/pnm";
};
inline wxPNMHandler()
{
m_name = wxT("PNM file");
m_extension = wxT("pnm");
m_type = wxBITMAP_TYPE_PNM;
m_mime = wxT("image/pnm");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxPNMHandler)
};
#endif

View File

@@ -24,24 +24,24 @@
#if wxUSE_LIBTIFF
class WXDLLEXPORT wxTIFFHandler: public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxTIFFHandler)
public:
inline wxTIFFHandler()
{
m_name = "TIFF file";
m_extension = "tif";
m_type = wxBITMAP_TYPE_TIF;
m_mime = "image/tiff";
};
inline wxTIFFHandler()
{
m_name = wxT("TIFF file");
m_extension = wxT("tif");
m_type = wxBITMAP_TYPE_TIF;
m_mime = wxT("image/tiff");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual int GetImageCount( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual int GetImageCount( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxTIFFHandler)
};
#endif

View File

@@ -23,23 +23,23 @@
class WXDLLEXPORT wxXPMHandler : public wxImageHandler
{
DECLARE_DYNAMIC_CLASS(wxXPMHandler)
public:
inline wxXPMHandler()
{
m_name = wxT("XPM file");
m_extension = wxT("xpm");
m_type = wxBITMAP_TYPE_XPM;
m_mime = wxT("image/xpm");
};
inline wxXPMHandler()
{
m_name = wxT("XPM file");
m_extension = wxT("xpm");
m_type = wxBITMAP_TYPE_XPM;
m_mime = wxT("image/xpm");
}
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
private:
DECLARE_DYNAMIC_CLASS(wxXPMHandler)
};

View File

@@ -371,7 +371,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
void wxFileConfig::Init()
{
m_pCurrentGroup =
m_pRootGroup = new wxFileConfigGroup(NULL, "", this);
m_pRootGroup = new wxFileConfigGroup(NULL, wxT(""), this);
m_linesHead =
m_linesTail = NULL;

View File

@@ -2095,7 +2095,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
#define LNG(wxlang, canonical, winlang, winsublang, desc) \
info.Language = wxlang; \
info.CanonicalName = wxT(canonical); \
info.Description = desc; \
info.Description = wxT(desc); \
SETWINLANG(info, winlang, winsublang) \
AddLanguage(info);

View File

@@ -155,6 +155,19 @@ wxYearSpinCtrl::wxYearSpinCtrl(wxCalendarCtrl *cal)
// wxCalendarCtrl
// ----------------------------------------------------------------------------
wxCalendarCtrl::wxCalendarCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& date,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
Init();
(void)Create(parent, id, date, pos, size, style, name);
}
void wxCalendarCtrl::Init()
{
m_comboMonth = NULL;

View File

@@ -364,7 +364,7 @@ bool wxMimeTypesManagerImpl::CheckGnomeDirsExist ()
wxString gnomedir;
wxGetHomeDir( &gnomedir );
wxString sTmp = gnomedir;
sTmp = sTmp + "/.gnome";
sTmp = sTmp + wxT("/.gnome");
if (! wxDir::Exists ( sTmp ) )
{
if (!wxMkdir ( sTmp ))
@@ -373,7 +373,7 @@ bool wxMimeTypesManagerImpl::CheckGnomeDirsExist ()
return FALSE;
}
}
sTmp = sTmp + "/mime-info";
sTmp = sTmp + wxT("/mime-info");
if (! wxDir::Exists ( sTmp ) )
{
if (!wxMkdir ( sTmp ))
@@ -393,11 +393,15 @@ bool wxMimeTypesManagerImpl::WriteGnomeKeyFile(int index, bool delete_index)
wxString gnomedir;
wxGetHomeDir( &gnomedir );
wxMimeTextFile outfile ( gnomedir + "/.gnome/mime-info/user.keys");
wxMimeTextFile outfile ( gnomedir + wxT("/.gnome/mime-info/user.keys"));
// if this fails probably Gnome is not installed ??
// create it anyway as a private mime store
#if defined(__WXGTK20__) && wxUSE_UNICODE
if (! outfile.Open ( wxConvUTF8) )
#else
if (! outfile.Open () )
#endif
{
if (delete_index) return FALSE;
if (!CheckGnomeDirsExist() ) return FALSE;
@@ -462,13 +466,13 @@ bool wxMimeTypesManagerImpl::WriteGnomeKeyFile(int index, bool delete_index)
}
//sOld should also contain the icon
if ( !m_aIcons[index].empty() )
sOld.AddOrReplaceVerb ( wxT( "icon-filename"), m_aIcons[index] );
sOld.AddOrReplaceVerb ( wxT("icon-filename"), m_aIcons[index] );
for (i=0; i < sOld.GetCount(); i++)
{
sTmp = sOld.GetVerbCmd(i);
sTmp.Replace( wxT("%s"), wxT("%f") );
sTmp = wxT ( "\t") + sTmp;
sTmp = wxT("\t") + sTmp;
nIndex ++;
outfile.InsertLine ( sTmp, nIndex );
}
@@ -484,7 +488,7 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
wxString gnomedir;
wxGetHomeDir( &gnomedir );
wxMimeTextFile outfile ( gnomedir + "/.gnome/mime-info/user.mime");
wxMimeTextFile outfile ( gnomedir + wxT("/.gnome/mime-info/user.mime"));
// if this fails probably Gnome is not installed ??
// create it anyway as a private mime store
if (! outfile.Open () )
@@ -498,7 +502,7 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
if ( nIndex == wxNOT_FOUND )
{
outfile.AddLine ( strType );
outfile.AddLine ( wxT( "\text:") + m_aExtensions.Item(index) );
outfile.AddLine ( wxT("\text:") + m_aExtensions.Item(index) );
}
else
{
@@ -510,13 +514,13 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
else
{// check for next line being the right one to replace ??
wxString sOld = outfile.GetLine(nIndex+1);
if (sOld.Contains(wxT("\text: ")))
if (sOld.Contains( wxT("\text: ")))
{
outfile.GetLine(nIndex+1) = wxT( "\text: ") + m_aExtensions.Item(index);
outfile.GetLine(nIndex+1) = wxT("\text: ") + m_aExtensions.Item(index);
}
else
{
outfile.InsertLine(wxT( "\text: ") + m_aExtensions.Item(index), nIndex + 1 );
outfile.InsertLine( wxT("\text: ") + m_aExtensions.Item(index), nIndex + 1 );
}
}
}
@@ -528,7 +532,11 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
{
wxTextFile textfile(filename);
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( !textfile.Open( wxConvUTF8) )
#else
if ( !textfile.Open() )
#endif
return;
wxLogTrace(TRACE_MIME, wxT("--- Opened Gnome file %s ---"),
filename.c_str());
@@ -615,7 +623,11 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& filename)
{
wxTextFile textfile(filename);
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( !textfile.Open( wxConvUTF8) )
#else
if ( !textfile.Open() )
#endif
return;
wxLogTrace(TRACE_MIME, wxT("--- Opened Gnome file %s ---"),
filename.c_str());
@@ -630,7 +642,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& file
if ( nLine < nLineCount )
{
pc = textfile[nLine].c_str();
if ( *pc == _T('#') )
if ( *pc == wxT('#') )
{
// skip comments
continue;
@@ -665,13 +677,13 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& file
}
// what do we have here?
if ( *pc == _T('\t') )
if ( *pc == wxT('\t') )
{
// this is a field=value ling
pc++; // skip leading TAB
static const int lenField = 4; // strlen("ext:")
if ( wxStrncmp(pc, _T("ext:"), lenField) == 0 )
if ( wxStrncmp(pc, wxT("ext:"), lenField) == 0 )
{
// skip ' ' which follows and take everything left until the end
// of line
@@ -690,7 +702,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& file
curMimeType.Empty();
while ( *pc != _T(':') && *pc != _T('\0') )
while ( *pc != wxT(':') && *pc != wxT('\0') )
{
curMimeType += *pc++;
}
@@ -705,7 +717,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
_T("base directory shouldn't end with a slash") );
wxString dirname = dirbase;
dirname << _T("/mime-info");
dirname << wxT("/mime-info");
if ( !wxDir::Exists(dirname) )
return;
@@ -715,7 +727,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
return;
// we will concatenate it with filename to get the full path below
dirname += _T('/');
dirname += wxT('/');
wxString filename;
bool cont = dir.GetFirst(&filename, _T("*.mime"), wxDIR_FILES);
@@ -742,12 +754,12 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
{
wxArrayString dirs;
dirs.Add(_T("/usr/share"));
dirs.Add(_T("/usr/local/share"));
dirs.Add(wxT("/usr/share"));
dirs.Add(wxT("/usr/local/share"));
wxString gnomedir;
wxGetHomeDir( &gnomedir );
gnomedir += _T("/.gnome");
gnomedir += wxT("/.gnome");
dirs.Add( gnomedir );
if (!sExtraDir.empty()) dirs.Add( sExtraDir );
@@ -2032,7 +2044,11 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
strFileName.c_str());
wxTextFile file(strFileName);
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( !file.Open( wxConvUTF8) )
#else
if ( !file.Open() )
#endif
return FALSE;
// the information we extract
@@ -2040,7 +2056,8 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
size_t nLineCount = file.GetLineCount();
const wxChar *pc = NULL;
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
for ( size_t nLine = 0; nLine < nLineCount; nLine++ )
{
if ( pc == NULL ) {
// now we're at the start of the line
pc = file[nLine].c_str();
@@ -2306,7 +2323,11 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
strFileName.c_str());
wxTextFile file(strFileName);
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( !file.Open( wxConvUTF8) )
#else
if ( !file.Open() )
#endif
return FALSE;
// indices of MIME types (in m_aTypes) we already found in this file