Source: lierolibre Version: 0.5-1 Severity: serious Justification: fails to build from source (but built successfully in the past) Tags: patch
[X-Debbugs-Cc to [email protected]] A binNMU of lierolibre was attempted for the libconfig C++ ABI transition. Unfortunately, this failed, with a lot of errors like this: src/common.cpp: In member function 'void Texts::loadFromCFG(std::__cxx11::string)': src/common.cpp:165:38: error: no match for 'operator[]' (operand types are 'const libconfig::Setting' and 'std::__cxx11::basic_string<char>') gameModes[i] = (char const*)sgmodes["gameModes" + to_string(i)]; ^ In file included from src/common.hpp:41:0, from src/common.cpp:28: /usr/include/libconfig.h++:223:13: note: candidate: libconfig::Setting& libconfig::Setting::operator[](const char*) const Setting & operator[](const char *name) const; ^ /usr/include/libconfig.h++:223:13: note: no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*' /usr/include/libconfig.h++:224:13: note: candidate: libconfig::Setting& libconfig::Setting::operator[](int) const Setting & operator[](int index) const; ^ /usr/include/libconfig.h++:224:13: note: no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'int' This seems to be a deliberate change in libconfig 1.5. There used to be an inline operator[](const std::string &), but it was removed: > Note: `operator[]` had to remain as `const char*` to avoid ambiguities > in some situations. <https://github.com/hyperrealm/libconfig/commit/1ff9b7f9a2df1abbb5781b78d4065fa22bc5fad6> I'm not sure why the NMU of libconfig included a new upstream version, but it's happened now. I attach a patch which compiles. I have not tested it. Regards, S
From: Simon McVittie <[email protected]> Date: Fri, 14 Aug 2015 00:27:56 +0100 Subject: Adapt to libconfig 1.5 Setting::operator[](const std::string &) is no longer available. --- src/common.cpp | 18 ++++++++++++------ src/configCompat.cpp | 6 +++--- src/configHelper.cpp | 12 +++++------- src/constants.cpp | 6 +++--- src/gfx/palette.cpp | 9 ++++++--- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 2d6ada5..9508a37 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -162,7 +162,8 @@ void Texts::loadFromCFG(std::string cfgFilePath) const libconfig::Setting &sgmodes = texts["gameModes"]; for(int i = 0; i < 4; ++i) { - gameModes[i] = (char const*)sgmodes["gameModes" + to_string(i)]; + std::string key("gameModes" + to_string(i)); + gameModes[i] = (char const*)sgmodes[key.c_str()]; } const libconfig::Setting &sgmspec = texts["gameModeSpec"]; @@ -181,13 +182,15 @@ void Texts::loadFromCFG(std::string cfgFilePath) const libconfig::Setting &swstates = texts["weapStates"]; for(int i = 0; i < 3; ++i) { - weapStates[i] = (char const*)swstates["weapStates" + to_string(i)]; + std::string key("weapStates" + to_string(i)); + weapStates[i] = (char const*)swstates[key.c_str()]; } const libconfig::Setting &sknames = texts["keyNames"]; for(int i = 1; i < 177; ++i) // First key starts at 1 { - keyNames[i] = (char const*)sknames["keyNames" + to_string(i)]; + std::string key("keyNames" + to_string(i)); + keyNames[i] = (char const*)sknames[key.c_str()]; } selWeap = (char const*)texts["selWeap"]; @@ -315,8 +318,10 @@ void Common::loadPaletteFromCFG(std::string cfgFilePath) const libconfig::Setting &scanim = palette["colorAnim"]; for(int i = 0; i < 4; ++i) { - colorAnim[i].from = (int)scanim["colorAnim" + to_string(i) + "from"]; - colorAnim[i].to = (int)scanim["colorAnim" + to_string(i) + "to"]; + std::string key("colorAnim" + to_string(i) + "from"); + colorAnim[i].from = (int)scanim[key.c_str()]; + key = "colorAnim" + to_string(i) + "to"; + colorAnim[i].to = (int)scanim[key.c_str()]; } } @@ -383,7 +388,8 @@ void Common::loadMaterialsFromCFG(std::string cfgFilePath) for(int i = 0; i < 256; ++i) { - const libconfig::Setting &smflags = smaterials["flags" + to_string(i)]; + std::string key("flags" + to_string(i)); + const libconfig::Setting &smflags = smaterials[key.c_str()]; materials[i].flags = smflags; } } diff --git a/src/configCompat.cpp b/src/configCompat.cpp index 1aeb262..a72c40f 100644 --- a/src/configCompat.cpp +++ b/src/configCompat.cpp @@ -160,19 +160,19 @@ void Common::loadConstantsFromCFGVer0(string cfgFilePath) const Setting &vconstants = constants["Values"]; for(int i = 0; i < MaxC; ++i) { - C[i] = (int)vconstants[valueConstantsNamesCFGVer0[i]]; + C[i] = (int)vconstants[valueConstantsNamesCFGVer0[i].c_str()]; } const Setting &sconstants = constants["Strings"]; for(int i = 0; i < MaxS; ++i) { - S[i]= (char const*)sconstants[stringConstantsNamesCFGVer0[i]]; + S[i]= (char const*)sconstants[stringConstantsNamesCFGVer0[i].c_str()]; } const Setting &hconstants = constants["Hacks"]; for(int i = 0; i < MaxH; ++i) { - H[i] = (bool)hconstants[hackConstantsNamesVer0[i]]; + H[i] = (bool)hconstants[hackConstantsNamesVer0[i].c_str()]; } } diff --git a/src/configHelper.cpp b/src/configHelper.cpp index fcd1f3f..6d9244e 100644 --- a/src/configHelper.cpp +++ b/src/configHelper.cpp @@ -54,14 +54,12 @@ template Uint8 ConfigHelper::getValue<Uint8, const Setting, int>(const Setting & template Uint8 ConfigHelper::getValue<Uint8, const Setting, char const*>(const Setting &node, char const* index); -template Uint8 ConfigHelper::getValue<Uint8, const Setting, string>(const Setting &node, string index); // Non-const template Uint8 ConfigHelper::getValue<Uint8, Setting, int>(Setting &node, int index); template Uint8 ConfigHelper::getValue<Uint8, Setting, char const*>(Setting &node, char const* index); -template Uint8 ConfigHelper::getValue<Uint8, Setting, string>(Setting &node, string index); // Since we still need specialisation per value type (Setting::Type), @@ -72,7 +70,7 @@ void ConfigHelper::put(Setting &node, string variable, string value) { node.add(variable, Setting::TypeString) = value; } else { - Setting &var = node[variable]; + Setting &var = node[variable.c_str()]; var = value; } } @@ -83,7 +81,7 @@ void ConfigHelper::put(Setting &node, string variable, int value) { node.add(variable, Setting::TypeInt) = value; } else { - Setting &var = node[variable]; + Setting &var = node[variable.c_str()]; var = value; } } @@ -94,7 +92,7 @@ void ConfigHelper::put(Setting &node, string variable, Uint8 value) { node.add(variable, Setting::TypeInt) = value; } else { - Setting &var = node[variable]; + Setting &var = node[variable.c_str()]; var = value; } } @@ -105,7 +103,7 @@ void ConfigHelper::put(Setting &node, string variable, bool value) { node.add(variable, Setting::TypeBoolean) = value; } else { - Setting &var = node[variable]; + Setting &var = node[variable.c_str()]; var = value; } } @@ -135,6 +133,6 @@ Setting& ConfigHelper::getSubgroup(Setting &node, string groupName) { node.add(groupName, Setting::TypeGroup); } - return node[groupName]; + return node[groupName.c_str()]; } diff --git a/src/constants.cpp b/src/constants.cpp index 7fced6a..cf7bbfc 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -523,19 +523,19 @@ void Common::loadConstantsFromCFG(std::string cfgFilePath) const libconfig::Setting &vconstants = constants["Values"]; for(int i = 0; i < MaxC; ++i) { - C[i] = (int)vconstants[valueConstantsNames[i]]; + C[i] = (int)vconstants[valueConstantsNames[i].c_str()]; } const libconfig::Setting &sconstants = constants["Strings"]; for(int i = 0; i < MaxS; ++i) { - S[i]= (char const*)sconstants[stringConstantsNames[i]]; + S[i]= (char const*)sconstants[stringConstantsNames[i].c_str()]; } const libconfig::Setting &hconstants = constants["Hacks"]; for(int i = 0; i < MaxH; ++i) { - H[i] = (bool)hconstants[hackConstantsNames[i]]; + H[i] = (bool)hconstants[hackConstantsNames[i].c_str()]; } } diff --git a/src/gfx/palette.cpp b/src/gfx/palette.cpp index 3fd08c4..cde0267 100644 --- a/src/gfx/palette.cpp +++ b/src/gfx/palette.cpp @@ -124,9 +124,12 @@ void Palette::readFromCFG(std::string cfgFilePath) for(int i = 0; i < 256; ++i) { - entries[i].r = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "r"); - entries[i].g = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "g"); - entries[i].b = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "b"); + std::string idx("entries" + to_string(i) + "r"); + entries[i].r = cfgHelp.getValue<Uint8>(spentries, idx.c_str()); + idx = "entries" + to_string(i) + "g"; + entries[i].g = cfgHelp.getValue<Uint8>(spentries, idx.c_str()); + idx = "entries" + to_string(i) + "b"; + entries[i].b = cfgHelp.getValue<Uint8>(spentries, idx.c_str()); } }

