Project

General

Profile

Actions

Emulator Issues #629

closed

Linux: Newlines in .ini files not handled properly

Added by facugaich over 15 years ago.

Status:
Fixed
Priority:
Low
Assignee:
Category:
UI
% Done:

0%

Operating system:
N/A
Issue type:
Other
Milestone:
Regression:
No
Relates to usability:
Yes
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

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;

Actions #1

Updated by lpfaint99 over 15 years ago

wouldn't setting the svn:eol-style to native fix this?

Actions #2

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 :)

Actions #3

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

Actions #4

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

Actions #5

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

Actions

Also available in: Atom PDF