New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle newlines in cIniFile #5447
Conversation
When reading the ini file, replace \n with newline. When writing, replace the newline with \n.
Isn't including regex for this overkill? Wouldn't a |
Thank you for your contribution! Firstly, please add yourself to the CONTRIBUTORS file to acknowledge our license and that your code is used in accordance to that. Secondly I agree with @NiLSPACE that regex is a bit overkill. Thirdly: Maybe we should add a sentence here, that line breaks are now supported and how they work |
Should I use ReplaceString from StringUtils instead of regex? |
Yes, please |
Indeed, regex is a bit overkill, ReplaceString is a good alternative. Also, please make sure it's possible to write a literal |
With the constraint mentioned, maybe regex is the way to go. If we want to add more for whatever reason, this is the easiest way to extend. |
Sorry for taking forever to push.. I'm having trouble with pushing to my fork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't address my comment made earlier; but I'd be happy to merge without that fix.
I do want the duplicated variables sorted out, no reason to have them.
src/IniFile.cpp
Outdated
@@ -191,6 +193,7 @@ bool cIniFile::WriteFile(const AString & a_FileName) const | |||
// Normally you would use ofstream, but the SGI CC compiler has | |||
// a few bugs with ofstream. So ... fstream used. | |||
fstream f; | |||
AString runvalue, writevalue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the point of having two separate strings here is - since writevalue is always set to the value of runvalue! Same for rawvalue up above.
Please remove one.
This reverts commit de11bac.
Now without plugin changes
I Fixed your request @bearbin |
This pull request replaces \n with newline a newline when reading an ini file. When writing to an ini file, the newline will be replaced with \n.
Example 1:
Example 2:
Fixes #5026