From 5a4ec571583845e2c6e7d005b400309072690d07 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 23 Mar 2014 20:43:18 +0000 Subject: new setting in a mirandaboot.ini:DefaultLanguage git-svn-id: http://svn.miranda-ng.org/main/trunk@8721 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/langpack.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp index 2fadf0f073..009185407a 100644 --- a/src/mir_core/langpack.cpp +++ b/src/mir_core/langpack.cpp @@ -359,11 +359,16 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack) { - lstrcpy(langPack.tszFileName, szLangPack); - lstrcpy(langPack.tszFullPath, szLangPack); + if (!lstrcmp(szLangPack, langPack.tszFullPath)) + return 0; + + if (g_entryCount) + UnloadLangPackModule(); + + _tcsncpy_s(langPack.tszFullPath, SIZEOF(langPack.tszFullPath), szLangPack, _TRUNCATE); TCHAR *p = _tcsrchr(langPack.tszFullPath, '\\'); - if (p) - p[1] = 0; + _tcsncpy_s(langPack.tszFileName, SIZEOF(langPack.tszFullPath), (p == NULL) ? szLangPack : p + 1, _TRUNCATE); + CharLower(langPack.tszFileName); FILE *fp = _tfopen(szLangPack, _T("rt")); if (fp == NULL) @@ -379,7 +384,6 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack) // body fseek(fp, startOfLine, SEEK_SET); - g_entriesAlloced = 0; LoadLangPackFile(fp, line, fileCp); fclose(fp); @@ -640,7 +644,7 @@ void UnloadLangPackModule() if (g_entryCount) { mir_free(g_pEntries); g_pEntries = 0; - g_entryCount = 0; + g_entryCount = g_entriesAlloced = 0; } } -- cgit v1.2.3