_countof and swprintf fixes for VC6
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6045 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
34395604e8
commit
82d42b1159
13 changed files with 68 additions and 74 deletions
|
@ -2,6 +2,12 @@
|
|||
|
||||
#include "pluginapi.h"
|
||||
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
unsigned int g_stringsize;
|
||||
stack_t **g_stacktop;
|
||||
TCHAR *g_variables;
|
||||
|
@ -267,7 +273,7 @@ int NSISCALL myatoi_or(const TCHAR *s)
|
|||
int NSISCALL popint()
|
||||
{
|
||||
TCHAR buf[128];
|
||||
if (popstringn(buf,_countof(buf)))
|
||||
if (popstringn(buf,COUNTOF(buf)))
|
||||
return 0;
|
||||
|
||||
return myatoi(buf);
|
||||
|
@ -276,7 +282,7 @@ int NSISCALL popint()
|
|||
int NSISCALL popint_or()
|
||||
{
|
||||
TCHAR buf[128];
|
||||
if (popstringn(buf,_countof(buf)))
|
||||
if (popstringn(buf,COUNTOF(buf)))
|
||||
return 0;
|
||||
|
||||
return myatoi_or(buf);
|
||||
|
|
|
@ -18,15 +18,10 @@
|
|||
|
||||
#include <nsis/pluginapi.h> // nsis plugin
|
||||
|
||||
#ifndef _countof
|
||||
#ifndef __cplusplus
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
extern "C++" {
|
||||
template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define _countof(_Array) sizeof(*__countof_helper(_Array))
|
||||
}
|
||||
#endif
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
// Use for functions only called from one place to possibly reduce some code
|
||||
|
@ -251,7 +246,7 @@ bool INLINE ValidateFields() {
|
|||
((pField->nMinLength > 0) && (nLength < pField->nMinLength))) {
|
||||
if (pField->pszValidateText) {
|
||||
TCHAR szTitle[1024];
|
||||
GetWindowText(hMainWindow, szTitle, _countof(szTitle));
|
||||
GetWindowText(hMainWindow, szTitle, COUNTOF(szTitle));
|
||||
MessageBox(hConfigWindow, pField->pszValidateText, szTitle, MB_OK|MB_ICONWARNING);
|
||||
}
|
||||
mySetFocus(pField->hwnd);
|
||||
|
@ -543,7 +538,7 @@ int WINAPI ReadSettings(void) {
|
|||
ConvertNewLines(pField->pszValidateText);
|
||||
|
||||
{
|
||||
int nResult = GetPrivateProfileString(szField, _T("Filter"), _T("All Files|*.*"), szResult, _countof(szResult), pszFilename);
|
||||
int nResult = GetPrivateProfileString(szField, _T("Filter"), _T("All Files|*.*"), szResult, COUNTOF(szResult), pszFilename);
|
||||
if (nResult) {
|
||||
// Convert the filter to the format required by Windows: NULL after each
|
||||
// item followed by a terminating NULL
|
||||
|
@ -631,10 +626,10 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
|
|||
ofn.hwndOwner = hConfigWindow;
|
||||
ofn.lpstrFilter = pField->pszFilter;
|
||||
ofn.lpstrFile = szBrowsePath;
|
||||
ofn.nMaxFile = _countof(szBrowsePath);
|
||||
ofn.nMaxFile = COUNTOF(szBrowsePath);
|
||||
ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
||||
|
||||
GetWindowText(pField->hwnd, szBrowsePath, _countof(szBrowsePath));
|
||||
GetWindowText(pField->hwnd, szBrowsePath, COUNTOF(szBrowsePath));
|
||||
|
||||
tryagain:
|
||||
GetCurrentDirectory(BUFFER_SIZE, szResult); // save working dir
|
||||
|
@ -1121,7 +1116,7 @@ int WINAPI createCfgDlg()
|
|||
|
||||
#undef DEFAULT_STYLES
|
||||
|
||||
if (pField->nType < 1 || pField->nType > (int)(_countof(ClassTable)))
|
||||
if (pField->nType < 1 || pField->nType > (int)(COUNTOF(ClassTable)))
|
||||
continue;
|
||||
|
||||
DWORD dwStyle, dwExStyle;
|
||||
|
|
|
@ -27,22 +27,17 @@ int GetTLBVersion(tstring& filepath, DWORD& high, DWORD & low)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef _countof
|
||||
#ifndef __cplusplus
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
extern "C++" {
|
||||
template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define _countof(_Array) sizeof(*__countof_helper(_Array))
|
||||
}
|
||||
#endif
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
int found = 0;
|
||||
|
||||
TCHAR fullpath[1024];
|
||||
TCHAR *p;
|
||||
if (!GetFullPathName(filepath.c_str(), _countof(fullpath), fullpath, &p))
|
||||
if (!GetFullPathName(filepath.c_str(), COUNTOF(fullpath), fullpath, &p))
|
||||
return 0;
|
||||
|
||||
ITypeLib* typeLib;
|
||||
|
|
|
@ -139,14 +139,14 @@ void UpdateToolBarCompressorButton()
|
|||
LoadString(g_sdata.hInstance,
|
||||
IDS_COMPRESSOR,
|
||||
temp,
|
||||
_countof(temp));
|
||||
COUNTOF(temp));
|
||||
my_memset(szBuffer, 0, sizeof(szBuffer));
|
||||
lstrcat(szBuffer,temp);
|
||||
lstrcat(szBuffer,_T(" ["));
|
||||
LoadString(g_sdata.hInstance,
|
||||
iString,
|
||||
temp,
|
||||
_countof(temp));
|
||||
COUNTOF(temp));
|
||||
lstrcat(szBuffer,temp);
|
||||
lstrcat(szBuffer,_T("]"));
|
||||
|
||||
|
@ -181,7 +181,7 @@ void AddToolBarButtonTooltip(int id, int iString)
|
|||
LoadString(g_sdata.hInstance,
|
||||
iString,
|
||||
szBuffer,
|
||||
_countof(szBuffer));
|
||||
COUNTOF(szBuffer));
|
||||
ti.lpszText = (LPTSTR) szBuffer;
|
||||
ti.rect.left =rect.left;
|
||||
ti.rect.top = rect.top;
|
||||
|
|
|
@ -27,15 +27,10 @@
|
|||
#include "toolbar.h"
|
||||
#include "noclib.h"
|
||||
|
||||
#ifndef _countof
|
||||
#ifndef __cplusplus
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
extern "C++" {
|
||||
template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define _countof(_Array) sizeof(*__countof_helper(_Array))
|
||||
}
|
||||
#endif
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
NTOOLTIP g_tip;
|
||||
|
@ -305,7 +300,7 @@ void CompileNSISScript() {
|
|||
/* script cmd args */ lstrlen(args) + /* space */ 1 +
|
||||
/* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 +
|
||||
/* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 +
|
||||
/* /NOTTIFYHWND + HWND */ _countof(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
|
||||
/* /NOTTIFYHWND + HWND */ COUNTOF(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
|
||||
+6); /* for -- \"\" and NULL */
|
||||
|
||||
g_sdata.compile_command = (TCHAR *) GlobalAlloc(GPTR, byteSize);
|
||||
|
@ -755,7 +750,7 @@ void PushMRUFile(TCHAR* fname)
|
|||
}
|
||||
|
||||
my_memset(full_file_name,0,sizeof(full_file_name));
|
||||
rv = GetFullPathName(fname,_countof(full_file_name),full_file_name,NULL);
|
||||
rv = GetFullPathName(fname,COUNTOF(full_file_name),full_file_name,NULL);
|
||||
if (rv == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ TCHAR *GetResultStr(SystemProc *proc)
|
|||
#ifdef SYSTEM_LOG_DEBUG
|
||||
|
||||
// System log debugging turned on
|
||||
#define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, _countof(syslogbuf) - _len); }
|
||||
#define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, COUNTOF(syslogbuf) - _len); }
|
||||
#define SYSTEM_LOG_POST { SYSTEM_LOG_ADD(_T("\n")); WriteToLog(syslogbuf); *syslogbuf = 0; }
|
||||
|
||||
HANDLE logfile = NULL;
|
||||
|
|
|
@ -8,15 +8,10 @@
|
|||
|
||||
#include "defs.h"
|
||||
|
||||
#ifndef _countof
|
||||
#ifndef __cplusplus
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
extern "C++" {
|
||||
template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define _countof(_Array) sizeof(*__countof_helper(_Array))
|
||||
}
|
||||
#endif
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
|
||||
|
@ -37,13 +32,13 @@ void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size,
|
|||
|
||||
EXDLL_INIT();
|
||||
|
||||
if (popstringn(title, _countof(initial)))
|
||||
if (popstringn(title, COUNTOF(initial)))
|
||||
{
|
||||
pushstring(_T("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (popstringn(initial, _countof(title)))
|
||||
if (popstringn(initial, COUNTOF(title)))
|
||||
{
|
||||
pushstring(_T("error"));
|
||||
return;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
#include <ctype.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#ifndef _countof
|
||||
#ifndef __cplusplus
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
extern "C++" {
|
||||
template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define _countof(_Array) sizeof(*__countof_helper(_Array))
|
||||
}
|
||||
#endif
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -751,7 +746,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_HIDE);
|
||||
ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_HIDE);
|
||||
{
|
||||
for (size_t x = 0; x < _countof(ids); x ++)
|
||||
for (size_t x = 0; x < COUNTOF(ids); x ++)
|
||||
ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_SHOWNA);
|
||||
SetDlgItemText(hwndDlg,IDOK,_T("&Generate"));
|
||||
EnableWindow(GetDlgItem(hwndDlg,IDOK),1);
|
||||
|
@ -761,7 +756,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
case IDC_TEST:
|
||||
if (!g_hThread) {
|
||||
TCHAR buf[1024];
|
||||
GetDlgItemText(hwndDlg,IDC_OUTFILE,buf,_countof(buf));
|
||||
GetDlgItemText(hwndDlg,IDC_OUTFILE,buf,COUNTOF(buf));
|
||||
ShellExecute(hwndDlg,_T("open"),buf,_T(""),_T(""),SW_SHOW);
|
||||
}
|
||||
break;
|
||||
|
@ -782,7 +777,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
g_compressor_solid = 0;
|
||||
g_mui=!IsDlgButtonChecked(hwndDlg,IDC_CLASSICUI);
|
||||
SetDlgItemText(g_hwnd, IDC_OUTPUTTEXT, _T(""));
|
||||
for (size_t x = 0; x < _countof(ids); x ++)
|
||||
for (size_t x = 0; x < COUNTOF(ids); x ++)
|
||||
ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_HIDE);
|
||||
ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_SHOWNA);
|
||||
SetDlgItemText(hwndDlg,IDOK,_T("&Close"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue