Removed scprintf, aprintf and snprintf stuff and use newXprintf

This commit is contained in:
Alexander Gottwald 2004-12-03 12:04:15 +00:00
parent 16a683f4d1
commit f264a7ea74
4 changed files with 24 additions and 68 deletions

View File

@ -1,3 +1,11 @@
2004-12-03 Alexander Gottwald <ago at freedesktop dot org>
* windialogs.c:
* win.h:
* Imakefile:
* winerror.c:
Removed scprintf, aprintf and snprintf stuff and use newXprintf
2004-12-02 Alexander Gottwald <ago at freedesktop dot org> 2004-12-02 Alexander Gottwald <ago at freedesktop dot org>
* winwin32rootless.c: * winwin32rootless.c:

View File

@ -139,13 +139,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdio.h> #include <stdio.h>
#ifndef HAS_SCPRINTF
extern int scprintf(const char *format, ...);
#else
#ifdef WIN32
#define scprintf _scprintf
#endif
#endif
#ifndef __CYGWIN__ #ifndef __CYGWIN__
#define sleep(x) Sleep(1000 * (x)) #define sleep(x) Sleep(1000 * (x))
@ -233,15 +226,9 @@ if (fDebugProcMsg) \
{ \ { \
char *pszTemp; \ char *pszTemp; \
int iLength; \ int iLength; \
\ pszTemp = Xprintf (str, ##__VA_ARGS__); \
iLength = scprintf (str, ##__VA_ARGS__); \
pszTemp = malloc (iLength + 1); \
snprintf (pszTemp, iLength + 1, str, ##__VA_ARGS__); \
pszTemp[iLength] = 0; \
\
MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \ MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
\ xfree (pszTemp); \
free (pszTemp); \
} }
#else #else
#define DEBUG_MSG(str,...) #define DEBUG_MSG(str,...)

View File

@ -307,7 +307,6 @@ winExitDlgProc (HWND hDialog, UINT message,
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
char *pszConnectedClients; char *pszConnectedClients;
int iReturn;
/* Store pointers to private structures for future use */ /* Store pointers to private structures for future use */
s_pScreenPriv = (winPrivScreenPtr) lParam; s_pScreenPriv = (winPrivScreenPtr) lParam;
@ -322,21 +321,17 @@ winExitDlgProc (HWND hDialog, UINT message,
MAKEINTRESOURCE(IDI_XWIN))); MAKEINTRESOURCE(IDI_XWIN)));
/* Format the connected clients string */ /* Format the connected clients string */
iReturn = scprintf (CONNECTED_CLIENTS_FORMAT, pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
s_pScreenPriv->iConnectedClients); s_pScreenPriv->iConnectedClients);
if (iReturn <= 0)
return TRUE;
pszConnectedClients = malloc (iReturn + 1);
if (!pszConnectedClients) if (!pszConnectedClients)
return TRUE; return TRUE;
snprintf (pszConnectedClients, iReturn + 1, CONNECTED_CLIENTS_FORMAT,
s_pScreenPriv->iConnectedClients);
pszConnectedClients[iReturn] = 0;
/* Set the number of connected clients */ /* Set the number of connected clients */
SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED), SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
pszConnectedClients); pszConnectedClients);
free (pszConnectedClients); xfree (pszConnectedClients);
} }
return TRUE; return TRUE;

View File

@ -98,22 +98,12 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
char * pszMsgBox = NULL; char * pszMsgBox = NULL;
va_list args; va_list args;
/* Get length of formatted error string */ va_start(args, uType);
va_start (args, uType); pszErrorF = Xvprintf(pszError, args);
i = scprintf (pszError, args); va_end(args);
va_end (args);
/* Allocate memory for formatted error string */
pszErrorF = malloc (i + 1);
if (!pszErrorF) if (!pszErrorF)
goto winMessageBoxF_Cleanup; goto winMessageBoxF_Cleanup;
/* Create the formatted error string */
va_start (args, uType);
snprintf (pszErrorF, i + 1, pszError, args);
pszErrorF[i] = 0;
va_end (args);
#define MESSAGEBOXF \ #define MESSAGEBOXF \
"%s\n" \ "%s\n" \
"Vendor: %s\n" \ "Vendor: %s\n" \
@ -122,24 +112,12 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
"XWin was started with the following command-line:\n\n" \ "XWin was started with the following command-line:\n\n" \
"%s\n" "%s\n"
/* Get length of message box string */ pszMsgBox = Xprintf (MESSAGEBOXF,
i = scprintf (MESSAGEBOXF, pszErrorF, VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
pszErrorF, g_pszCommandLine);
VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
g_pszCommandLine);
/* Allocate memory for message box string */
pszMsgBox = malloc (i + 1);
if (!pszMsgBox) if (!pszMsgBox)
goto winMessageBoxF_Cleanup; goto winMessageBoxF_Cleanup;
/* Format the message box string */
snprintf (pszMsgBox, i + 1, MESSAGEBOXF,
pszErrorF,
VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
g_pszCommandLine);
pszMsgBox[i] = 0;
/* Display the message box string */ /* Display the message box string */
MessageBox (NULL, MessageBox (NULL,
pszMsgBox, pszMsgBox,
@ -148,20 +126,8 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
winMessageBoxF_Cleanup: winMessageBoxF_Cleanup:
if (pszErrorF) if (pszErrorF)
free (pszErrorF); xfree (pszErrorF);
if (pszMsgBox) if (pszMsgBox)
free (pszMsgBox); xfree (pszMsgBox);
#undef MESSAGEBOXF #undef MESSAGEBOXF
} }
#ifndef HAS_SCPRINTF
extern int scprintf(const char *format, ...)
{
int ret;
va_list va;
va_start(va, format);
ret = vsnprintf(NULL, 0, format, va);
va_end(va);
return ret;
}
#endif