summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-07-07 18:11:32 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-07-07 18:11:32 +0000
commit5dbbf5cdb80ad060482727b884f2220efdc74746 (patch)
treee17f8e82f13cb8c805928588ab18567991cfeb65
parent38d28e8206acfcc337844658927e8319594fbc3d (diff)
fix for processing backslashes in langpacks
git-svn-id: http://svn.miranda-ng.org/main/trunk@5262 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/mir_core/langpack.cpp15
1 files changed, 10 insertions, 5 deletions
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;