[lierolibre] 01/04: Add upstream patch to fix string conversion

Martin Werner arand-guest at moszumanska.debian.org
Tue Aug 18 21:41:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

arand-guest pushed a commit to branch master
in repository lierolibre.

commit 5974d5113c5d04329124322fd6760c611297c2c4
Author: Martin Erik Werner <martinerikwerner at gmail.com>
Date:   Mon Aug 17 16:26:01 2015 +0200

    Add upstream patch to fix string conversion
---
 debian/changelog                                   |   8 +-
 ...ix-conversion-of-basic-string-to-c-string.patch | 226 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 234 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 74300cf..9e53814 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,14 @@
 lierolibre (0.5-2) UNRELEASED; urgency=low
 
+  [ Christoph Egger ]
   * Handle hurd/kfreebsd as linux. Fixes build there
 
- -- Christoph Egger <christoph at debian.org>  Mon, 10 Dec 2012 15:44:17 -0800
+  [ Martin Erik Werner ]
+  * Add upstream patch to fix string conversion with new libstdc++6 cxx11 and
+    libconfig++9v5
+    - debian/patches/fix-conversion-of-basic-string-to-c-string.patch
+
+ -- Martin Erik Werner <martinerikwerner at gmail.com>  Mon, 17 Aug 2015 16:27:12 +0200
 
 lierolibre (0.5-1) unstable; urgency=low
 
diff --git a/debian/patches/fix-conversion-of-basic-string-to-c-string.patch b/debian/patches/fix-conversion-of-basic-string-to-c-string.patch
new file mode 100644
index 0000000..21cc5b8
--- /dev/null
+++ b/debian/patches/fix-conversion-of-basic-string-to-c-string.patch
@@ -0,0 +1,226 @@
+From b9cc6f96a13e24bc219b9f493792f6de44fd206b Mon Sep 17 00:00:00 2001
+From: Martin Erik Werner <martinerikwerner at gmail.com>
+Date: Mon, 17 Aug 2015 15:54:53 +0200
+Subject: [PATCH] Fix conversion of basic string to c string
+
+An ABI bump in libstdc++6 presumably made it so that
+operator[](const char*) does not accept std::__cxx11::basic_string<char>
+as an argument, so solve this by explicitly converting the result via
+c_str() everywhere.
+
+This also required some odd messing with templates in order to
+specialise them for the conversion.
+---
+ src/common.cpp       | 12 ++++++------
+ src/configCompat.cpp |  6 +++---
+ src/configHelper.cpp | 36 ++++++++++++++++++++++++++++--------
+ src/configHelper.hpp |  2 ++
+ src/constants.cpp    |  6 +++---
+ 5 files changed, 42 insertions(+), 20 deletions(-)
+
+diff --git a/src/common.cpp b/src/common.cpp
+index 2d6ada5..4942b05 100644
+--- a/src/common.cpp
++++ b/src/common.cpp
+@@ -162,7 +162,7 @@ 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)];
++		gameModes[i] = (char const*)sgmodes[("gameModes" + to_string(i)).c_str()];
+ 	}
+ 
+ 	const libconfig::Setting &sgmspec = texts["gameModeSpec"];
+@@ -181,13 +181,13 @@ 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)];
++		 weapStates[i] = (char const*)swstates[("weapStates" + to_string(i)).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)];
++		keyNames[i] = (char const*)sknames[("keyNames" + to_string(i)).c_str()];
+ 	}
+ 
+ 	selWeap = (char const*)texts["selWeap"];
+@@ -315,8 +315,8 @@ 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"];
++		colorAnim[i].from = (int)scanim[("colorAnim" + to_string(i) + "from").c_str()];
++		colorAnim[i].to = (int)scanim[("colorAnim" + to_string(i) + "to").c_str()];
+ 	}
+ }
+ 
+@@ -383,7 +383,7 @@ void Common::loadMaterialsFromCFG(std::string cfgFilePath)
+ 
+ 	for(int i = 0; i < 256; ++i)
+ 	{
+-		const libconfig::Setting &smflags = smaterials["flags" + to_string(i)];
++		const libconfig::Setting &smflags = smaterials[("flags" + to_string(i)).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..fd74f0c 100644
+--- a/src/configHelper.cpp
++++ b/src/configHelper.cpp
+@@ -54,15 +54,35 @@ 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);
++// This needs to be specific since string must be manually cast to const char*
++template<>
++Uint8 ConfigHelper::getValue(const Setting &node, string index)
++{
++	int value = node[index.c_str()];
++	if(value <= numeric_limits<Uint8>::max() && value >= numeric_limits<Uint8>::min())
++	{
++		return static_cast<Uint8>(value);
++	} else {
++		throw overflow_error("Config value is too big");
++	}
++}
+ 
++template<>
++Uint8 ConfigHelper::getValue(Setting &node, string index)
++{
++	int value = node[index.c_str()];
++	if(value <= numeric_limits<Uint8>::max() && value >= numeric_limits<Uint8>::min())
++	{
++		return static_cast<Uint8>(value);
++	} else {
++		throw overflow_error("Config value is too big");
++	}
++}
+ 
+ // Since we still need specialisation per value type (Setting::Type),
+ // no need to templateify these
+@@ -72,7 +92,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 +103,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 +114,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 +125,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 +155,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/configHelper.hpp b/src/configHelper.hpp
+index 6c4ba33..b7bd343 100644
+--- a/src/configHelper.hpp
++++ b/src/configHelper.hpp
+@@ -37,6 +37,8 @@ class ConfigHelper
+ public:
+ 	void putVersion(libconfig::Setting &node, int version);
+ 
++	unsigned char getValue(const libconfig::Setting &node, std::string index);
++	unsigned char getValue(libconfig::Setting &node, std::string index);
+ 	template<typename Dest, typename Node, typename Idx>
+ 	Dest getValue(Node &node, Idx index);
+ 
+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()];
+ 	}
+ }
+ 
+-- 
+2.4.6
+
diff --git a/debian/patches/series b/debian/patches/series
index 26238c9..7d86c47 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 kfreebsd.patch
+fix-conversion-of-basic-string-to-c-string.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/lierolibre.git



More information about the Pkg-games-commits mailing list