summaryrefslogtreecommitdiff
path: root/plugins/ContextHelp/src
diff options
context:
space:
mode:
authorGoraf <goraf@miranda-ng.org>2016-02-09 16:00:09 +0000
committerGoraf <goraf@miranda-ng.org>2016-02-09 16:00:09 +0000
commitd49739f87dd347d6a560dd834788b74cf520b931 (patch)
tree02d0f5c6f6846f7a48234ed26bc65e421e407d80 /plugins/ContextHelp/src
parentfd8fdaa7ade16132fd3f23db5b0727e3615038ad (diff)
ContextHelp: revert of accidentally lowercased SIZEOF()
git-svn-id: http://svn.miranda-ng.org/main/trunk@16251 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ContextHelp/src')
-rw-r--r--plugins/ContextHelp/src/datastore.cpp16
-rw-r--r--plugins/ContextHelp/src/helpdlg.cpp6
-rw-r--r--plugins/ContextHelp/src/helppack.cpp50
-rw-r--r--plugins/ContextHelp/src/main.cpp4
-rw-r--r--plugins/ContextHelp/src/options.cpp31
-rw-r--r--plugins/ContextHelp/src/streaminout.cpp18
-rw-r--r--plugins/ContextHelp/src/utils.cpp16
7 files changed, 71 insertions, 70 deletions
diff --git a/plugins/ContextHelp/src/datastore.cpp b/plugins/ContextHelp/src/datastore.cpp
index ca04665acf..40df51eb08 100644
--- a/plugins/ContextHelp/src/datastore.cpp
+++ b/plugins/ContextHelp/src/datastore.cpp
@@ -68,7 +68,7 @@ void InitDialogCache(void)
hServiceFileChange = CreateServiceFunction("Help/HelpPackChanged", ServiceFileChanged);
hFileChange = INVALID_HANDLE_VALUE;
- if (GetModuleFileName(NULL, szFilePath, sizeof(szFilePath))) {
+ if (GetModuleFileName(NULL, szFilePath, _countof(szFilePath))) {
p = _tcsrchr(szFilePath, _T('\\'));
if (p != NULL)
*(p + 1) = _T('\0');
@@ -135,7 +135,7 @@ static void LoaderThread(void *arg)
void *buf;
ZeroMemory(&dialog, sizeof(dialog));
- if (GetModuleFileName(NULL, szDir, sizeof(szDir))) {
+ if (GetModuleFileName(NULL, szDir, _countof(szDir))) {
p = _tcsrchr(szDir, _T('\\'));
if (p)
*p = _T('\0');
@@ -146,7 +146,7 @@ static void LoaderThread(void *arg)
do {
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
- if (lstrlen(wfd.cFileName)<4 || wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.'))
+ if (lstrlen(wfd.cFileName) < 4 || wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.'))
continue;
mir_sntprintf(szSearch, _T("%s\\%s"), szDir, wfd.cFileName);
success = 1;
@@ -167,7 +167,7 @@ static void LoaderThread(void *arg)
PostMessage(hwndHelpDlg, M_HELPLOADFAILED, 0, (LPARAM)dtsp->hwndCtl);
return;
}
- fgets(line, sizeof(line), fp);
+ fgets(line, _countof(line), fp);
TrimString(line);
if (lstrcmpA(line, "Miranda Help Pack Version 1")) {
fclose(fp);
@@ -181,7 +181,7 @@ static void LoaderThread(void *arg)
dialog.defaultCodePage = CP_ACP;
while (!feof(fp)) {
startOfLine = ftell(fp);
- if (fgets(line, sizeof(line), fp) == NULL)
+ if (fgets(line, _countof(line), fp) == NULL)
break;
TrimString(line);
if (IsEmpty(line) || line[0] == ';' || line[0] == '\0')
@@ -230,7 +230,7 @@ static void LoaderThread(void *arg)
success = 1;
control = NULL;
while (!feof(fp)) {
- if (fgets(line, sizeof(line), fp) == NULL)
+ if (fgets(line, _countof(line), fp) == NULL)
break;
if (IsEmpty(line) || line[0] == ';' || line[0] == '\0')
continue;
@@ -372,8 +372,8 @@ char *CreateControlIdentifier(const char *pszDlgId, const char *pszModule, int c
int size;
char *szId;
TCHAR szDefCtlText[128];
- GetControlTitle(hwndCtl, szDefCtlText, sizeof(szDefCtlText));
- size = lstrlenA(pszModule) + lstrlenA(pszDlgId) + sizeof(szDefCtlText) + 22;
+ GetControlTitle(hwndCtl, szDefCtlText, _countof(szDefCtlText));
+ size = lstrlenA(pszModule) + lstrlenA(pszDlgId) + _countof(szDefCtlText) + 22;
szId = (char*)mir_alloc(size);
mir_snprintf(szId, size, "[%s:%i@%s]\r\n%S%s", pszModule, ctrlId, pszDlgId, szDefCtlText, szDefCtlText[0] ? "=" : "");
diff --git a/plugins/ContextHelp/src/helpdlg.cpp b/plugins/ContextHelp/src/helpdlg.cpp
index 47692e128c..38ee716452 100644
--- a/plugins/ContextHelp/src/helpdlg.cpp
+++ b/plugins/ContextHelp/src/helpdlg.cpp
@@ -333,7 +333,7 @@ INT_PTR CALLBACK HelpDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
TCHAR text[1024];
char *szModule, *szDlgId;
- GetControlTitle(hwndCtl, text, sizeof(text));
+ GetControlTitle(hwndCtl, text, _countof(text));
SetDlgItemText(hwndDlg, IDC_CTLTEXT, text);
mir_sntprintf(text, sizeof(text), TranslateT("Control ID: %d"), GetControlID(hwndCtl));
SetDlgItemText(hwndDlg, IDC_CTLID, text);
@@ -368,7 +368,7 @@ INT_PTR CALLBACK HelpDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT), TRUE);
{
TCHAR text[2024];
- GetControlTitle(hwndCtl, text, sizeof(text));
+ GetControlTitle(hwndCtl, text, _countof(text));
SetDlgItemText(hwndDlg, IDC_CTLTEXT, text);
}
#else
@@ -568,7 +568,7 @@ INT_PTR CALLBACK HelpDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
{
TCHAR szTitle[1024];
char *szText, *szDlgId, *szModule;
- if (!GetDlgItemText(hwndDlg, IDC_CTLTEXT, szTitle, sizeof(szTitle)))
+ if (!GetDlgItemText(hwndDlg, IDC_CTLTEXT, szTitle, _countof(szTitle)))
break;
szDlgId = CreateDialogIdString(GetControlDialog(hwndCtl));
if (szDlgId == NULL)
diff --git a/plugins/ContextHelp/src/helppack.cpp b/plugins/ContextHelp/src/helppack.cpp
index 3592cf6a3f..5b702c13e2 100644
--- a/plugins/ContextHelp/src/helppack.cpp
+++ b/plugins/ContextHelp/src/helppack.cpp
@@ -172,7 +172,7 @@ static BOOL LoadPackData(HELPPACK_INFO *pack, BOOL fEnabledPacks, const char *ps
X-Version: 1.2.3.4 (non-standard extension)
see 'Help-Translation.txt' for some header guidelines
*/
- if (!GetPackPath(szFileName, sizeof(szFileName), fEnabledPacks, pack->szFileName))
+ if (!GetPackPath(szFileName, _countof(szFileName), fEnabledPacks, pack->szFileName))
return FALSE;
FILE *fp = _tfopen(szFileName, _T("rt"));
if (fp == NULL)
@@ -237,11 +237,11 @@ static BOOL LoadPackData(HELPPACK_INFO *pack, BOOL fEnabledPacks, const char *ps
if (GetLocaleInfoA(pack->Locale, LOCALE_IDEFAULTANSICODEPAGE, line, 6))
pack->codepage = (WORD)atoi(line); /* CP_ACP on error */
/* language */
- MultiByteToWideChar(pack->codepage, 0, szLanguageA, -1, pack->szLanguage, sizeof(pack->szLanguage));
+ MultiByteToWideChar(pack->codepage, 0, szLanguageA, -1, pack->szLanguage, _countof(pack->szLanguage));
/* ensure the pack always has a language name */
- if (!pack->szLanguage[0] && !GetLocaleInfo(pack->Locale, LOCALE_SENGLANGUAGE, pack->szLanguage, sizeof(pack->szLanguage))) {
+ if (!pack->szLanguage[0] && !GetLocaleInfo(pack->Locale, LOCALE_SENGLANGUAGE, pack->szLanguage, _countof(pack->szLanguage))) {
TCHAR *p;
- lstrcpyn(pack->szLanguage, pack->szFileName, sizeof(pack->szLanguage)); /* buffer safe */
+ lstrcpyn(pack->szLanguage, pack->szFileName, _countof(pack->szLanguage)); /* buffer safe */
p = _tcsrchr(pack->szLanguage, _T('.'));
if (p != NULL)
*p = '\0';
@@ -292,7 +292,7 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
HANDLE hFind;
/* enabled packs */
- if (GetPackPath(pack.szFileName, sizeof(pack.szFileName), TRUE, pszFilePattern)) {
+ if (GetPackPath(pack.szFileName, _countof(pack.szFileName), TRUE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
@@ -326,7 +326,7 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
}
/* disabled packs */
- if (GetPackPath(pack.szFileName, sizeof(pack.szFileName), FALSE, pszFilePattern)) {
+ if (GetPackPath(pack.szFileName, _countof(pack.szFileName), FALSE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
@@ -384,7 +384,7 @@ BOOL EnablePack(const HELPPACK_INFO *pack, const TCHAR *pszFilePattern)
TCHAR szFrom[MAX_PATH], szDest[MAX_PATH];
/* disable previous pack */
- if (GetPackPath(szFrom, sizeof(szFrom), TRUE, pszFilePattern)) {
+ if (GetPackPath(szFrom, _countof(szFrom), TRUE, pszFilePattern)) {
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(szFrom, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
@@ -394,11 +394,11 @@ BOOL EnablePack(const HELPPACK_INFO *pack, const TCHAR *pszFilePattern)
if (lstrlen(wfd.cFileName) < 4 || wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.'))
continue;
/* ensure dir exists */
- if (GetPackPath(szFrom, sizeof(szFrom), FALSE, NULL))
+ if (GetPackPath(szFrom, _countof(szFrom), FALSE, NULL))
CreateDirectory(szFrom, NULL);
/* move file */
- if (GetPackPath(szFrom, sizeof(szFrom), TRUE, wfd.cFileName))
- if (GetPackPath(szDest, sizeof(szDest), FALSE, wfd.cFileName))
+ if (GetPackPath(szFrom, _countof(szFrom), TRUE, wfd.cFileName))
+ if (GetPackPath(szDest, _countof(szDest), FALSE, wfd.cFileName))
if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
DeleteFile(szDest);
MoveFile(szFrom, szDest);
@@ -410,8 +410,8 @@ BOOL EnablePack(const HELPPACK_INFO *pack, const TCHAR *pszFilePattern)
}
/* enable current pack */
- if (GetPackPath(szFrom, sizeof(szFrom), FALSE, pack->szFileName))
- if (GetPackPath(szDest, sizeof(szDest), TRUE, pack->szFileName))
+ if (GetPackPath(szFrom, _countof(szFrom), FALSE, pack->szFileName))
+ if (GetPackPath(szDest, _countof(szDest), TRUE, pack->szFileName))
return MoveFile(szFrom, szDest);
return FALSE;
@@ -430,7 +430,7 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
*pszFile = _T('\0');
/* move wrongly placed packs from 'Plugins' to 'Language' */
- mir_sntprintf(szFrom, sizeof(szFrom), _T("%s\\Plugins\\%s"), szDir, pszFilePattern);
+ mir_sntprintf(szFrom, _T("%s\\Plugins\\%s"), szDir, pszFilePattern);
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(szFrom, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
@@ -441,12 +441,12 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
continue;
/* ensure dir exists */
- if (!fDirCreated && GetPackPath(szFrom, sizeof(szFrom), FALSE, NULL))
+ if (!fDirCreated && GetPackPath(szFrom, _countof(szFrom), FALSE, NULL))
fDirCreated = CreateDirectory(szFrom, NULL);
/* move file */
- if (GetPackPath(szDest, sizeof(szDest), FALSE, wfd.cFileName)) {
- mir_sntprintf(szFrom, sizeof(szFrom), _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
+ if (GetPackPath(szDest, _countof(szDest), FALSE, wfd.cFileName)) {
+ mir_sntprintf(szFrom, _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
DeleteFile(szDest);
MoveFile(szFrom, szDest);
@@ -457,7 +457,7 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
}
/* disable all packs except one */
- if (GetPackPath(szFrom, sizeof(szFrom), TRUE, pszFilePattern)) {
+ if (GetPackPath(szFrom, _countof(szFrom), TRUE, pszFilePattern)) {
hFind = FindFirstFile(szFrom, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
@@ -472,11 +472,11 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
continue;
}
/* ensure dir exists */
- if (!fDirCreated && GetPackPath(szFrom, sizeof(szFrom), FALSE, NULL))
+ if (!fDirCreated && GetPackPath(szFrom, _countof(szFrom), FALSE, NULL))
fDirCreated = CreateDirectory(szFrom, NULL);
/* move file */
- if (GetPackPath(szFrom, sizeof(szFrom), TRUE, wfd.cFileName))
- if (GetPackPath(szDest, sizeof(szDest), FALSE, wfd.cFileName)) {
+ if (GetPackPath(szFrom, _countof(szFrom), TRUE, wfd.cFileName))
+ if (GetPackPath(szDest, _countof(szDest), FALSE, wfd.cFileName)) {
if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
DeleteFile(szDest);
MoveFile(szFrom, szDest);
@@ -490,12 +490,12 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
/* ensure one is enabled if installed */
if (!fOneEnabled) {
/* try to move english */
- if (GetPackPath(szFrom, sizeof(szFrom), FALSE, pszDefaultFile))
- if (GetPackPath(szDest, sizeof(szDest), TRUE, pszDefaultFile))
+ if (GetPackPath(szFrom, _countof(szFrom), FALSE, pszDefaultFile))
+ if (GetPackPath(szDest, _countof(szDest), TRUE, pszDefaultFile))
fOneEnabled = MoveFile(szFrom, szDest);
/* fallback on other one */
if (!fOneEnabled)
- if (GetPackPath(szFrom, sizeof(szFrom), FALSE, pszFilePattern)) {
+ if (GetPackPath(szFrom, _countof(szFrom), FALSE, pszFilePattern)) {
hFind = FindFirstFile(szFrom, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
@@ -504,8 +504,8 @@ void CorrectPacks(const TCHAR *pszFilePattern, const TCHAR *pszDefaultFile, BOOL
if (lstrlen(wfd.cFileName) < 4 || wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.'))
continue;
/* move first file */
- if (GetPackPath(szFrom, sizeof(szFrom), FALSE, wfd.cFileName))
- if (GetPackPath(szDest, sizeof(szDest), TRUE, wfd.cFileName))
+ if (GetPackPath(szFrom, _countof(szFrom), FALSE, wfd.cFileName))
+ if (GetPackPath(szDest, _countof(szDest), TRUE, wfd.cFileName))
MoveFile(szFrom, szDest);
break;
} while (FindNextFile(hFind, &wfd));
diff --git a/plugins/ContextHelp/src/main.cpp b/plugins/ContextHelp/src/main.cpp
index 6ddc2363b5..28887b15e0 100644
--- a/plugins/ContextHelp/src/main.cpp
+++ b/plugins/ContextHelp/src/main.cpp
@@ -52,7 +52,7 @@ static void InstallFile(const TCHAR *pszFileName, const TCHAR *pszDestSubDir)
TCHAR szFileFrom[MAX_PATH + 1], szFileTo[MAX_PATH + 1], *p;
HANDLE hFile;
- if (!GetModuleFileName(hInst, szFileFrom, sizeof(szFileFrom) - lstrlen(pszFileName)))
+ if (!GetModuleFileName(hInst, szFileFrom, _countof(szFileFrom) - lstrlen(pszFileName)))
return;
p = _tcsrchr(szFileFrom, _T('\\'));
if (p != NULL)
@@ -64,7 +64,7 @@ static void InstallFile(const TCHAR *pszFileName, const TCHAR *pszDestSubDir)
return;
CloseHandle(hFile);
- if (!GetModuleFileName(NULL, szFileTo, sizeof(szFileTo) - lstrlen(pszDestSubDir) - lstrlen(pszFileName)))
+ if (!GetModuleFileName(NULL, szFileTo, _countof(szFileTo) - lstrlen(pszDestSubDir) - lstrlen(pszFileName)))
return;
p = _tcsrchr(szFileTo, _T('\\'));
if (p != NULL)
diff --git a/plugins/ContextHelp/src/options.cpp b/plugins/ContextHelp/src/options.cpp
index 81d5fd6164..507dcabf01 100644
--- a/plugins/ContextHelp/src/options.cpp
+++ b/plugins/ContextHelp/src/options.cpp
@@ -30,8 +30,8 @@ static HWND hwndLangOpt;
/* these are only there for a short time to
* debug those radio buttons an Win9x */
-#define BOX(str) BOX2("%s (err:%i)",str,GetLastError())
-#define BOX2(fmt,p1,p2) { char str[256]; mir_snprintf(str,fmt,p1,p2); MessageBoxA(NULL,str,"dbg",0); }
+#define BOX(str) BOX2("%s (err:%i)", str, GetLastError())
+#define BOX2(fmt,p1,p2) { char str[256]; mir_snprintf(str, fmt, p1, p2); MessageBoxA(NULL, str, "dbg", 0); }
// ImageList_Destroy() the return value
// refresh on WM_THEMECHANGED
@@ -169,12 +169,12 @@ static void DisplayNotIncludedPlugins(HWND hwndListBox, const HELPPACK_INFO *pac
{
/* enum plugins */
TCHAR szDir[MAX_PATH];
- if (GetModuleFileName(NULL, szDir, sizeof(szDir))) {
+ if (GetModuleFileName(NULL, szDir, _countof(szDir))) {
TCHAR *p = _tcsrchr(szDir, _T('\\'));
if (p != NULL)
*p = _T('\0');
TCHAR szSearch[MAX_PATH];
- mir_sntprintf(szSearch, sizeof(szSearch), _T("%s\\Plugins\\*.dll"), szDir);
+ mir_sntprintf(szSearch, _T("%s\\Plugins\\*.dll"), szDir);
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(szSearch, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
@@ -184,7 +184,7 @@ static void DisplayNotIncludedPlugins(HWND hwndListBox, const HELPPACK_INFO *pac
do {
if (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
continue;
- if ((lstrlen(wfd.cFileName)<4) || (wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.')))
+ if ((lstrlen(wfd.cFileName) < 4) || (wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.')))
continue;
/* file name */
lstrcpy(szSearch, wfd.cFileName); /* buffer safe */
@@ -198,7 +198,7 @@ static void DisplayNotIncludedPlugins(HWND hwndListBox, const HELPPACK_INFO *pac
continue;
/* friendly name of the plugin */
- mir_sntprintf(szSearch, sizeof(szSearch), _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
+ mir_sntprintf(szSearch, _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
HMODULE hModule = GetModuleHandle(szSearch);
BOOL fNeedsFree = (hModule == NULL);
if (hModule == NULL) {
@@ -217,7 +217,7 @@ static void DisplayNotIncludedPlugins(HWND hwndListBox, const HELPPACK_INFO *pac
CleanupPluginName(buf);
TCHAR buf2[128];
- mir_sntprintf(buf2, sizeof(buf2), _T("%hs (%s)"), buf, CharLower(wfd.cFileName));
+ mir_sntprintf(buf2, _T("%hs (%s)"), buf, CharLower(wfd.cFileName));
SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM)buf2);
}
}
@@ -241,13 +241,14 @@ static void DisplayPackInfo(HWND hwndDlg, const HELPPACK_INFO *pack)
IDC_LANGLOCALELABEL, IDC_LANGLOCALE, IDC_LANGVERSIONLABEL, IDC_LANGVERSION,
IDC_LANGMODUSINGLABEL, IDC_LANGMODUSING, IDC_LANGAUTHORSLABEL, IDC_LANGAUTHORS,
IDC_LANGEMAILLABEL, IDC_LANGEMAIL };
- for (int i = 0; i < sizeof(controls); i++)
+ for (int i = 0; i < _countof(controls); i++)
ShowWindow(GetDlgItem(hwndDlg, controls[i]), (pack != NULL) ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_NOPACK), (pack != NULL) ? SW_HIDE : SW_SHOW);
SetDlgItemText(hwndDlg, IDC_LANGINFOFRAME, NULL);
}
if (pack == NULL)
return;
+
/* compute not-included from included list */
SendDlgItemMessage(hwndDlg, IDC_LANGNOTINCLUDED, LB_RESETCONTENT, 0, 0);
DisplayNotIncludedPlugins(GetDlgItem(hwndDlg, IDC_LANGNOTINCLUDED), pack);
@@ -256,12 +257,12 @@ static void DisplayPackInfo(HWND hwndDlg, const HELPPACK_INFO *pack)
TCHAR szLocaleName[128];
szLocaleName[0] = _T('\0');
/* can't use LOCALE_SNAME as it is not present on pre WinVista */
- if (!GetLocaleInfo(pack->Locale, LOCALE_SISO639LANGNAME, szLocaleName, sizeof(szLocaleName))) { /* Win98/NT4+ */
- if (!GetLocaleInfo(pack->Locale, LOCALE_SLANGUAGE, szLocaleName, sizeof(szLocaleName))) /* not unique! */
+ if (!GetLocaleInfo(pack->Locale, LOCALE_SISO639LANGNAME, szLocaleName, _countof(szLocaleName))) { /* Win98/NT4+ */
+ if (!GetLocaleInfo(pack->Locale, LOCALE_SLANGUAGE, szLocaleName, _countof(szLocaleName))) /* not unique! */
szLocaleName[0] = _T('\0');
}
else {
- if (GetLocaleInfo(pack->Locale, LOCALE_SISO3166CTRYNAME, &szLocaleName[3], sizeof(szLocaleName) - 3)) /* Win98/NT4+ */
+ if (GetLocaleInfo(pack->Locale, LOCALE_SISO3166CTRYNAME, &szLocaleName[3], _countof(szLocaleName) - 3)) /* Win98/NT4+ */
szLocaleName[2] = _T('-');
}
/* add some note if its incompatible */
@@ -269,7 +270,7 @@ static void DisplayPackInfo(HWND hwndDlg, const HELPPACK_INFO *pack)
if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) {
TCHAR *pszIncompat;
pszIncompat = TranslateT("(incompatible)");
- szLocaleName[sizeof(szLocaleName) - lstrlen(pszIncompat) - 1] = 0;
+ szLocaleName[_countof(szLocaleName) - lstrlen(pszIncompat) - 1] = 0;
lstrcat(lstrcat(szLocaleName, _T(" ")), pszIncompat); /* buffer safe */
}
SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName);
@@ -286,7 +287,7 @@ static void DisplayPackInfo(HWND hwndDlg, const HELPPACK_INFO *pack)
TCHAR szDate[128];
szDate[0] = _T('\0');
if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate))
- GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, sizeof(szDate));
+ GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, _countof(szDate));
SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate);
}
@@ -321,7 +322,7 @@ static void DeletePackFile(HWND hwndDlg, HWND hwndList, int iItem, HELPPACK_INFO
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_SILENT; /* silent = no progress */
/* double zero terminated */
TCHAR szFileName[MAX_PATH];
- if (GetPackPath(szFileName, sizeof(szFileName) - 1, pack->flags&HPF_ENABLED, pack->szFileName)) {
+ if (GetPackPath(szFileName, _countof(szFileName) - 1, pack->flags&HPF_ENABLED, pack->szFileName)) {
szFileName[lstrlen(szFileName) + 1] = _T('\0');
sfo.pFrom = szFileName;
/* ask to delete file */
@@ -372,7 +373,7 @@ static INT_PTR CALLBACK InsertPackItemEnumProc(HELPPACK_INFO *pack, WPARAM wPara
TCHAR szBuf[6];
/* get country id from locale */
if (!(pack->flags&HPF_NOLOCALE))
- if (GetLocaleInfo(pack->Locale, LOCALE_ICOUNTRY, szBuf, sizeof(szBuf)))
+ if (GetLocaleInfo(pack->Locale, LOCALE_ICOUNTRY, szBuf, _countof(szBuf)))
countryId = _ttoi(szBuf);
hIcon = (HICON)CallService(MS_FLAGS_LOADFLAGICON, countryId, 0);
}
diff --git a/plugins/ContextHelp/src/streaminout.cpp b/plugins/ContextHelp/src/streaminout.cpp
index 6962dce293..bf692c54ac 100644
--- a/plugins/ContextHelp/src/streaminout.cpp
+++ b/plugins/ContextHelp/src/streaminout.cpp
@@ -194,13 +194,13 @@ void StreamInHtml(HWND hwndEdit, const char *szHtml, UINT codepage, COLORREF clr
CopyMemory(szTagName, pszHtml + 1, min(sizeof(szTagName), iNameEnd));
szTagName[min(sizeof(szTagName), iNameEnd) - 1] = '\0';
- for (i = 0; i < sizeof(simpleHtmlRtfConversions); i++) {
+ for (i = 0; i < _countof(simpleHtmlRtfConversions); i++) {
if (!lstrcmpiA(szTagName, simpleHtmlRtfConversions[i].szHtml)) {
AppendToCharBuffer(&body, "\\%s ", simpleHtmlRtfConversions[i].szRtf);
break;
}
}
- if (i == sizeof(simpleHtmlRtfConversions)) {
+ if (i == _countof(simpleHtmlRtfConversions)) {
if (!lstrcmpiA(szTagName, "br")) {
AppendToCharBuffer(&body, "\\par ");
charCount++; // linebreaks are characters
@@ -251,7 +251,7 @@ void StreamInHtml(HWND hwndEdit, const char *szHtml, UINT codepage, COLORREF clr
if (szColour != NULL) {
int i, freeColour = 1;
if (szColour[0] != '#' || lstrlenA(szColour) != 7) {
- for (i = 0; i < sizeof(htmlColourNames); i++) {
+ for (i = 0; i < _countof(htmlColourNames); i++) {
if (!lstrcmpiA(szColour, htmlColourNames[i].szName)) {
mir_free(szColour);
szColour = (char*)htmlColourNames[i].szClr;
@@ -303,7 +303,7 @@ void StreamInHtml(HWND hwndEdit, const char *szHtml, UINT codepage, COLORREF clr
pszTagEnd = strchr(pszHtml + 1, ';');
if (pszTagEnd == NULL)
break;
- CopyMemory(szTag, pszHtml + 1, min(sizeof(szTag), pszTagEnd - pszHtml));
+ CopyMemory(szTag, pszHtml + 1, min(_countof(szTag), pszTagEnd - pszHtml));
szTag[min(sizeof(szTag), pszTagEnd - pszHtml) - 1] = '\0';
if (szTag[0] == '#') {
int ch;
@@ -317,7 +317,7 @@ void StreamInHtml(HWND hwndEdit, const char *szHtml, UINT codepage, COLORREF clr
AppendToCharBuffer(&body, "\\'%02x ", ch);
}
else {
- for (i = 0; i < sizeof(htmlSymbolChars); i++) {
+ for (i = 0; i < _countof(htmlSymbolChars); i++) {
if (!lstrcmpiA(szTag, htmlSymbolChars[i].szSym)) {
AppendCharToCharBuffer(&body, htmlSymbolChars[i].ch);
charCount++;
@@ -610,13 +610,13 @@ char *StreamOutHtml(HWND hwndEdit)
int i;
char szColour[7];
wsprintfA(szColour, "%02x%02x%02x", GetRValue(colourTbl[param]), GetGValue(colourTbl[param]), GetBValue(colourTbl[param]));
- for (i = 0; i < sizeof(htmlColourNames); i++) {
+ for (i = 0; i < _countof(htmlColourNames); i++) {
if (!lstrcmpiA(szColour, htmlColourNames[i].szClr)) {
AppendToCharBuffer(output, "<font color=\"%s\">", htmlColourNames[i].szName);
break;
}
}
- if (i == sizeof(htmlColourNames))
+ if (i == _countof(htmlColourNames))
AppendToCharBuffer(output, "<font color=\"#%s\">", szColour);
inFontTag = 1;
groupStack[groupLevel].colour = param;
@@ -734,13 +734,13 @@ char *StreamOutHtml(HWND hwndEdit)
if (*pszRtf == ' ')
AppendCharToCharBuffer(output, *pszRtf);
else {
- for (i = 0; i < sizeof(htmlSymbolChars); i++) {
+ for (i = 0; i < _countof(htmlSymbolChars); i++) {
if (*pszRtf == htmlSymbolChars[i].ch) {
AppendToCharBuffer(output, "&%s;", htmlSymbolChars[i].szSym);
break;
}
}
- if (i == sizeof(htmlSymbolChars))
+ if (i == _countof(htmlSymbolChars))
AppendCharToCharBuffer(output, *pszRtf);
}
}
diff --git a/plugins/ContextHelp/src/utils.cpp b/plugins/ContextHelp/src/utils.cpp
index 84e78fcc7d..aac6e70a22 100644
--- a/plugins/ContextHelp/src/utils.cpp
+++ b/plugins/ContextHelp/src/utils.cpp
@@ -39,12 +39,12 @@ int GetControlType(HWND hwndCtl)
if (GetClassLong(hwndCtl, GCW_ATOM) == 32770)
return CTLTYPE_DIALOG;
- if (!GetClassName(hwndCtl, szClassName, sizeof(szClassName)))
+ if (!GetClassName(hwndCtl, szClassName, _countof(szClassName)))
return CTLTYPE_UNKNOWN;
if (!lstrcmpi(szClassName, _T("MDIClient")))
return CTLTYPE_DIALOG;
else if (!lstrcmpi(szClassName, _T("Static"))) {
- if (GetClassName(GetParent(hwndCtl), szClassName, sizeof(szClassName)) && !lstrcmpi(szClassName, _T("ComboBox")) || !lstrcmpi(szClassName, WC_COMBOBOXEX))
+ if (GetClassName(GetParent(hwndCtl), szClassName, _countof(szClassName)) && !lstrcmpi(szClassName, _T("ComboBox")) || !lstrcmpi(szClassName, WC_COMBOBOXEX))
return CTLTYPE_COMBO;
style = GetWindowLongPtr(hwndCtl, GWL_STYLE);
switch (style&SS_TYPEMASK) {
@@ -90,9 +90,9 @@ int GetControlType(HWND hwndCtl)
else if (!lstrcmpi(szClassName, MIRANDABUTTONCLASS))
return CTLTYPE_BUTTON;
else if (!lstrcmpi(szClassName, _T("Edit"))) {
- if (GetClassName(GetParent(hwndCtl), szClassName, sizeof(szClassName)) && !lstrcmpi(szClassName, _T("ComboBox")))
+ if (GetClassName(GetParent(hwndCtl), szClassName, _countof(szClassName)) && !lstrcmpi(szClassName, _T("ComboBox")))
return CTLTYPE_COMBO;
- if (GetClassName(GetWindow(hwndCtl, GW_HWNDNEXT), szClassName, sizeof(szClassName)) && !lstrcmpi(szClassName, UPDOWN_CLASS))
+ if (GetClassName(GetWindow(hwndCtl, GW_HWNDNEXT), szClassName, _countof(szClassName)) && !lstrcmpi(szClassName, UPDOWN_CLASS))
if ((HWND)SendMessage(GetWindow(hwndCtl, GW_HWNDNEXT), UDM_GETBUDDY, 0, 0) == hwndCtl)
return CTLTYPE_SPINEDIT;
return CTLTYPE_EDIT;
@@ -116,7 +116,7 @@ int GetControlType(HWND hwndCtl)
else if (!lstrcmpi(szClassName, WC_PAGESCROLLER))
return CTLTYPE_SCROLL;
else if (!lstrcmpi(szClassName, UPDOWN_CLASS)) {
- if (GetClassName((HWND)SendMessage(hwndCtl, UDM_GETBUDDY, 0, 0), szClassName, sizeof(szClassName)) && !lstrcmpi(szClassName, _T("Edit")))
+ if (GetClassName((HWND)SendMessage(hwndCtl, UDM_GETBUDDY, 0, 0), szClassName, _countof(szClassName)) && !lstrcmpi(szClassName, _T("Edit")))
return CTLTYPE_SPINEDIT;
return CTLTYPE_SCROLL;
}
@@ -169,7 +169,7 @@ HWND GetControlDialog(HWND hwndCtl)
while (hwndCtl != NULL) {
if (GetClassLong(hwndCtl, GCW_ATOM) == 32770)
return hwndCtl;
- if (GetClassName(hwndCtl, szClassName, sizeof(szClassName)))
+ if (GetClassName(hwndCtl, szClassName, _countof(szClassName)))
if (!lstrcmpi(szClassName, _T("MDIClient")))
return hwndCtl;
hwndCtl = GetParent(hwndCtl);
@@ -272,7 +272,7 @@ static BOOL CALLBACK CreateCtlIdEnumProc(HWND hwnd, LPARAM lParam)
TCHAR szClassName[32];
if (GetClassLong(hwnd, GCW_ATOM) == 32770) // class="#32770"
return TRUE;
- if (GetClassName(hwnd, szClassName, sizeof(szClassName)))
+ if (GetClassName(hwnd, szClassName, _countof(szClassName)))
if (!lstrcmpi(szClassName, _T("MDIClient")))
return TRUE;
if (GetWindowLongPtr(hwnd, GWL_ID) <= 0 || GetWindowLongPtr(hwnd, GWL_ID) == 0xFFFF)
@@ -293,7 +293,7 @@ int GetControlID(HWND hwndCtl)
if (ccid.id != 0)
return ccid.id;
- if (GetClassName(hwndCtl, szClassName, sizeof(szClassName))) {
+ if (GetClassName(hwndCtl, szClassName, _countof(szClassName))) {
if (!lstrcmpi(szClassName, UPDOWN_CLASS)) { // handle spinner controls as a whole
DWORD style;
HWND hwndBuddy;