projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
small bug fix for composite options
[wxWidgets.git]
/
src
/
os2
/
utils.cpp
diff --git
a/src/os2/utils.cpp
b/src/os2/utils.cpp
index f6adb6b772ffef2f99bf37f8b435ae02d07e41a9..a5dd628bad4d7f74a707b73edc0dd8fd37e596c4 100644
(file)
--- a/
src/os2/utils.cpp
+++ b/
src/os2/utils.cpp
@@
-65,9
+65,9
@@
bool wxGetHostName(
char zServer[256];
char zComputer[256];
unsigned long ulLevel = 0;
char zServer[256];
char zComputer[256];
unsigned long ulLevel = 0;
- unsigned char* zBuffer;
- unsigned long ulBuffer;
- unsigned long* pulTotalAvail;
+ unsigned char* zBuffer
= NULL
;
+ unsigned long ulBuffer
= 256
;
+ unsigned long* pulTotalAvail
= NULL
;
NetBios32GetInfo( (const unsigned char*)zServer
,(const unsigned char*)zComputer
NetBios32GetInfo( (const unsigned char*)zServer
,(const unsigned char*)zComputer
@@
-195,10
+195,9
@@
bool wxShell(
}
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
}
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-long wxGetFreeMemory(
- void* pMemptr
-)
+long wxGetFreeMemory()
{
{
+ void* pMemptr = NULL;
ULONG lSize;
ULONG lMemFlags;
APIRET rc;
ULONG lSize;
ULONG lMemFlags;
APIRET rc;
@@
-266,6
+265,7
@@
void wxError(
, const wxString& rTitle
)
{
, const wxString& rTitle
)
{
+ wxBuffer = new wxChar[256];
wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST rMsg);
if (::WinMessageBox( HWND_DESKTOP
,NULL
wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST rMsg);
if (::WinMessageBox( HWND_DESKTOP
,NULL
@@
-274,6
+274,7
@@
void wxError(
,0
,MB_ICONEXCLAMATION | MB_YESNO
) == MBID_YES)
,0
,MB_ICONEXCLAMATION | MB_YESNO
) == MBID_YES)
+ delete[] wxBuffer;
wxExit();
}
wxExit();
}
@@
-309,14
+310,17
@@
int wxGetOsVersion(
)
{
ULONG ulSysInfo[QSV_MAX] = {0};
)
{
ULONG ulSysInfo[QSV_MAX] = {0};
-
- if (::DosQuerySysInfo( 1L
- ,QSV_MAX
- ,(PVOID)ulSysInfo
- ,sizeof(ULONG) * QSV_MAX
- ))
+ APIRET ulrc;
+
+ ulrc = ::DosQuerySysInfo( 1L
+ ,QSV_MAX
+ ,(PVOID)ulSysInfo
+ ,sizeof(ULONG) * QSV_MAX
+ );
+ if (ulrc == 0L)
{
*pMajorVsn = ulSysInfo[QSV_VERSION_MAJOR];
{
*pMajorVsn = ulSysInfo[QSV_VERSION_MAJOR];
+ *pMajorVsn = *pMajorVsn/10;
*pMinorVsn = ulSysInfo[QSV_VERSION_MINOR];
return wxWINDOWS_OS2;
}
*pMinorVsn = ulSysInfo[QSV_VERSION_MINOR];
return wxWINDOWS_OS2;
}
@@
-332,8
+336,8
@@
bool wxWriteResource(
, const wxString& rFile
)
{
, const wxString& rFile
)
{
- HAB hab;
- HINI hIni;
+ HAB hab
= 0
;
+ HINI hIni
= 0
;
if (rFile != "")
{
if (rFile != "")
{
@@
-414,9
+418,10
@@
bool wxGetResource(
, const wxString& rFile
)
{
, const wxString& rFile
)
{
- HAB hab;
- HINI hIni;
- static const wxChar zDefunkt[] = _T("$$default");
+ HAB hab = 0;
+ HINI hIni = 0;
+ wxChar zDefunkt[] = _T("$$default");
+ char zBuf[1000];
if (rFile != "")
{
if (rFile != "")
{
@@
-427,11
+432,14
@@
bool wxGetResource(
,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST rEntry
,(PSZ)zDefunkt
,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST rEntry
,(PSZ)zDefunkt
- ,(
void*)wxBuffer
+ ,(
PVOID)zBuf
,1000
);
,1000
);
- if (n == 0L || wxStrcmp(wxBuffer, zDefunkt) == 0)
+ if (zBuf == NULL)
+ return FALSE;
+ if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
return FALSE;
return FALSE;
+ zBuf[n-1] = '\0';
}
else
return FALSE;
}
else
return FALSE;
@@
-442,15
+450,16
@@
bool wxGetResource(
,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST rEntry
,(PSZ)zDefunkt
,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST rEntry
,(PSZ)zDefunkt
- ,(
void*)wxBuffer
+ ,(
PVOID)zBuf
,1000
);
,1000
);
- if (
n == 0L || wxStrcmp(wxBuffer, zDefunkt) == 0
)
+ if (
zBuf == NULL
)
return FALSE;
return FALSE;
+ if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
+ return FALSE;
+ zBuf[n-1] = '\0';
}
}
- if (*ppValue)
- delete[] (*ppValue);
- *ppValue = copystring(wxBuffer);
+ strcpy((char*)*ppValue, zBuf);
return TRUE;
}
return TRUE;
}
@@
-462,6
+471,8
@@
bool wxGetResource(
)
{
wxChar* zStr = NULL;
)
{
wxChar* zStr = NULL;
+
+ zStr = new wxChar[1000];
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
@@
-474,7
+485,11
@@
bool wxGetResource(
delete[] zStr;
return TRUE;
}
delete[] zStr;
return TRUE;
}
- else return FALSE;
+ else
+ {
+ delete[] zStr;
+ return FALSE;
+ }
}
bool wxGetResource(
}
bool wxGetResource(
@@
-485,6
+500,8
@@
bool wxGetResource(
)
{
wxChar* zStr = NULL;
)
{
wxChar* zStr = NULL;
+
+ zStr = new wxChar[1000];
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
@@
-497,7
+514,11
@@
bool wxGetResource(
delete[] zStr;
return TRUE;
}
delete[] zStr;
return TRUE;
}
- else return FALSE;
+ else
+ {
+ delete[] zStr;
+ return FALSE;
+ }
}
bool wxGetResource(
}
bool wxGetResource(
@@
-508,6
+529,8
@@
bool wxGetResource(
)
{
wxChar* zStr = NULL;
)
{
wxChar* zStr = NULL;
+
+ zStr = new wxChar[1000];
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
bool bSucc = wxGetResource( rSection
,rEntry
,(wxChar **)&zStr
@@
-520,7
+543,11
@@
bool wxGetResource(
delete[] zStr;
return TRUE;
}
delete[] zStr;
return TRUE;
}
- else return FALSE;
+ else
+ {
+ delete[] zStr;
+ return FALSE;
+ }
}
#endif // wxUSE_RESOURCES
}
#endif // wxUSE_RESOURCES
@@
-596,6
+623,7
@@
wxChar* wxGetUserHome (
wxChar* zHome;
wxString sUser1(rUser);
wxChar* zHome;
wxString sUser1(rUser);
+ wxBuffer = new wxChar[256];
if (sUser1 != _T(""))
{
wxChar zTmp[64];
if (sUser1 != _T(""))
{
wxChar zTmp[64];
@@
-610,6
+638,7
@@
wxChar* wxGetUserHome (
if ((zHome = wxGetenv(_T("TMP"))) != NULL ||
(zHome = wxGetenv(_T("TMPDIR"))) != NULL ||
(zHome = wxGetenv(_T("TEMP"))) != NULL)
if ((zHome = wxGetenv(_T("TMP"))) != NULL ||
(zHome = wxGetenv(_T("TMPDIR"))) != NULL ||
(zHome = wxGetenv(_T("TEMP"))) != NULL)
+ delete[] wxBuffer;
return *zHome ? zHome : (wxChar*)_T("\\");
}
if (wxStricmp(zTmp, WXSTRINGCAST sUser1) == 0)
return *zHome ? zHome : (wxChar*)_T("\\");
}
if (wxStricmp(zTmp, WXSTRINGCAST sUser1) == 0)
@@
-617,13
+646,18
@@
wxChar* wxGetUserHome (
}
}
if (sUser1 == _T(""))
}
}
if (sUser1 == _T(""))
+ {
if ((zHome = wxGetenv(_T("HOME"))) != NULL)
{
wxStrcpy(wxBuffer, zHome);
Unix2DosFilename(wxBuffer);
if ((zHome = wxGetenv(_T("HOME"))) != NULL)
{
wxStrcpy(wxBuffer, zHome);
Unix2DosFilename(wxBuffer);
- return wxBuffer;
+ wxStrcpy(zHome, wxBuffer);
+ delete[] wxBuffer;
+ return zHome;
}
}
- return NULL; // No home known!
+ }
+ delete[] wxBuffer;
+ return NULL; // No home known!
}
// Check whether this window wants to process messages, e.g. Stop button
}
// Check whether this window wants to process messages, e.g. Stop button
@@
-635,8
+669,8
@@
bool wxCheckForInterrupt(
if(pWnd)
{
QMSG vMsg;
if(pWnd)
{
QMSG vMsg;
- HAB hab;
- HWND hwndFilter;
+ HAB hab
= 0
;
+ HWND hwndFilter
= NULLHANDLE
;
HWND hwndWin= (HWND) pWnd->GetHWND();
while(::WinPeekMsg(hab, &vMsg, hwndFilter, 0, 0, PM_REMOVE))
HWND hwndWin= (HWND) pWnd->GetHWND();
while(::WinPeekMsg(hab, &vMsg, hwndFilter, 0, 0, PM_REMOVE))
@@
-704,12
+738,16
@@
void wxDisplaySize(
{
HPS hpsScreen;
HDC hdcScreen;
{
HPS hpsScreen;
HDC hdcScreen;
+ LONG lWidth;
+ LONG lHeight;
hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
hdcScreen = ::GpiQueryDevice(hpsScreen);
hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
hdcScreen = ::GpiQueryDevice(hpsScreen);
- ::DevQueryCaps(hdcScreen, CAPS_WIDTH, 1L,
(PLONG)p
Width);
- ::DevQueryCaps(hdcScreen, CAPS_HEIGHT, 1L,
(PLONG)p
Height);
+ ::DevQueryCaps(hdcScreen, CAPS_WIDTH, 1L,
&l
Width);
+ ::DevQueryCaps(hdcScreen, CAPS_HEIGHT, 1L,
&l
Height);
DevCloseDC(hdcScreen);
DevCloseDC(hdcScreen);
+ *pWidth = (int)lWidth;
+ *pHeight = (int)lHeight;
}
bool wxDirExists(
}
bool wxDirExists(