Fix Cygwin 1.7 build.
Avoid using Cygwin sockets as our code assumes that we use WinSock API under Windows currently (this might change in the future) by defining __USE_W32_SOCKETS. Use new, safer and more efficient cygwin_conv_path() function. Use t_str() instead of fn_str() with Windows API taking file names, under Cygwin they are different and using fn_str() is incorrect. A few other minor fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -400,6 +400,14 @@ Major new features in this release
|
||||
was added.
|
||||
|
||||
|
||||
2.9.2:
|
||||
------
|
||||
|
||||
MSW:
|
||||
|
||||
- Fix Cygwin 1.7 build (David Gangola).
|
||||
|
||||
|
||||
2.9.1:
|
||||
------
|
||||
|
||||
|
@@ -497,7 +497,7 @@ protected:
|
||||
wxDECLARE_NO_COPY_CLASS(wxAppConsoleBase);
|
||||
};
|
||||
|
||||
#if defined(__UNIX__)
|
||||
#if defined(__UNIX__) && !defined(__CYGWIN__)
|
||||
#include "wx/unix/app.h"
|
||||
#else
|
||||
// this has to be a class and not a typedef as we forward declare it
|
||||
|
@@ -193,6 +193,12 @@
|
||||
#define va_list __gnuc_va_list
|
||||
#endif /* HP-UX */
|
||||
|
||||
/* Prevents conflicts between sys/types.h and winsock.h with Cygwin, */
|
||||
/* when using Windows sockets. */
|
||||
#if defined(__CYGWIN__) && (__WXMSW__)
|
||||
#define __USE_W32_SOCKETS
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* check for native bool type and TRUE/FALSE constants */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
// TODO: implement wxEventLoopSource for MSW (it should wrap a HANDLE and be
|
||||
// monitored using MsgWaitForMultipleObjects())
|
||||
#if defined(__WXOSX__) || defined(__UNIX__)
|
||||
#if defined(__WXOSX__) || (defined(__UNIX__) && !defined(__CYGWIN__))
|
||||
#define wxUSE_EVENTLOOP_SOURCE 1
|
||||
#else
|
||||
#define wxUSE_EVENTLOOP_SOURCE 0
|
||||
@@ -310,7 +310,7 @@ protected:
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// include the header defining wxConsoleEventLoop for Unix systems
|
||||
#if defined(__UNIX__)
|
||||
#if defined(__UNIX__) && !defined(__CYGWIN__)
|
||||
#include "wx/unix/evtloop.h"
|
||||
#endif
|
||||
|
||||
|
@@ -578,7 +578,8 @@ inline int wxLstat(const wxString& path, wxStructStat *buf)
|
||||
{ return wxCRT_Lstat(path.fn_str(), buf); }
|
||||
inline int wxRmDir(const wxString& path)
|
||||
{ return wxCRT_RmDir(path.fn_str()); }
|
||||
#if defined(__WINDOWS__) || (defined(__OS2__) && defined(__WATCOMC__))
|
||||
#if (defined(__WINDOWS__) && !defined(__CYGWIN__)) \
|
||||
|| (defined(__OS2__) && defined(__WATCOMC__))
|
||||
inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0)
|
||||
{ return wxCRT_MkDir(path.fn_str()); }
|
||||
#else
|
||||
|
@@ -64,11 +64,13 @@
|
||||
#include "wx/msw/mslu.h"
|
||||
|
||||
// sys/cygwin.h is needed for cygwin_conv_to_full_win32_path()
|
||||
// and for cygwin_conv_path()
|
||||
//
|
||||
// note that it must be included after <windows.h>
|
||||
#ifdef __GNUWIN32__
|
||||
#ifdef __CYGWIN__
|
||||
#include <sys/cygwin.h>
|
||||
#include <cygwin/version.h>
|
||||
#endif
|
||||
#endif // __GNUWIN32__
|
||||
|
||||
@@ -1062,7 +1064,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
|
||||
// instead of our code if available
|
||||
//
|
||||
// NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
|
||||
if ( !::CopyFile(file1.fn_str(), file2.fn_str(), !overwrite) )
|
||||
if ( !::CopyFile(file1.t_str(), file2.t_str(), !overwrite) )
|
||||
{
|
||||
wxLogSysError(_("Failed to copy the file '%s' to '%s'"),
|
||||
file1.c_str(), file2.c_str());
|
||||
@@ -1505,11 +1507,19 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
|
||||
// another example of DOS/Unix mix (Cygwin)
|
||||
wxString pathUnix = buf;
|
||||
#if wxUSE_UNICODE
|
||||
#if CYGWIN_VERSION_DLL_MAJOR >= 1007
|
||||
cygwin_conv_path(CCP_POSIX_TO_WIN_W, pathUnix.mb_str(wxConvFile), buf, sz);
|
||||
#else
|
||||
char bufA[_MAXPATHLEN];
|
||||
cygwin_conv_to_full_win32_path(pathUnix.mb_str(wxConvFile), bufA);
|
||||
wxConvFile.MB2WC(buf, bufA, sz);
|
||||
#endif
|
||||
#else
|
||||
#if CYGWIN_VERSION_DLL_MAJOR >= 1007
|
||||
cygwin_conv_path(CCP_POSIX_TO_WIN_A, pathUnix, buf, sz);
|
||||
#else
|
||||
cygwin_conv_to_full_win32_path(pathUnix, buf);
|
||||
#endif
|
||||
#endif // wxUSE_UNICODE
|
||||
#endif // __CYGWIN__
|
||||
}
|
||||
|
@@ -188,7 +188,7 @@ public:
|
||||
// access time (see #10567)
|
||||
m_hFile = ::CreateFile
|
||||
(
|
||||
filename.fn_str(), // name
|
||||
filename.t_str(), // name
|
||||
mode == ReadAttr ? FILE_READ_ATTRIBUTES // access mask
|
||||
: FILE_WRITE_ATTRIBUTES,
|
||||
FILE_SHARE_READ | // sharing mode
|
||||
@@ -613,7 +613,7 @@ bool wxFileName::FileExists( const wxString &filePath )
|
||||
#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
|
||||
// we must use GetFileAttributes() instead of the ANSI C functions because
|
||||
// it can cope with network (UNC) paths unlike them
|
||||
DWORD ret = ::GetFileAttributes(filePath.fn_str());
|
||||
DWORD ret = ::GetFileAttributes(filePath.t_str());
|
||||
|
||||
return (ret != INVALID_FILE_ATTRIBUTES) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
|
||||
#else // !__WIN32__
|
||||
@@ -670,7 +670,7 @@ bool wxFileName::DirExists( const wxString &dirPath )
|
||||
return false;
|
||||
#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
|
||||
// stat() can't cope with network paths
|
||||
DWORD ret = ::GetFileAttributes(strPath.fn_str());
|
||||
DWORD ret = ::GetFileAttributes(strPath.t_str());
|
||||
|
||||
return (ret != INVALID_FILE_ATTRIBUTES) && (ret & FILE_ATTRIBUTE_DIRECTORY);
|
||||
#elif defined(__OS2__)
|
||||
@@ -876,8 +876,8 @@ static wxString wxCreateTempImpl(
|
||||
}
|
||||
|
||||
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
||||
if ( !::GetTempFileName(dir.fn_str(), name.fn_str(), 0,
|
||||
wxStringBuffer(path, MAX_PATH + 1)) )
|
||||
if (!::GetTempFileName(dir.t_str(), name.t_str(), 0,
|
||||
wxStringBuffer(path, MAX_PATH + 1)))
|
||||
{
|
||||
wxLogLastError(wxT("GetTempFileName"));
|
||||
|
||||
@@ -1287,7 +1287,11 @@ bool wxFileName::Rmdir(const wxString& dir, int flags)
|
||||
SHFILEOPSTRUCT fileop;
|
||||
wxZeroMemory(fileop);
|
||||
fileop.wFunc = FO_DELETE;
|
||||
#if defined(__CYGWIN__) && defined(wxUSE_UNICODE)
|
||||
fileop.pFrom = path.wc_str();
|
||||
#else
|
||||
fileop.pFrom = path.fn_str();
|
||||
#endif
|
||||
fileop.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
|
||||
#ifndef __WXWINCE__
|
||||
// FOF_NOERRORUI is not defined in WinCE
|
||||
@@ -2058,13 +2062,13 @@ wxString wxFileName::GetShortPath() const
|
||||
wxString path(GetFullPath());
|
||||
|
||||
#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
|
||||
DWORD sz = ::GetShortPathName(path.fn_str(), NULL, 0);
|
||||
DWORD sz = ::GetShortPathName(path.t_str(), NULL, 0);
|
||||
if ( sz != 0 )
|
||||
{
|
||||
wxString pathOut;
|
||||
if ( ::GetShortPathName
|
||||
(
|
||||
path.fn_str(),
|
||||
path.t_str(),
|
||||
wxStringBuffer(pathOut, sz),
|
||||
sz
|
||||
) != 0 )
|
||||
@@ -2122,12 +2126,12 @@ wxString wxFileName::GetLongPath() const
|
||||
|
||||
if ( s_pfnGetLongPathName )
|
||||
{
|
||||
DWORD dwSize = (*s_pfnGetLongPathName)(path.fn_str(), NULL, 0);
|
||||
DWORD dwSize = (*s_pfnGetLongPathName)(path.t_str(), NULL, 0);
|
||||
if ( dwSize > 0 )
|
||||
{
|
||||
if ( (*s_pfnGetLongPathName)
|
||||
(
|
||||
path.fn_str(),
|
||||
path.t_str(),
|
||||
wxStringBuffer(pathOut, dwSize),
|
||||
dwSize
|
||||
) != 0 )
|
||||
@@ -2179,7 +2183,7 @@ wxString wxFileName::GetLongPath() const
|
||||
continue;
|
||||
}
|
||||
|
||||
hFind = ::FindFirstFile(tmpPath.fn_str(), &findFileData);
|
||||
hFind = ::FindFirstFile(tmpPath.t_str(), &findFileData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// Error: most likely reason is that path doesn't exist, so
|
||||
|
@@ -49,7 +49,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __UNIX__
|
||||
#if defined(__UNIX__) && !defined(__CYGWIN__)
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif // __UNIX__
|
||||
@@ -82,8 +82,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
|
||||
#ifdef __WXMSW__
|
||||
#define HAVE_INET_ADDR
|
||||
|
||||
#ifndef HAVE_GETHOSTBYNAME
|
||||
#define HAVE_GETHOSTBYNAME
|
||||
#endif
|
||||
#ifndef HAVE_GETSERVBYNAME
|
||||
#define HAVE_GETSERVBYNAME
|
||||
#endif
|
||||
|
||||
// under MSW getxxxbyname() functions are MT-safe (but not reentrant) so
|
||||
// we don't need to serialize calls to them
|
||||
|
@@ -375,7 +375,7 @@ private:
|
||||
size_t m_nCopied;
|
||||
};
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#if defined(__WINDOWS__) && !defined(__CYGWIN__)
|
||||
|
||||
// on Windows, we should use %s and %c regardless of the build:
|
||||
class wxPrintfFormatConverterWchar : public wxFormatConverterBase<wchar_t>
|
||||
|
@@ -236,12 +236,12 @@ wxCursor::wxCursor(const wxString& filename,
|
||||
switch ( kind )
|
||||
{
|
||||
case wxBITMAP_TYPE_CUR_RESOURCE:
|
||||
hcursor = ::LoadCursor(wxGetInstance(), filename.fn_str());
|
||||
hcursor = ::LoadCursor(wxGetInstance(), filename.t_str());
|
||||
break;
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
case wxBITMAP_TYPE_CUR:
|
||||
hcursor = ::LoadCursorFromFile(filename.fn_str());
|
||||
hcursor = ::LoadCursorFromFile(filename.t_str());
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@@ -280,7 +280,7 @@ bool wxDIB::Load(const wxString& filename)
|
||||
m_handle = (HBITMAP)::LoadImage
|
||||
(
|
||||
wxGetInstance(),
|
||||
filename.fn_str(),
|
||||
filename.t_str(),
|
||||
IMAGE_BITMAP,
|
||||
0, 0, // don't specify the size
|
||||
LR_CREATEDIBSECTION | LR_LOADFROMFILE
|
||||
|
@@ -67,7 +67,7 @@ inline void FreeFindData(FIND_DATA fd)
|
||||
inline FIND_DATA FindFirst(const wxString& spec,
|
||||
FIND_STRUCT *finddata)
|
||||
{
|
||||
return ::FindFirstFile(spec.fn_str(), finddata);
|
||||
return ::FindFirstFile(spec.t_str(), finddata);
|
||||
}
|
||||
|
||||
inline bool FindNext(FIND_DATA fd, FIND_STRUCT *finddata)
|
||||
|
@@ -92,7 +92,7 @@ void wxEnhMetaFile::Init()
|
||||
}
|
||||
else // have valid file name, load metafile from it
|
||||
{
|
||||
m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename.fn_str());
|
||||
m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename.t_str());
|
||||
if ( !m_hMF )
|
||||
{
|
||||
wxLogSysError(_("Failed to load metafile from file \"%s\"."),
|
||||
|
@@ -55,7 +55,7 @@
|
||||
#include "wx/msw/ole/oleutils.h"
|
||||
#include <shldisp.h>
|
||||
|
||||
#if defined(__MINGW32__) || defined (__WATCOMC__)
|
||||
#if defined(__MINGW32__) || defined (__WATCOMC__) || defined(__CYGWIN__)
|
||||
// needed for IID_IAutoComplete, IID_IAutoComplete2 and ACO_AUTOSUGGEST
|
||||
#include <shlguid.h>
|
||||
#endif
|
||||
|
@@ -67,7 +67,9 @@
|
||||
#if defined(__CYGWIN__)
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/cygwin.h> // for cygwin_conv_to_full_win32_path()
|
||||
#include <sys/cygwin.h> // for cygwin_conv_path()
|
||||
// and cygwin_conv_to_full_win32_path()
|
||||
#include <cygwin/version.h>
|
||||
#endif //GNUWIN32
|
||||
|
||||
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
|
||||
@@ -367,7 +369,7 @@ const wxChar* wxGetHomeDir(wxString *pstr)
|
||||
|
||||
// first branch is for Cygwin
|
||||
#if defined(__UNIX__) && !defined(__WINE__)
|
||||
const wxChar *szHome = wxGetenv("HOME");
|
||||
const wxChar *szHome = wxGetenv(wxT("HOME"));
|
||||
if ( szHome == NULL ) {
|
||||
// we're homeless...
|
||||
wxLogWarning(_("can't find user's HOME, using current directory."));
|
||||
@@ -383,7 +385,11 @@ const wxChar* wxGetHomeDir(wxString *pstr)
|
||||
#ifdef __CYGWIN__
|
||||
// Cygwin returns unix type path but that does not work well
|
||||
static wxChar windowsPath[MAX_PATH];
|
||||
#if CYGWIN_VERSION_DLL_MAJOR >= 1007
|
||||
cygwin_conv_path(CCP_POSIX_TO_WIN_W, strDir, windowsPath, MAX_PATH);
|
||||
#else
|
||||
cygwin_conv_to_full_win32_path(strDir, windowsPath);
|
||||
#endif
|
||||
strDir = windowsPath;
|
||||
#endif
|
||||
#elif defined(__WXWINCE__)
|
||||
@@ -494,7 +500,7 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
|
||||
ULARGE_INTEGER bytesFree, bytesTotal;
|
||||
|
||||
// may pass the path as is, GetDiskFreeSpaceEx() is smart enough
|
||||
if ( !pGetDiskFreeSpaceEx(path.fn_str(),
|
||||
if ( !pGetDiskFreeSpaceEx(path.t_str(),
|
||||
&bytesFree,
|
||||
&bytesTotal,
|
||||
NULL) )
|
||||
@@ -544,7 +550,7 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
|
||||
|
||||
// FIXME: this is wrong, we should extract the root drive from path
|
||||
// instead, but this is the job for wxFileName...
|
||||
if ( !::GetDiskFreeSpace(path.fn_str(),
|
||||
if ( !::GetDiskFreeSpace(path.t_str(),
|
||||
&lSectorsPerCluster,
|
||||
&lBytesPerSector,
|
||||
&lNumberOfFreeClusters,
|
||||
|
Reference in New Issue
Block a user