]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/utils.cpp
<br><br><br> is now handled correctly, e.g. empty lines are inserted (unlike <p>...
[wxWidgets.git] / src / os2 / utils.cpp
index abea758038897dad3ab8dd19b37d4ab2d9427c8b..9c2ea76d18b71d52fbdb716078e620581abb2034 100644 (file)
@@ -160,7 +160,7 @@ bool wxShell(
     SData.PgmName  = zShell;
 
     sInputs = "/C " + rCommand;
-    SData.PgmInputs     = NULL; //(BYTE*)sInputs.c_str();
+    SData.PgmInputs     = (BYTE*)sInputs.c_str();
     SData.TermQ         = 0;
     SData.Environment   = 0;
     SData.InheritOpt    = SSF_INHERTOPT_SHELL;
@@ -177,7 +177,7 @@ bool wxShell(
     SData.ObjectBuffLen = (ULONG)sizeof(achObjBuf);
 
     rc = ::DosStartSession(&SData, &ulSessID, &vPid);
-    if (rc == 0)
+    if (rc == 0 || rc == 457) // NO_ERROR or SMG_START_IN_BACKGROUND
     {
         PTIB                            ptib;
         PPIB                            ppib;
@@ -195,10 +195,9 @@ bool wxShell(
 }
 
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-long wxGetFreeMemory(
-  void*                             pMemptr
-)
+long wxGetFreeMemory()
 {
+    void*                           pMemptr;
     ULONG                           lSize;
     ULONG                           lMemFlags;
     APIRET                          rc;
@@ -266,6 +265,7 @@ void wxError(
 , const wxString&                   rTitle
 )
 {
+    wxBuffer = new wxChar[256];
     wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST rMsg);
     if (::WinMessageBox( HWND_DESKTOP
                         ,NULL
@@ -274,6 +274,7 @@ void wxError(
                         ,0
                         ,MB_ICONEXCLAMATION | MB_YESNO
                        ) == MBID_YES)
+    delete[] wxBuffer;
     wxExit();
 }
 
@@ -309,14 +310,17 @@ int wxGetOsVersion(
 )
 {
     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 = *pMajorVsn/10;
         *pMinorVsn = ulSysInfo[QSV_VERSION_MINOR];
         return wxWINDOWS_OS2;
     }
@@ -416,7 +420,8 @@ bool wxGetResource(
 {
     HAB                             hab;
     HINI                            hIni;
-    static const wxChar             zDefunkt[] = _T("$$default");
+    wxChar                          zDefunkt[] = _T("$$default");
+    char                            zBuf[1000];
 
     if (rFile != "")
     {
@@ -427,11 +432,14 @@ bool wxGetResource(
                                               ,(PSZ)WXSTRINGCAST rSection
                                               ,(PSZ)WXSTRINGCAST rEntry
                                               ,(PSZ)zDefunkt
-                                              ,(void*)wxBuffer
+                                              ,(PVOID)zBuf
                                               ,1000
                                              );
-            if (n == 0L || wxStrcmp(wxBuffer, zDefunkt) == 0)
+            if (zBuf == NULL)
+                return FALSE;
+            if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
                 return FALSE;
+            zBuf[n-1] = '\0';
         }
         else
             return FALSE;
@@ -442,15 +450,16 @@ bool wxGetResource(
                                           ,(PSZ)WXSTRINGCAST rSection
                                           ,(PSZ)WXSTRINGCAST rEntry
                                           ,(PSZ)zDefunkt
-                                          ,(void*)wxBuffer
+                                          ,(PVOID)zBuf
                                           ,1000
                                          );
-        if (n == 0L || wxStrcmp(wxBuffer, zDefunkt) == 0)
+        if (zBuf == NULL)
             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;
 }
 
@@ -462,6 +471,8 @@ bool wxGetResource(
 )
 {
     wxChar*                         zStr = NULL;
+
+    zStr = new wxChar[1000];
     bool                            bSucc = wxGetResource( rSection
                                                           ,rEntry
                                                           ,(wxChar **)&zStr
@@ -474,7 +485,11 @@ bool wxGetResource(
         delete[] zStr;
         return TRUE;
     }
-    else return FALSE;
+    else
+    {
+        delete[] zStr;
+        return FALSE;
+    }
 }
 
 bool wxGetResource(
@@ -485,6 +500,8 @@ bool wxGetResource(
 )
 {
     wxChar*                           zStr = NULL;
+
+    zStr = new wxChar[1000];
     bool                              bSucc = wxGetResource( rSection
                                                             ,rEntry
                                                             ,(wxChar **)&zStr
@@ -497,7 +514,11 @@ bool wxGetResource(
         delete[] zStr;
         return TRUE;
     }
-    else return FALSE;
+    else
+    {
+        delete[] zStr;
+        return FALSE;
+    }
 }
 
 bool wxGetResource(
@@ -508,6 +529,8 @@ bool wxGetResource(
 )
 {
     wxChar*                         zStr = NULL;
+
+    zStr = new wxChar[1000];
     bool                            bSucc = wxGetResource( rSection
                                                           ,rEntry
                                                           ,(wxChar **)&zStr
@@ -520,7 +543,11 @@ bool wxGetResource(
         delete[] zStr;
         return TRUE;
     }
-    else return FALSE;
+    else
+    {
+        delete[] zStr;
+        return FALSE;
+    }
 }
 #endif // wxUSE_RESOURCES
 
@@ -596,6 +623,7 @@ wxChar* wxGetUserHome (
     wxChar*                         zHome;
     wxString                        sUser1(rUser);
 
+    wxBuffer = new wxChar[256];
     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)
+                    delete[] wxBuffer;
                     return *zHome ? zHome : (wxChar*)_T("\\");
             }
             if (wxStricmp(zTmp, WXSTRINGCAST sUser1) == 0)
@@ -617,13 +646,18 @@ wxChar* wxGetUserHome (
         }
     }
     if (sUser1 == _T(""))
+    {
         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