summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mir_core/langpack.cpp19
-rw-r--r--src/modules/langpack/langpack.cpp19
-rw-r--r--src/modules/langpack/langpack.h4
-rw-r--r--src/modules/langpack/lpopts.cpp21
4 files changed, 32 insertions, 31 deletions
diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp
index b362dc34e3..48d2f15aaa 100644
--- a/src/mir_core/langpack.cpp
+++ b/src/mir_core/langpack.cpp
@@ -327,14 +327,23 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start
return 3;
*pszColon++ = 0;
- if (!lstrcmpA(line, "Language")) { mir_snprintf(szLanguage, sizeof(szLanguage), "%s", pszColon); lrtrim(szLanguage); }
- else if (!lstrcmpA(line, "Last-Modified-Using")) { mir_snprintf(lpinfo.szLastModifiedUsing, sizeof(lpinfo.szLastModifiedUsing), "%s", pszColon); lrtrim(lpinfo.szLastModifiedUsing); }
+ if (!lstrcmpA(line, "Language")) {
+ mir_snprintf(szLanguage, sizeof(szLanguage), "%s", pszColon);
+ lrtrim(szLanguage);
+ }
+ else if (!lstrcmpA(line, "Last-Modified-Using")) {
+ lpinfo.szLastModifiedUsing = pszColon;
+ lpinfo.szLastModifiedUsing.Trim();
+ }
else if (!lstrcmpA(line, "Authors")) {
if (!szAuthors.IsEmpty())
szAuthors.AppendChar(' ');
szAuthors.Append(lrtrim(pszColon));
}
- else if (!lstrcmpA(line, "Author-email")) { mir_snprintf(lpinfo.szAuthorEmail, sizeof(lpinfo.szAuthorEmail), "%s", pszColon); lrtrim(lpinfo.szAuthorEmail); }
+ else if (!lstrcmpA(line, "Author-email")) {
+ lpinfo.szAuthorEmail = pszColon;
+ lpinfo.szAuthorEmail.Trim();
+ }
else if (!lstrcmpA(line, "Locale")) {
char szBuf[20], *stopped;
@@ -347,7 +356,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start
}
}
- strncpy_s(lpinfo.szAuthors, SIZEOF(lpinfo.szAuthors), szAuthors, _TRUNCATE);
+ lpinfo.szAuthors = szAuthors;
MultiByteToWideChar(lpinfo.codepage, 0, szLanguage, -1, lpinfo.tszLanguage, SIZEOF(lpinfo.tszLanguage));
@@ -628,8 +637,6 @@ MIR_CORE_DLL(int) LoadLangPackModule(void)
{
bModuleInitialized = TRUE;
- ZeroMemory(&langPack, sizeof(langPack));
-
hevChanged = CreateHookableEvent(ME_LANGPACK_CHANGED);
// look into mirandaboot.ini
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp
index 728e48db43..33a52b53d0 100644
--- a/src/modules/langpack/langpack.cpp
+++ b/src/modules/langpack/langpack.cpp
@@ -35,22 +35,21 @@ BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam)
/* language folder */
ptrT langpack(db_get_tsa(NULL, "Langpack", "Current"));
-
- LANGPACK_INFO pack;
- PathToAbsoluteT(_T("\\Languages\\langpack_*.txt"), pack.tszFullPath);
+
+ TCHAR tszFullPath[MAX_PATH];
+ PathToAbsoluteT(_T("\\Languages\\langpack_*.txt"), tszFullPath);
BOOL fPackFound = FALSE;
WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(pack.tszFullPath, &wfd);
+ HANDLE hFind = FindFirstFile(tszFullPath, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
/* get data */
- TCHAR tszFullPath[MAX_PATH];
PathToAbsoluteT(_T("\\Languages\\"), tszFullPath);
lstrcat(tszFullPath, wfd.cFileName);
- ZeroMemory(&pack, sizeof(pack));
+ LANGPACK_INFO pack;
if (!LoadLangPackDescr(tszFullPath, &pack)) {
pack.ftFileDate = wfd.ftLastWriteTime;
/* enabled? */
@@ -68,13 +67,13 @@ BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam)
/* default langpack: English */
if (callback != NULL) {
- ZeroMemory(&pack, sizeof(pack));
+ LANGPACK_INFO pack;
pack.Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
lstrcpy(pack.tszLanguage, _T("English"));
- lstrcpyA(pack.szAuthors, "Miranda NG Development Team");
- lstrcpyA(pack.szAuthorEmail, "project-info@miranda-ng.org");
+ pack.szAuthors = "Miranda NG Development Team";
+ pack.szAuthorEmail = "project-info@miranda-ng.org";
DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0);
- mir_snprintf(pack.szLastModifiedUsing, sizeof(pack.szLastModifiedUsing), "%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF));
+ pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF));
/* file date */
if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) {
lstrcpy(pack.tszFileName, _tcsrchr(pack.tszFullPath, '\\') + 1);
diff --git a/src/modules/langpack/langpack.h b/src/modules/langpack/langpack.h
index 137fabc245..b39f03215d 100644
--- a/src/modules/langpack/langpack.h
+++ b/src/modules/langpack/langpack.h
@@ -45,9 +45,7 @@ struct LANGPACK_INFO
TCHAR tszLanguage[64];
LCID Locale;
WORD codepage;
- char szAuthors[2048];
- char szAuthorEmail[128];
- char szLastModifiedUsing[64];
+ CMStringA szAuthors, szAuthorEmail, szLastModifiedUsing;
FILETIME ftFileDate;
TCHAR tszFileName[MAX_PATH]; /* just the file name itself */
TCHAR tszFullPath[MAX_PATH]; /* full path to the langpack */
diff --git a/src/modules/langpack/lpopts.cpp b/src/modules/langpack/lpopts.cpp
index d0258dde6b..b1c11ae665 100644
--- a/src/modules/langpack/lpopts.cpp
+++ b/src/modules/langpack/lpopts.cpp
@@ -72,9 +72,8 @@ static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack)
static BOOL InsertPackItemEnumProc(LANGPACK_INFO *pack, WPARAM wParam, LPARAM lParam)
{
- LANGPACK_INFO *pack2 = (LANGPACK_INFO*)mir_alloc(sizeof(LANGPACK_INFO));
- if (pack2 == NULL) return FALSE;
- CopyMemory(pack2, pack, sizeof(LANGPACK_INFO));
+ LANGPACK_INFO *pack2 = new LANGPACK_INFO();
+ *pack2 = *pack;
/* insert */
TCHAR tszName[512];
@@ -120,15 +119,6 @@ INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
EnumLangpacks(InsertPackItemEnumProc, (WPARAM)hwndList, (LPARAM)0);
return TRUE;
- case WM_DESTROY:
- {
- int count = ListBox_GetCount(hwndList);
- for (int i = 0; i < count; i++)
- mir_free((LANGPACK_INFO*)ListBox_GetItemData(hwndList, i));
- ComboBox_ResetContent(hwndList);
- }
- return TRUE;
-
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_LANGEMAIL:
@@ -194,6 +184,13 @@ INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
}
break;
+
+ case WM_DESTROY:
+ int count = ListBox_GetCount(hwndList);
+ for (int i = 0; i < count; i++)
+ delete (LANGPACK_INFO*)ListBox_GetItemData(hwndList, i);
+ ComboBox_ResetContent(hwndList);
+ return TRUE;
}
return FALSE;
}