Stop inserting empty lines at end of minetest.conf file each time it is rewritten
authorCraig Robbins <kde.psych@gmail.com>
Fri, 7 Nov 2014 01:47:07 +0000 (11:47 +1000)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Sat, 8 Nov 2014 20:57:52 +0000 (21:57 +0100)
See: https://github.com/minetest/minetest/issues/1790

src/settings.cpp

index ca0775330414b8b4a62ab88a791897d340caecc3..65896ef27cf22848248f2e5a311abd0ea4975a71 100644 (file)
@@ -667,8 +667,9 @@ void Settings::getUpdatedConfigObject(std::istream &is,
                bool &changed)
 {
        std::string name, value;
+
        if (!parseConfigObject(is, name, value)) {
-               dst.push_back(value + '\n');
+               dst.push_back(value + (is.eof() ? "" : "\n"));
                return;
        }
 
@@ -679,7 +680,7 @@ void Settings::getUpdatedConfigObject(std::istream &is,
                        changed = true;
                }
 
-               dst.push_back(name + " = " + new_value + '\n');
+               dst.push_back(name + " = " + new_value + (is.eof() ? "" : "\n"));
                updated.insert(name);
        } else { // File contains a setting which is not in m_settings
                changed = true;