Project

General

Profile

Actions

Emulator Issues #629

closed

Linux: Newlines in .ini files not handled properly

Added by facugaich almost 16 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

Also available in: Atom PDF