From 6cb52f7c6cb47112df9fc0d89c4fa829e474a561 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jul 2012 07:27:16 +0000 Subject: unneeded structure removed git-svn-id: http://svn.miranda-ng.org/main/trunk@784 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Mir_core/langpack.cpp | 52 +++++++++++++++++-------------------------- plugins/Mir_core/miranda.h | 10 ++------- 2 files changed, 23 insertions(+), 39 deletions(-) (limited to 'plugins/Mir_core') diff --git a/plugins/Mir_core/langpack.cpp b/plugins/Mir_core/langpack.cpp index 9aa2f6694c..90c11a4a65 100644 --- a/plugins/Mir_core/langpack.cpp +++ b/plugins/Mir_core/langpack.cpp @@ -24,13 +24,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LANGPACK_BUF_SIZE 4000 -static int CompareMuuids(const LangPackMuuid* p1, const LangPackMuuid* p2) +static int CompareMuuids(const MUUID* p1, const MUUID* p2) { - return memcmp(&p1->muuid, &p2->muuid, sizeof(MUUID)); + return memcmp(p1, p2, sizeof(MUUID)); } -static LIST lMuuids(10, CompareMuuids); -static LangPackMuuid* pCurrentMuuid = NULL; +static LIST lMuuids(10, CompareMuuids); +static MUUID* pCurrentMuuid = NULL; static BOOL bModuleInitialized = FALSE; @@ -38,7 +38,7 @@ struct LangPackEntry { DWORD englishHash; char *local; wchar_t *wlocal; - LangPackMuuid* pMuuid; + MUUID* pMuuid; LangPackEntry* pNext; // for langpack items with the same hash value }; @@ -227,13 +227,11 @@ static void LoadLangPackFile(FILE* fp, char* line, UINT fileCp) fgets(line, SIZEOF(line), p); UINT fileCp = CP_ACP; - if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') - { + if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') { fileCp = CP_UTF8; fseek(p, 3, SEEK_SET); } - else - { + else { fileCp = langPack.defaultANSICp; fseek(p, 0, SEEK_SET); } @@ -247,9 +245,8 @@ static void LoadLangPackFile(FILE* fp, char* line, UINT fileCp) if ( !EnterMuuid(line+7, t)) continue; - LangPackMuuid* pNew = (LangPackMuuid*)mir_alloc(sizeof(LangPackMuuid)); - memcpy(&pNew->muuid, &t, sizeof(t)); - pNew->pInfo = NULL; + MUUID* pNew = (MUUID*)mir_alloc(sizeof(MUUID)); + memcpy(pNew, &t, sizeof(t)); lMuuids.insert(pNew); pCurrentMuuid = pNew; } @@ -401,7 +398,7 @@ static int SortLangPackHashesProc2(LangPackEntry *arg1, LangPackEntry *arg2) return 0; } -static char *LangPackTranslateString(LangPackMuuid* pUuid, const char *szEnglish, const int W) +static char *LangPackTranslateString(MUUID* pUuid, const char *szEnglish, const int W) { if (langPack.entryCount == 0 || szEnglish == NULL) return (char*)szEnglish; @@ -438,12 +435,11 @@ MIR_CORE_DLL(TCHAR*) Langpack_PcharToTchar(const char* pszStr) if (pszStr == NULL) return NULL; - { int len = (int)strlen(pszStr); - TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR)); - MultiByteToWideChar(Langpack_GetDefaultCodePage(), 0, pszStr, -1, result, len); - result[len] = 0; - return mir_wstrdup(TranslateW(result)); - } + int len = (int)strlen(pszStr); + TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR)); + MultiByteToWideChar(Langpack_GetDefaultCodePage(), 0, pszStr, -1, result, len); + result[len] = 0; + return mir_wstrdup(TranslateW(result)); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -460,7 +456,7 @@ MIR_CORE_DLL(WCHAR*) TranslateW_LP(const WCHAR* str, int hLangpack) MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int hLangpack) { - LangPackMuuid* uuid = Langpack_LookupUuid(hLangpack); + MUUID* uuid = Langpack_LookupUuid(hLangpack); MENUITEMINFO mii; mii.cbSize = MENUITEMINFO_V4_SIZE; @@ -483,7 +479,7 @@ MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int hLangpack) } } -static void TranslateWindow(LangPackMuuid* pUuid, HWND hwnd) +static void TranslateWindow(MUUID* pUuid, HWND hwnd) { TCHAR title[2048]; GetWindowText(hwnd, title, SIZEOF(title)); @@ -505,7 +501,7 @@ static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd, LPARAM lParam) TCHAR szClass[32]; int id = GetDlgCtrlID(hwnd); - LangPackMuuid* uuid = Langpack_LookupUuid(hLangpack); + MUUID* uuid = Langpack_LookupUuid(hLangpack); GetClassName(hwnd, szClass, SIZEOF(szClass)); if ( !lstrcmpi(szClass, _T("static")) || !lstrcmpi(szClass, _T("hyperlink")) || !lstrcmpi(szClass, _T("button")) || !lstrcmpi(szClass, _T("MButtonClass")) || !lstrcmpi(szClass, _T("MHeaderbarCtrl"))) @@ -525,7 +521,7 @@ MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, int hLangpack) ///////////////////////////////////////////////////////////////////////////////////////// -MIR_CORE_DLL(LangPackMuuid*) Langpack_LookupUuid(WPARAM wParam) +MIR_CORE_DLL(MUUID*) Langpack_LookupUuid(WPARAM wParam) { int idx = (wParam >> 16) & 0xFFFF; return (idx > 0 && idx <= lMuuids.getCount()) ? lMuuids[ idx-1 ] : NULL; @@ -533,8 +529,7 @@ MIR_CORE_DLL(LangPackMuuid*) Langpack_LookupUuid(WPARAM wParam) MIR_CORE_DLL(int) Langpack_GetPluginHandle(PLUGININFOEX* pInfo) { - LangPackMuuid tmp; tmp.muuid = pInfo->uuid; - int idx = lMuuids.getIndex(&tmp); + int idx = lMuuids.getIndex(&pInfo->uuid); if (idx == -1) return 0; @@ -543,12 +538,10 @@ MIR_CORE_DLL(int) Langpack_GetPluginHandle(PLUGININFOEX* pInfo) MIR_CORE_DLL(int) Langpack_MarkPluginLoaded(PLUGININFOEX* pInfo) { - LangPackMuuid tmp; tmp.muuid = pInfo->uuid; - int idx = lMuuids.getIndex(&tmp); + int idx = lMuuids.getIndex(&pInfo->uuid); if (idx == -1) return 0; - lMuuids[ idx ]->pInfo = pInfo; return (idx+1) << 16; } @@ -562,9 +555,6 @@ MIR_CORE_DLL(void) Langpack_SortDuplicates(void) bool bSortNeeded = false; for (int i=1; i < langPack.entryCount; i++, s++) { - if (s->pMuuid != NULL && s->pMuuid->pInfo == NULL) - s->pMuuid = NULL; - if (s->englishHash != dwSavedHash) { pLast = d; if (s != d) diff --git a/plugins/Mir_core/miranda.h b/plugins/Mir_core/miranda.h index ed3f4a5b75..06aae73420 100644 --- a/plugins/Mir_core/miranda.h +++ b/plugins/Mir_core/miranda.h @@ -24,19 +24,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define NEWSTR_ALLOCA(A) (A == NULL)?NULL:strcpy((char*)alloca(strlen(A)+1), A) #define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1)* sizeof(TCHAR)), A) -struct LangPackMuuid -{ - MUUID muuid; - PLUGININFOEX* pInfo; -}; - extern "C" { MIR_CORE_DLL(int) Langpack_GetPluginHandle(PLUGININFOEX* pInfo); MIR_CORE_DLL(int) Langpack_MarkPluginLoaded(PLUGININFOEX* pInfo); }; -MIR_CORE_DLL(LangPackMuuid*) Langpack_LookupUuid(WPARAM wParam); +MIR_CORE_DLL(MUUID*) Langpack_LookupUuid(WPARAM wParam); void UnloadLangPackModule(void); @@ -90,7 +84,7 @@ extern LIST pluginListAddr; /**** langpack.cpp *********************************************************************/ -char* LangPackTranslateString(struct LangPackMuuid* pUuid, const char *szEnglish, const int W); +char* LangPackTranslateString(MUUID* pUuid, const char *szEnglish, const int W); TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish); /**** options.cpp **********************************************************************/ -- cgit v1.2.3