summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-12-20 22:21:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-12-20 22:21:06 +0300
commitef9f9d9ae4a91f08392ddd383a9c0ff3bed909f0 (patch)
tree2b3be3f90b5ba025d6f3ae2134a832010f5f80ea
parent42809c8f3d5248bbc4bd16724d8f5c9fcb254907 (diff)
mir_app: get rid of old good Windows min/max macroses
-rw-r--r--src/mir_app/src/clistgroups.cpp2
-rw-r--r--src/mir_app/src/clisttray.cpp2
-rw-r--r--src/mir_app/src/clui.cpp2
-rw-r--r--src/mir_app/src/db_ini.cpp6
-rw-r--r--src/mir_app/src/ei_groupIcon.cpp2
-rw-r--r--src/mir_app/src/ei_options.cpp4
-rw-r--r--src/mir_app/src/icolib.cpp2
-rw-r--r--src/mir_app/src/image_utils.cpp10
-rw-r--r--src/mir_app/src/menu_utils.cpp2
-rw-r--r--src/mir_app/src/meta_services.cpp2
-rw-r--r--src/mir_app/src/netlib_http.cpp8
-rw-r--r--src/mir_app/src/netlib_log.cpp2
-rw-r--r--src/mir_app/src/netlib_sock.cpp2
-rw-r--r--src/mir_app/src/netlib_upnp.cpp2
-rw-r--r--src/mir_app/src/proto_opts.cpp8
-rw-r--r--src/mir_app/src/srmm_util.cpp2
-rw-r--r--src/mir_app/src/stdafx.h2
17 files changed, 31 insertions, 29 deletions
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp
index 38861a7a2f..9e21ae1869 100644
--- a/src/mir_app/src/clistgroups.cpp
+++ b/src/mir_app/src/clistgroups.cpp
@@ -471,7 +471,7 @@ MIR_APP_DLL(HMENU) Clist_GroupBuildMenu(int startId)
pNextField = nullptr;
}
else {
- mir_wstrncpy(szThisField, pNextField, min(_countof(szThisField), pBackslash - pNextField + 1));
+ mir_wstrncpy(szThisField, pNextField, std::min(_countof(szThisField), size_t(pBackslash - pNextField + 1)));
pNextField = pBackslash + 1;
}
int compareResult = 1;
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp
index 544e192ca5..b36d49c0c7 100644
--- a/src/mir_app/src/clisttray.cpp
+++ b/src/mir_app/src/clisttray.cpp
@@ -368,7 +368,7 @@ int TrayIconUpdate(HICON hNewIcon, const wchar_t *szNewTip, const char *szPrefer
if (db_get_b(0, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
DWORD time1 = db_get_w(0, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 200;
DWORD time2 = db_get_w(0, "CList", "IconFlashTime", 550) + 1000;
- DWORD time = max(max(2000, time1), time2);
+ DWORD time = std::max(std::max(DWORD(2000), time1), time2);
if (RefreshTimerId)
KillTimer(nullptr, RefreshTimerId);
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index d7a78df9f3..611b39e89e 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -808,7 +808,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (GetMonitorInfo(hMon, &mi))
rcWorkArea = mi.rcWork;
- newHeight = max(nmc->pt.y, 9) + 1 + (rcWindow.bottom - rcWindow.top) - (rcTree.bottom - rcTree.top);
+ newHeight = std::max(nmc->pt.y, LONG(9)) + 1 + (rcWindow.bottom - rcWindow.top) - (rcTree.bottom - rcTree.top);
if (newHeight > (rcWorkArea.bottom - rcWorkArea.top) * maxHeight / 100)
newHeight = (rcWorkArea.bottom - rcWorkArea.top) * maxHeight / 100;
if (db_get_b(0, "CLUI", "AutoSizeUpward", 0)) {
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp
index a6e480923a..7b9de85da1 100644
--- a/src/mir_app/src/db_ini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -322,7 +322,7 @@ LBL_NewLine:
if (szLine[1] == '!')
szSection[0] = '\0';
else {
- mir_strncpy(szSection, szLine + 1, min(sizeof(szSection), (int)(szEnd - szLine)));
+ mir_strncpy(szSection, szLine + 1, std::min(sizeof(szSection), (size_t)(szEnd - szLine)));
switch (secur) {
case 0:
warnThisSection = false;
@@ -343,7 +343,7 @@ LBL_NewLine:
if (secFN) warnThisSection = 0;
}
if (szLine[1] == '?' || szLine[1] == '-') {
- mir_strncpy(szSection, szLine + 2, min(sizeof(szSection), (int)(szEnd - szLine - 1)));
+ mir_strncpy(szSection, szLine + 2, std::min(sizeof(szSection), (size_t)(szEnd - szLine - 1)));
db_enum_settings(0, SettingsEnumProc, szSection);
while (setting_items) {
SettingsList *next = setting_items->next;
@@ -366,7 +366,7 @@ LBL_NewLine:
continue;
char szName[128];
- mir_strncpy(szName, szLine, min(sizeof(szName), (int)(szValue - szLine + 1)));
+ mir_strncpy(szName, szLine, std::min(sizeof(szName), (size_t)(szValue - szLine + 1)));
szValue++;
{
warnSettingChangeInfo_t warnInfo;
diff --git a/src/mir_app/src/ei_groupIcon.cpp b/src/mir_app/src/ei_groupIcon.cpp
index 796f50d2f3..feb5d1a052 100644
--- a/src/mir_app/src/ei_groupIcon.cpp
+++ b/src/mir_app/src/ei_groupIcon.cpp
@@ -77,7 +77,7 @@ int ExtraIconGroup::getPosition() const
{
int pos = INT_MAX;
for (auto &p : m_items)
- pos = min(pos, p->getPosition());
+ pos = std::min(pos, p->getPosition());
return pos;
}
diff --git a/src/mir_app/src/ei_options.cpp b/src/mir_app/src/ei_options.cpp
index f9c1f13b6e..7bc851221b 100644
--- a/src/mir_app/src/ei_options.cpp
+++ b/src/mir_app/src/ei_options.cpp
@@ -279,9 +279,9 @@ public:
oldSlots[i] = registeredExtraIcons[i]->getSlot();
else // Remove old slot for groups to re-set images
oldSlots[i] = -1;
- lastUsedSlot = max(lastUsedSlot, registeredExtraIcons[i]->getSlot());
+ lastUsedSlot = std::max(lastUsedSlot, registeredExtraIcons[i]->getSlot());
}
- lastUsedSlot = min(lastUsedSlot, EXTRA_ICON_COUNT);
+ lastUsedSlot = std::min(lastUsedSlot, EXTRA_ICON_COUNT);
// Get user data and create new groups
LIST<ExtraIconGroup> groups(1);
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp
index 13d6d2baae..136a629689 100644
--- a/src/mir_app/src/icolib.cpp
+++ b/src/mir_app/src/icolib.cpp
@@ -62,7 +62,7 @@ LIST<IcolibItem> iconList(20, sttCompareIcons);
/////////////////////////////////////////////////////////////////////////////////////////
// Utility functions
-void __fastcall SafeDestroyIcon(HICON &hIcon)
+void SafeDestroyIcon(HICON &hIcon)
{
if (hIcon != nullptr) {
DestroyIcon(hIcon);
diff --git a/src/mir_app/src/image_utils.cpp b/src/mir_app/src/image_utils.cpp
index ee80b786ac..4a25f9a73a 100644
--- a/src/mir_app/src/image_utils.cpp
+++ b/src/mir_app/src/image_utils.cpp
@@ -67,23 +67,23 @@ MIR_APP_DLL(HBITMAP) Image_Resize(HBITMAP hBmp, int fit /* RESIZEBITMAP_*/, int
case RESIZEBITMAP_KEEP_PROPORTIONS:
if (height * widthOrig / heightOrig <= width) {
if (fit & RESIZEBITMAP_FLAG_DONT_GROW)
- height = min(height, bminfo.bmHeight);
+ height = std::min(height, (int)bminfo.bmHeight);
width = height * widthOrig / heightOrig;
}
else {
if (fit & RESIZEBITMAP_FLAG_DONT_GROW)
- width = min(width, bminfo.bmWidth);
+ width = std::min(width, (int)bminfo.bmWidth);
height = width * heightOrig / widthOrig;
}
break;
case RESIZEBITMAP_MAKE_SQUARE:
if (fit & RESIZEBITMAP_FLAG_DONT_GROW) {
- width = min(width, bminfo.bmWidth);
- height = min(height, bminfo.bmHeight);
+ width = std::min(width, (int)bminfo.bmWidth);
+ height = std::min(height, (int)bminfo.bmHeight);
}
- width = height = min(width, height);
+ width = height = std::min(width, height);
// Do not break. Use crop calcs to make size
case RESIZEBITMAP_CROP:
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp
index 6d8c142330..57c3d8a142 100644
--- a/src/mir_app/src/menu_utils.cpp
+++ b/src/mir_app/src/menu_utils.cpp
@@ -123,7 +123,7 @@ MIR_APP_DLL(BOOL) Menu_MeasureItem(LPARAM lParam)
if (pimi->iconId == -1)
return FALSE;
- mis->itemWidth = max(0, g_iIconSX - GetSystemMetrics(SM_CXMENUCHECK) + 4);
+ mis->itemWidth = std::max(0, g_iIconSX - GetSystemMetrics(SM_CXMENUCHECK) + 4);
mis->itemHeight = g_iIconSY + 2;
return TRUE;
}
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index 5c1f4f56e9..eacf7d4745 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -84,7 +84,7 @@ INT_PTR Meta_GetCaps(WPARAM wParam, LPARAM)
INT_PTR Meta_GetName(WPARAM wParam, LPARAM lParam)
{
char *name = (char *)Translate(META_PROTO);
- size_t size = min(mir_strlen(name), wParam - 1); // copy only the first size bytes.
+ size_t size = std::min(mir_strlen(name), wParam - 1); // copy only the first size bytes.
if (strncpy((char *)lParam, name, size) == nullptr)
return 1;
((char *)lParam)[size] = '\0';
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp
index da18e4bf53..bd479a45db 100644
--- a/src/mir_app/src/netlib_http.cpp
+++ b/src/mir_app/src/netlib_http.cpp
@@ -79,13 +79,13 @@ struct ProxyAuthList : OBJLIST<ProxyAuth>
ProxyAuthList proxyAuthList;
-static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, char *buf, int len, int flags)
+static int RecvWithTimeoutTime(NetlibConnection *nlc, int dwTimeoutTime, char *buf, int len, int flags)
{
- DWORD dwTimeNow;
+ int dwTimeNow;
if (nlc->foreBuf.isEmpty() && !Netlib_SslPending(nlc->hSsl)) {
while ((dwTimeNow = GetTickCount()) < dwTimeoutTime) {
- unsigned dwDeltaTime = min(dwTimeoutTime - dwTimeNow, 1000);
+ int dwDeltaTime = std::min(dwTimeoutTime - dwTimeNow, 1000);
int res = WaitUntilReadable(nlc->s, dwDeltaTime);
switch (res) {
@@ -732,7 +732,7 @@ MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection,
}
char *buffer = (char*)_alloca(NHRV_BUF_SIZE + 1);
- int bytesPeeked = Netlib_Recv(nlc, buffer, min(firstLineLength, NHRV_BUF_SIZE), flags | MSG_DUMPASTEXT);
+ int bytesPeeked = Netlib_Recv(nlc, buffer, std::min(firstLineLength, NHRV_BUF_SIZE), flags | MSG_DUMPASTEXT);
if (bytesPeeked != firstLineLength) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
Netlib_FreeHttpRequest(nlhr);
diff --git a/src/mir_app/src/netlib_log.cpp b/src/mir_app/src/netlib_log.cpp
index 9a3955eeae..f4a83fc005 100644
--- a/src/mir_app/src/netlib_log.cpp
+++ b/src/mir_app/src/netlib_log.cpp
@@ -511,7 +511,7 @@ MIR_APP_DLL(void) Netlib_Dump(HNETLIBCONN nlc, const void *pBuf, size_t len, boo
else {
for (int line = 0;; line += 16) {
auto *p = buf + line;
- int colsInLine = min(16, (int)len - line);
+ int colsInLine = std::min(16, (int)len - line);
if (colsInLine == 16)
str.AppendFormat("%08X: %02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X ",
line, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
diff --git a/src/mir_app/src/netlib_sock.cpp b/src/mir_app/src/netlib_sock.cpp
index 4cfe8ee4ff..821e7e37bc 100644
--- a/src/mir_app/src/netlib_sock.cpp
+++ b/src/mir_app/src/netlib_sock.cpp
@@ -58,7 +58,7 @@ MIR_APP_DLL(int) Netlib_Recv(HNETLIBCONN nlc, char *buf, int len, int flags)
int recvResult;
if (!nlc->foreBuf.isEmpty()) {
- recvResult = min(len, (int)nlc->foreBuf.length());
+ recvResult = std::min(len, (int)nlc->foreBuf.length());
memcpy(buf, nlc->foreBuf.data(), recvResult);
nlc->foreBuf.remove(recvResult);
}
diff --git a/src/mir_app/src/netlib_upnp.cpp b/src/mir_app/src/netlib_upnp.cpp
index 862d3989a2..693f963020 100644
--- a/src/mir_app/src/netlib_upnp.cpp
+++ b/src/mir_app/src/netlib_upnp.cpp
@@ -146,7 +146,7 @@ static bool txtParseParam(char* szData, char* presearch,
if (cp1 == nullptr) return false;
while (*(cp1-1) == ' ' && cp1 > cp) --cp1;
- len = min((size_t)(cp1 - cp), size-1);
+ len = std::min((size_t)(cp1 - cp), size-1);
strncpy(param, cp, len);
param[len] = 0;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index 5e5094bc1f..7c6b604672 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -299,7 +299,7 @@ public:
::SelectObject(hdc, hfnt);
::ReleaseDC(m_hwnd, hdc);
- m_normalHeight = 4 + max(m_titleHeight, g_iIconSY);
+ m_normalHeight = 4 + std::max(m_titleHeight, g_iIconSY);
m_selectedHeight = m_normalHeight + 4 + 2 * m_textHeight;
m_name.SendMsg(WM_SETFONT, (WPARAM)m_hfntTitle, 0);
@@ -684,11 +684,11 @@ BOOL CAccountListCtrl::OnDrawItem(DRAWITEMSTRUCT *lps)
SelectObject(lps->hDC, PARENT()->m_hfntTitle);
tmp = lps->rcItem.bottom;
- lps->rcItem.bottom = lps->rcItem.top + max(cyIcon, PARENT()->m_titleHeight);
+ lps->rcItem.bottom = lps->rcItem.top + std::max(cyIcon, PARENT()->m_titleHeight);
DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER);
lps->rcItem.bottom = tmp;
GetTextExtentPoint32(lps->hDC, text, (int)length, &sz);
- lps->rcItem.top += max(cxIcon, sz.cy) + 2;
+ lps->rcItem.top += std::max(cxIcon, (int)sz.cy) + 2;
}
if (lps->itemID == (unsigned)PARENT()->m_iSelected) {
@@ -951,7 +951,7 @@ void CAccountListCtrl::InitRename()
RECT rc;
GetItemRect(GetCurSel(), &rc);
rc.left += 2 * g_iIconSX + 4;
- rc.bottom = rc.top + max(g_iIconSX, PARENT()->m_titleHeight) + 4 - 1;
+ rc.bottom = rc.top + std::max(g_iIconSX, PARENT()->m_titleHeight) + 4 - 1;
++rc.top; --rc.right;
m_hwndEdit = ::CreateWindow(L"EDIT", pa->tszAccountName, WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, m_hwnd, nullptr, g_plugin.getInst(), nullptr);
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index cc805d6070..2bc644b6f2 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -38,7 +38,7 @@ MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pb
}
// give the RTF to the RE control
- *pcb = min(cb, LONG(lstrdat->bufferLen - lstrdat->bufferOffset));
+ *pcb = std::min(cb, LONG(lstrdat->bufferLen - lstrdat->bufferOffset));
memcpy(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
lstrdat->bufferOffset += *pcb;
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index f3fc28e0ff..d54ad76947 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct SslHandle *HSSL;
#ifdef _WINDOWS
+ #define NOMINMAX
+
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>