Emulator Issues #629
closedLinux: Newlines in .ini files not handled properly
0%
Description
Since the .ini files included in trunk use the CRLF newline format, when
they're read by CIniFile in a Linux OS a trailing \r character is added to
every line. This in turn breaks the parsing of said lines, mostly when
trying to parse numbers. I've put together this little patch but I thought
I'd raise an issue so you can review it, since it's kind of a hack and
IniFile.cpp is part of Common. Also, my guess is a similar problem is
occurs in Mac OS, where every line begins with a LF character.
Index: Source/Core/Common/Src/IniFile.cpp¶
--- Source/Core/Common/Src/IniFile.cpp (revision 2382)
+++ Source/Core/Common/Src/IniFile.cpp (working copy)
@@ -268,8 +268,6 @@
// ------------
bool IniFile::Load(const char* filename)
{
-
// Maximum number of letters in a line
-
static const int MAX_BYTES = 1024*10;
sections.clear();
sections.push_back(Section(""));
@@ -286,10 +284,17 @@while (!in.eof())
{ -
char templine[MAX_BYTES];
-
in.getline(templine, MAX_BYTES);
-
std::string line = templine;
-
std::string line;
-
std::getline(in, line);
+#ifndef _WIN32
-
if (!line.empty() && line.at(line.size()-1) == '\r')
-
{
-
line.erase(line.size()-1);
-
}
+#endif
+
if (in.eof())
{
break;
Updated by lpfaint99 over 15 years ago
wouldn't setting the svn:eol-style to native fix this?
Updated by hrydgard over 15 years ago
yeah but it's still good to be able to read windows ini files. Facugaich, you have
commit access right? Add a comment and submit it :)
Updated by nakeee over 15 years ago
Why remove the limit from getline though?
it's not so safe to read from a file with no byte limit
Updated by nakeee over 15 years ago
BTW how come there are ini files in trunk again?
We worked hard on removing all of them
Updated by facugaich over 15 years ago
- Status changed from New to Fixed
Nakee, these are the ones I'm talking about (maybe this isn't actually trunk and I
got it wrong):
http://code.google.com/p/dolphin-emu/source/browse/trunk#trunk/Data/User/GameConfig