From 5dbbf5cdb80ad060482727b884f2220efdc74746 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 7 Jul 2013 18:11:32 +0000 Subject: fix for processing backslashes in langpacks git-svn-id: http://svn.miranda-ng.org/main/trunk@5262 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/langpack.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp index 9f70065fb1..ca69a9d811 100644 --- a/src/mir_core/langpack.cpp +++ b/src/mir_core/langpack.cpp @@ -68,11 +68,13 @@ static int IsEmpty(const char *str) return 1; } -static void ConvertBackslashes(char *str, UINT fileCp) +static int ConvertBackslashes(char *str, UINT fileCp) { + int shift = 0; char *pstr; for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0)) { if (*pstr == '\\') { + shift++; switch(pstr[1]) { case 'n': *pstr = '\n'; break; case 't': *pstr = '\t'; break; @@ -80,7 +82,10 @@ static void ConvertBackslashes(char *str, UINT fileCp) default: *pstr = pstr[1]; break; } memmove(pstr+1, pstr+2, strlen(pstr+2) + 1); -} } } + } + } + return shift; +} #ifdef _DEBUG //#pragma optimize("gt", on) @@ -254,20 +259,20 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp) continue; } - ConvertBackslashes(line, fileCp); + cbLen -= ConvertBackslashes(line, fileCp); if (line[0] == '[' && line[cbLen] == ']') { if (langPack.entryCount && langPack.entry[ langPack.entryCount-1].wszLocal == NULL) langPack.entryCount--; char *pszLine = line+1; - line[ lstrlenA(line)-1 ] = '\0'; + line[cbLen] = '\0'; if (++langPack.entryCount > langPack.entriesAlloced) { langPack.entriesAlloced += 128; langPack.entry = (LangPackEntry*)mir_realloc(langPack.entry, sizeof(LangPackEntry)*langPack.entriesAlloced); } - LangPackEntry *E = &langPack.entry[ langPack.entryCount-1 ]; + LangPackEntry *E = &langPack.entry[langPack.entryCount-1]; E->englishHash = mir_hashstr(pszLine); E->szLocal = NULL; E->wszLocal = NULL; -- cgit v1.2.3