Ticket #3990: t3990_allow_empty_strings_in_config_v1.patch

File t3990_allow_empty_strings_in_config_v1.patch, 1.7 KB (added by elexis, 8 years ago)

If a comma separated list is given, the empty strings will be recognized correctly too, even if the list ends with a comma.

  • source/ps/ConfigDB.cpp

    bool CConfigDB::Reload(EConfigNamespace  
    334334                case '\r':
    335335                case '\t':
    336336                    break; // ignore
    337337
    338338                case ',':
    339                     if (!value.empty())
    340                         values.push_back(value);
     339                    values.push_back(value);
    341340                    value.clear();
    342341                    break;
    343342
    344343                default:
    345344                    value.push_back(*pos);
    346345                    break;
    347346                }
    348347            }
    349348            if (quoted) // We ignore the invalid parameter
    350349                LOGERROR("Unmatched quote while parsing config file '%s' on line %d", m_ConfigFile[ns].string8(), line);
    351             else if (!value.empty())
    352                 values.push_back(value);
     350
     351            values.push_back(value);
    353352            value.clear();
    354353            quoted = false;
    355354            break; // We are either at the end of the line, or we still have a comment to parse
    356355
    357356        default:
    bool CConfigDB::Reload(EConfigNamespace  
    361360
    362361        // Consume the rest of the line
    363362        while (pos < filebufend && *pos != '\n')
    364363            ++pos;
    365364        // Store the setting
    366         if (!name.empty() && !values.empty())
     365        if (!name.empty())
    367366        {
    368367            CStr key(header + name);
    369368            newMap[key] = values;
    370369            if (key == "lobby.password")
    371370                LOGMESSAGE("Loaded config string \"%s\"", key);
    bool CConfigDB::Reload(EConfigNamespace  
    376375                    vals += "\"" + EscapeString(newMap[key][i]) + "\", ";
    377376                vals += "\"" + EscapeString(newMap[key][values.size()-1]) + "\"";
    378377                LOGMESSAGE("Loaded config string \"%s\" = %s", key, vals);
    379378            }
    380379        }
    381         else if (!name.empty())
    382             LOGERROR("Encountered config setting '%s' without value while parsing '%s' on line %d", name, m_ConfigFile[ns].string8(), line);
    383380
    384381        name.clear();
    385382        values.clear();
    386383        ++line;
    387384    }