Changed: ForceUtf8 parameter useless now

--HG--
branch : develop
This commit is contained in:
kervala 2016-11-04 20:19:41 +01:00
parent 369a121aa1
commit 9e0954fad5
7 changed files with 27 additions and 31 deletions

View file

@ -144,12 +144,10 @@ public:
* 16 bits encoding can be recognized by the official header : * 16 bits encoding can be recognized by the official header :
* FF, FE, witch can be reversed if the data are MSB first. * FF, FE, witch can be reversed if the data are MSB first.
* *
* Optionally, you can force the reader to consider the file as
* UTF-8 encoded.
* Optionally, you can ask the reader to interpret #include commands. * Optionally, you can ask the reader to interpret #include commands.
*/ */
static void readTextFile(const std::string &filename, static void readTextFile(const std::string &filename,
ucstring &result, bool forceUtf8 = false, ucstring &result,
bool fileLookup = true, bool fileLookup = true,
bool preprocess = false, bool preprocess = false,
TLineFormat lineFmt = LINE_FMT_NO_CARE, TLineFormat lineFmt = LINE_FMT_NO_CARE,
@ -259,7 +257,7 @@ private:
/// The internal read function, it does the real job of readTextFile /// The internal read function, it does the real job of readTextFile
static void _readTextFile(const std::string &filename, static void _readTextFile(const std::string &filename,
ucstring &result, bool forceUtf8, ucstring &result,
bool fileLookup, bool fileLookup,
bool preprocess, bool preprocess,
TLineFormat lineFmt, TLineFormat lineFmt,

View file

@ -412,7 +412,7 @@ void CConfigFile::reparse (bool lookupPaths)
if (!CPath::lookup(fn, false).empty()) if (!CPath::lookup(fn, false).empty())
{ {
ucstring content; ucstring content;
CI18N::readTextFile(fn, content, true, true, true); CI18N::readTextFile(fn, content, true, true);
string utf8 = content.toUtf8(); string utf8 = content.toUtf8();
CMemStream stream; CMemStream stream;

View file

@ -117,7 +117,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
*/ */
ucstring text; ucstring text;
CI18N::readTextFile(filename, text, false, false, true, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, text, false, true, CI18N::LINE_FMT_LF);
// CI18N::readTextBuffer(buffer, size, text); // CI18N::readTextBuffer(buffer, size, text);
// delete [] buffer; // delete [] buffer;
@ -313,7 +313,7 @@ bool readPhraseFile(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, true, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, doc, false, true, CI18N::LINE_FMT_LF);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -626,7 +626,7 @@ bool loadExcelSheet(const string filename, TWorksheet &worksheet, bool checkUniq
fp.close(); fp.close();
ucstring str; ucstring str;
CI18N::readTextFile(filename, str, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, str, false, false, CI18N::LINE_FMT_LF);
if (!readExcelSheet(str, worksheet, checkUnique)) if (!readExcelSheet(str, worksheet, checkUnique))
return false; return false;

View file

@ -656,7 +656,6 @@ bool CI18N::parseMarkedString(ucchar openMark, ucchar closeMark, ucstring::const
void CI18N::readTextFile(const string &filename, void CI18N::readTextFile(const string &filename,
ucstring &result, ucstring &result,
bool forceUtf8,
bool fileLookup, bool fileLookup,
bool preprocess, bool preprocess,
TLineFormat lineFmt, TLineFormat lineFmt,
@ -666,7 +665,7 @@ void CI18N::readTextFile(const string &filename,
TReadContext readContext; TReadContext readContext;
// call the inner function // call the inner function
_readTextFile(filename, result, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); _readTextFile(filename, result, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
if (!readContext.IfStack.empty()) if (!readContext.IfStack.empty())
{ {
@ -709,7 +708,6 @@ void CI18N::skipLine(ucstring::const_iterator &it, ucstring::const_iterator end,
void CI18N::_readTextFile(const string &filename, void CI18N::_readTextFile(const string &filename,
ucstring &result, ucstring &result,
bool forceUtf8,
bool fileLookup, bool fileLookup,
bool preprocess, bool preprocess,
TLineFormat lineFmt, TLineFormat lineFmt,
@ -819,7 +817,7 @@ void CI18N::_readTextFile(const string &filename,
subFilename.c_str()); subFilename.c_str());
ucstring inserted; ucstring inserted;
_readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
final += inserted; final += inserted;
} }
} }
@ -873,7 +871,7 @@ void CI18N::_readTextFile(const string &filename,
subFilename.c_str()); subFilename.c_str());
ucstring inserted; ucstring inserted;
_readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
final += inserted; final += inserted;
} }
} }

View file

@ -550,7 +550,7 @@ void executeScriptBuf(const string &text)
void executeScriptFile(const string &filename) void executeScriptFile(const string &filename)
{ {
ucstring temp; ucstring temp;
CI18N::readTextFile(filename, temp, false, false, false); CI18N::readTextFile(filename, temp, false, false);
if (temp.empty()) if (temp.empty())
{ {

View file

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
} }
ucstring str; ucstring str;
CI18N::readTextFile(inputFile, str, false, false, false); CI18N::readTextFile(inputFile, str, false, false);
if (outMode == ASCII) if (outMode == ASCII)
{ {

View file

@ -190,7 +190,7 @@ bool readPhraseFile1(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, doc, false, false, CI18N::LINE_FMT_LF);
verifyVersion(doc, 1); verifyVersion(doc, 1);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -199,7 +199,7 @@ bool readPhraseFile2(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, doc, false, false, CI18N::LINE_FMT_LF);
verifyVersion(doc, 2); verifyVersion(doc, 2);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -352,7 +352,7 @@ bool mergeStringDiff(vector<TStringInfo> &strings, const string &language, const
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str()); LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str());
@ -680,7 +680,7 @@ void cleanComment(const std::string & filename)
ucstring text; ucstring text;
uint nbOldValue=0; uint nbOldValue=0;
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, text, false, false, CI18N::LINE_FMT_LF);
ucstring newText; ucstring newText;
ucstring::size_type last = 0; ucstring::size_type last = 0;
@ -801,7 +801,7 @@ int mergeStringDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -841,7 +841,7 @@ bool mergePhraseDiff(vector<TPhrase> &phrases, const string &language, bool only
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
verifyVersion(text, 1); verifyVersion(text, 1);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
@ -1165,7 +1165,7 @@ int mergePhraseDiff(int argc, char *argv[], int version)
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -1334,7 +1334,7 @@ int mergeClauseDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -1359,7 +1359,7 @@ bool mergeWorksheetDiff(const std::string filename, TWorksheet &sheet, bool only
if (onlyTranslated) if (onlyTranslated)
{ {
ucstring text; ucstring text;
CI18N::readTextFile(fileList[i], text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(fileList[i], text, false, false, CI18N::LINE_FMT_LF);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str()); LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str());
@ -1692,7 +1692,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
// there is no translated file yet, build one from the working file. // there is no translated file yet, build one from the working file.
ucstring str; ucstring str;
string addfn = addDir+additionFile; string addfn = addDir+additionFile;
CI18N::readTextFile(addfn, str, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(addfn, str, false, false, CI18N::LINE_FMT_LF);
str = str.substr(0, str.find(nl)+2); str = str.substr(0, str.find(nl)+2);
CI18N::writeTextFile(transDir+filename, str); CI18N::writeTextFile(transDir+filename, str);
// reread the file. // reread the file.
@ -1712,7 +1712,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(transDir+filename, old, false, true, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(transDir+filename, old, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
{ {
string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename)); string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename));
@ -1866,7 +1866,7 @@ void cropLines(const std::string &filename, uint32 nbLines)
LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str()); LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str());
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, utext, false, false, CI18N::LINE_FMT_LF);
string text = utext.toUtf8(); string text = utext.toUtf8();
@ -1911,7 +1911,7 @@ int makeWork()
// change #include "*_en.txt" into #include "*_wk.txt" // change #include "*_en.txt" into #include "*_wk.txt"
ucstring utext; ucstring utext;
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, utext, false, false, CI18N::LINE_FMT_LF);
string text = utext.toUtf8(); string text = utext.toUtf8();
bool changedFile = false; bool changedFile = false;
@ -2349,7 +2349,7 @@ void patchWorkFile(vector<TPhrase> &updatedPhrase, const std::string & filename)
{ {
ucstring text; ucstring text;
if ( updatedPhrase.empty() ) { return; } if ( updatedPhrase.empty() ) { return; }
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, text, false, false, CI18N::LINE_FMT_LF);
vector<TPhrase>::const_iterator first(updatedPhrase.begin()); vector<TPhrase>::const_iterator first(updatedPhrase.begin());
vector<TPhrase>::const_iterator last(updatedPhrase.end()); vector<TPhrase>::const_iterator last(updatedPhrase.end());
for (; first != last; ++first) for (; first != last; ++first)
@ -2490,7 +2490,7 @@ bool mergePhraseDiff2(vector<TPhrase> &phrases, const string &language, bool onl
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
verifyVersion(text, 2); verifyVersion(text, 2);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
@ -3030,7 +3030,7 @@ int mergePhraseDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF); CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str()); CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str());
} }