1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:53:51 +00:00

mwiniimporter: fix line ending problem

This commit is contained in:
Emanuel Guevel 2012-12-31 16:44:22 +01:00
parent cb71efc427
commit e2b348de96

View file

@ -660,10 +660,19 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(std::string filename) {
std::string line; std::string line;
while (std::getline(file, line)) { while (std::getline(file, line)) {
if(line[0] == '[') { // unify Unix-style and Windows file ending
if(line.length() > 2) { if (!(line.empty()) && (line[line.length()-1]) == '\r') {
section = line.substr(1, line.length()-2); line = line.substr(0, line.length()-1);
} }
if(line[0] == '[') {
int pos = line.find(']');
if(pos < 2) {
std::cout << "Warning: ini file wrongly formatted (" << line << "). Line ignored." << std::endl;
continue;
}
section = line.substr(1, line.find(']')-1);
continue; continue;
} }