From e8fb6ae467feef14e89913588be1b845c41c3c46 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Wed, 4 May 2016 11:11:43 +0000 Subject: genlang keygen with newline changed when generating the keyid for text, all newlines \n must be converted to 0x0A Change-Id: I626776e94a6573d044522990a7f9ccc3d52b825b --- l10ntools/source/gConvPo.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'l10ntools') diff --git a/l10ntools/source/gConvPo.cxx b/l10ntools/source/gConvPo.cxx index 29cb2fe4acfc..431b58ee8685 100644 --- a/l10ntools/source/gConvPo.cxx +++ b/l10ntools/source/gConvPo.cxx @@ -206,7 +206,7 @@ void convert_po::save(const string& sFileName, { string sName; ostream outFile(&mfOutBuffer); - int newPos; + int newPos, oldPos; // isolate filename newPos = sFileName.find_last_of("/\\", sFileName.length()); @@ -224,7 +224,16 @@ void convert_po::save(const string& sFileName, outFile << "\"" << sResource << ".text\"" << endl; if (bFuzzy) outFile << "#, fuzzy" << endl; - outFile << "msgid \"" << sENUStext << "\"" << endl + outFile << "msgid \""; + newPos = oldPos = 0; + while ((newPos = sENUStext.find("\\n", oldPos)) > 0) { + newPos += 2; + outFile << "\"" << endl + << "\"" << sENUStext.substr(oldPos, newPos - oldPos); + oldPos = newPos; + } + outFile << "\"" << endl + << "\"" << sENUStext.substr(oldPos) << "\"" << endl << "msgstr \"" << sText << "\"" << endl; } @@ -249,6 +258,10 @@ string convert_po::genKeyId(const string& text) for (i = 0; (i = newText.find("\\\"", 0)) != (int)string::npos;) { newText.erase(i, 1); } + for (i = 0; (i = newText.find("\\n", 0)) != (int)string::npos;) { + newText.erase(i, 1); + newText[i] = 0x0A; + } aCRC32.process_bytes(newText.c_str(), newText.length()); unsigned int nCRC = aCRC32.checksum(); string key; -- cgit