Added a forgotten header, fixed warnings.

This commit is contained in:
Quantum 2013-06-02 22:05:20 -04:00
parent e9e0ba6262
commit f14bd75015
2 changed files with 47 additions and 7 deletions

38
include/NLSWrap.hpp Normal file
View file

@ -0,0 +1,38 @@
#pragma once
#ifndef id8B5E818D_F6E4_43FA_889FF93BB24D8D62
#define id8B5E818D_F6E4_43FA_889FF93BB24D8D62
typedef int (WINAPI *FN_NORMALIZESTRING)(UINT NormForm, LPCWSTR lpSrcString,
int cwSrcLength, LPWSTR lpDstString,
int cwDstLength);
FN_NORMALIZESTRING f_NormalizeString = NULL;
inline void ZalgoNormalizeInit()
{
HMODULE module = LoadLibrary(L"normaliz.dll");
FARPROC proc = GetProcAddress(module, "NormalizeString");
if (proc)
f_NormalizeString = (FN_NORMALIZESTRING) proc;
}
inline UINT NormalizeStringForm(DWORD form)
{
switch (form) {
case MAP_PRECOMPOSED:
return 0x1; // NormalizationC
case MAP_COMPOSITE:
return 0x2; // NormalizationD
default:
return 0;
}
}
inline int ZalgoNormalizeString(DWORD form, LPCWSTR src, LPWSTR dst, int bufsize)
{
if (f_NormalizeString)
return f_NormalizeString(NormalizeStringForm(form), src, -1, dst, bufsize);
else
return FoldString(form, src, -1, dst, bufsize);
}
#endif // header

View file

@ -280,9 +280,9 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
Edit_GetText(m_message, text, textlen);
zalgo = ZalgoComes(text,
IsDlgButtonChecked(m_hwnd, ZALGO_GO_UP),
IsDlgButtonChecked(m_hwnd, ZALGO_GO_CENTER),
IsDlgButtonChecked(m_hwnd, ZALGO_GO_DOWN),
IsDlgButtonChecked(m_hwnd, ZALGO_GO_UP) != 0,
IsDlgButtonChecked(m_hwnd, ZALGO_GO_CENTER) != 0,
IsDlgButtonChecked(m_hwnd, ZALGO_GO_DOWN) != 0,
GetDlgItemInt(m_hwnd, ZALGO_MESS_LEVEL, NULL, FALSE));
Edit_SetText(m_message, zalgo);
@ -329,7 +329,7 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
ShowWindow(m_preview->GetHWND(), SW_SHOW);
}
case TEXT_TO_NFC: {
wchar_t *orig, *nfc;
wchar_t *orig, *nfc = NULL;
int bufsize;
int textlen;
@ -346,12 +346,13 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
Edit_SetText(m_message, nfc);
nfccleanup:
delete nfc;
if (nfc)
delete nfc;
delete orig;
break;
}
case TEXT_TO_NFD: {
wchar_t *orig, *nfd;
wchar_t *orig, *nfd = NULL;
int bufsize;
int textlen;
@ -368,7 +369,8 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
Edit_SetText(m_message, nfd);
nfdcleanup:
delete nfd;
if (nfd)
delete nfd;
delete orig;
break;
}