From 9f934f77657bab1a811a495fde7f6a55d3ea70ae Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:22:10 +0100 Subject: [PATCH] Changed: Discard \r and only use \n --HG-- branch : develop --- code/nel/src/misc/i18n.cpp | 22 ++++++++++++++++----- code/ryzom/tools/translation_tools/main.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index b511197c8..f61bcddf6 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -502,17 +502,30 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato if (storeComments && *it == '/' && it+1 != last && *(it+1) == '/') { // found a one line C comment. Store it until end of line. - while (it != last && *it != '\n') + while (it != last && (*it != '\n' && *it != '\r')) storeComments->push_back(*it++); + // store the final '\n' if (it != last) - storeComments->push_back(*it++); + storeComments->push_back('\n'); } else if (storeComments && *it == '/' && it+1 != last && *(it+1) == '*') { // found a multi line C++ comment. store until we found the closing '*/' - while (it != last && !(*it == '*' && it+1 != last && *(it+1) == '/')) - storeComments->push_back(*it++); + while (it != last && !(*it == '*' && it + 1 != last && *(it + 1) == '/')) + { + // don't put \r + if (*it == '\r') + { + // skip it + ++it; + } + else + { + storeComments->push_back(*it++); + } + } + // store the final '*' if (it != last) storeComments->push_back(*it++); @@ -522,7 +535,6 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato storeComments->push_back(*it++); // and a new line. - storeComments->push_back('\r'); storeComments->push_back('\n'); } else diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 04ea60f61..456cd871e 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -153,9 +153,9 @@ void showUsage(char *exeName) void verifyVersion(ucstring& doc, int versionId) { - ucstring version1("// DIFF_VERSION 1\r\n"); + ucstring version1("// DIFF_VERSION 1\n"); ucstring::size_type version1Size = version1.size(); - ucstring version2("// DIFF_VERSION 2\r\n"); + ucstring version2("// DIFF_VERSION 2\n"); ucstring::size_type version2Size = version2.size(); switch (versionId) @@ -1071,7 +1071,7 @@ int makePhraseDiff(int argc, char *argv[]) { LOG("Writing difference file for language %s\n", Languages[l].c_str()); ucstring text; - text += "// DIFF_VERSION 1\r\n"; + text += "// DIFF_VERSION 1\n"; text += preparePhraseFile(diff, false); // add the tag for non translation text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl; @@ -2805,7 +2805,7 @@ int makePhraseDiff2(int argc, char *argv[]) { LOG("Writing difference file for language %s\n", Languages[l].c_str()); ucstring text; - text += "// DIFF_VERSION 2\r\n"; + text += "// DIFF_VERSION 2\n"; text += preparePhraseFile(diff, false); // add the tag for non translation text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl;