Merge branch 'origin/master' commit 'a499e9acdd385b57dd43caf88af3a6f7f53716ba'

This commit is contained in:
pelya
2020-03-20 00:10:46 +02:00
1448 changed files with 32573 additions and 27146 deletions

View File

@@ -1,5 +1,3 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
@@ -29,7 +27,7 @@
/**
* Create a new ini file with given group names.
* @param list_group_names A \c NULL terminated list with group names that should be loaded as lists instead of variables. @see IGT_LIST
* @param list_group_names A \c nullptr terminated list with group names that should be loaded as lists instead of variables. @see IGT_LIST
*/
IniFile::IniFile(const char * const *list_group_names) : IniLoadFile(list_group_names)
{
@@ -52,23 +50,23 @@ bool IniFile::SaveToDisk(const char *filename)
strecpy(file_new, filename, lastof(file_new));
strecat(file_new, ".new", lastof(file_new));
FILE *f = fopen(file_new, "w");
if (f == NULL) return false;
if (f == nullptr) return false;
for (const IniGroup *group = this->group; group != NULL; group = group->next) {
for (const IniGroup *group = this->group; group != nullptr; group = group->next) {
if (group->comment) fputs(group->comment, f);
fprintf(f, "[%s]\n", group->name);
for (const IniItem *item = group->item; item != NULL; item = item->next) {
if (item->comment != NULL) fputs(item->comment, f);
for (const IniItem *item = group->item; item != nullptr; item = item->next) {
if (item->comment != nullptr) fputs(item->comment, f);
/* protect item->name with quotes if needed */
if (strchr(item->name, ' ') != NULL ||
if (strchr(item->name, ' ') != nullptr ||
item->name[0] == '[') {
fprintf(f, "\"%s\"", item->name);
} else {
fprintf(f, "%s", item->name);
}
fprintf(f, " = %s\n", item->value == NULL ? "" : item->value);
fprintf(f, " = %s\n", item->value == nullptr ? "" : item->value);
}
}
if (this->comment) fputs(this->comment, f);