Some Windows gcc fixes

This commit is contained in:
nhmall
2024-11-30 19:06:05 -05:00
parent bc88266081
commit b89e792873
8 changed files with 53 additions and 31 deletions

View File

@@ -1022,7 +1022,8 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
pFile = _tfopen(filename, TEXT("wt+,ccs=UTF-8"));
if (!pFile) {
TCHAR buf[4096];
_stprintf(buf, TEXT("Cannot open %s for writing!"), filename);
nh_stprintf(buf, sizeof buf,
TEXT("Cannot open %s for writing!"), filename);
NHMessageBox(hWnd, buf, MB_OK | MB_ICONERROR);
if (text)
free(text);

View File

@@ -1188,10 +1188,12 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
&& data->menui.menu.items[lpdis->itemID].count != 0
&& item->glyphinfo.glyph != NO_GLYPH) {
if (data->menui.menu.items[lpdis->itemID].count == -1) {
_stprintf(wbuf, TEXT("Count: All"));
nh_stprintf(wbuf, sizeof wbuf,
TEXT("Count: All"));
} else {
_stprintf(wbuf, TEXT("Count: %d"),
data->menui.menu.items[lpdis->itemID].count);
nh_stprintf(wbuf, sizeof wbuf,
TEXT("Count: %d"),
data->menui.menu.items[lpdis->itemID].count);
}
/* TODO: add blinking for blink text */

View File

@@ -1061,8 +1061,9 @@ mswin_display_file(const char *filename, boolean must_exist)
if (!f) {
if (must_exist) {
TCHAR message[90];
_stprintf(message, TEXT("Warning! Could not find file: %s\n"),
NH_A2W(filename, wbuf, sizeof(wbuf)));
nh_stprintf(message, sizeof message,
TEXT("Warning! Could not find file: %s\n"),
NH_A2W(filename, wbuf, sizeof(wbuf)));
NHMessageBox(GetNHApp()->hMainWnd, message,
MB_OK | MB_ICONEXCLAMATION);
}

View File

@@ -249,12 +249,14 @@ extern COLORREF message_fg_color;
/* unicode stuff */
#define NH_CODEPAGE (SYMHANDLING(H_IBM) ? GetOEMCP() : GetACP())
#ifdef _UNICODE
#define nh_stprintf swprintf
#define NH_W2A(w, a, cb) \
(WideCharToMultiByte(NH_CODEPAGE, 0, (w), -1, (a), (cb), NULL, NULL), (a))
#define NH_A2W(a, w, cb) \
(MultiByteToWideChar(NH_CODEPAGE, 0, (a), -1, (w), (cb)), (w))
#else
#define nh_stprintf snprintf
#define NH_W2A(w, a, cb) (strncpy((a), (w), (cb)))
#define NH_A2W(a, w, cb) (strncpy((w), (a), (cb)))