Last active
August 9, 2019 18:40
-
-
Save j-rivero/bc563620802d78129d775b2d5aee69ac to your computer and use it in GitHub Desktop.
urdfdom-headers debdiff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Nru urdfdom-headers-1.0.0/debian/changelog urdfdom-headers-1.0.0/debian/changelog | |
--- urdfdom-headers-1.0.0/debian/changelog 2016-07-23 00:38:00.000000000 +0000 | |
+++ urdfdom-headers-1.0.0/debian/changelog 2019-08-08 17:49:30.000000000 +0000 | |
@@ -1,3 +1,9 @@ | |
+urdfdom-headers (1.0.0-1ubuntu1) bionic; urgency=medium | |
+ | |
+ * Patch to avoid truncating problems on non english locale systems | |
+ | |
+ -- Jose Luis Rivero <jrivero@osrfoundation.org> Thu, 08 Aug 2019 17:49:30 +0000 | |
+ | |
urdfdom-headers (1.0.0-1) unstable; urgency=medium | |
* Cherry pick patch for current version to fix problem in upstream code | |
diff -Nru urdfdom-headers-1.0.0/debian/patches/avoid_truncating_floating_values.patch urdfdom-headers-1.0.0/debian/patches/avoid_truncating_floating_values.patch | |
--- urdfdom-headers-1.0.0/debian/patches/avoid_truncating_floating_values.patch 1970-01-01 00:00:00.000000000 +0000 | |
+++ urdfdom-headers-1.0.0/debian/patches/avoid_truncating_floating_values.patch 2019-08-08 17:49:30.000000000 +0000 | |
@@ -0,0 +1,94 @@ | |
+Description: use helper function strToDouble for locale independent | |
+Author: Simon Schmeisser <simon.schmeisser@isys-vision.de> | |
+Author: Chris Lalancette <clalancette@gmail.com> | |
+Upstream: https://github.com/ros/urdfdom_headers/commit/e7e0972a4617b8a5df7a274ea3ba3b92e3895a35.patch | |
+Upstream: https://github.com/ros/urdfdom_headers/commit/f97cbceba9827629c6f010554513219a828d9592.patch | |
+ | |
+Use stringstream instead of stod to work around locale issues. | |
+ | |
+diff --git a/urdf_model/include/urdf_model/color.h b/urdf_model/include/urdf_model/color.h | |
+index 505d9a6..46915a5 100644 | |
+--- a/urdf_model/include/urdf_model/color.h | |
++++ b/urdf_model/include/urdf_model/color.h | |
+@@ -73,13 +73,10 @@ class Color | |
+ { | |
+ try | |
+ { | |
+- rgba.push_back(std::stof(pieces[i])); | |
++ rgba.push_back(strToDouble(pieces[i].c_str())); | |
+ } | |
+- catch (std::invalid_argument &/*e*/) { | |
+- return false; | |
+- } | |
+- catch (std::out_of_range &/*e*/) { | |
+- return false; | |
++ catch (std::runtime_error &/*e*/) { | |
++ throw ParseError("Unable to parse component [" + pieces[i] + "] to a double (while parsing a color value)"); | |
+ } | |
+ } | |
+ } | |
+ | |
+diff --git a/urdf_model/include/urdf_model/pose.h b/urdf_model/include/urdf_model/pose.h | |
+index 90e74a8..da65b53 100644 | |
+--- a/urdf_model/include/urdf_model/pose.h | |
++++ b/urdf_model/include/urdf_model/pose.h | |
+@@ -67,14 +67,10 @@ class Vector3 | |
+ for (unsigned int i = 0; i < pieces.size(); ++i){ | |
+ if (pieces[i] != ""){ | |
+ try { | |
+- xyz.push_back(std::stod(pieces[i])); | |
+- } | |
+- catch (std::invalid_argument &/*e*/) { | |
++ xyz.push_back(strToDouble(pieces[i].c_str())); | |
++ } catch(std::runtime_error &) { | |
+ throw ParseError("Unable to parse component [" + pieces[i] + "] to a double (while parsing a vector value)"); | |
+ } | |
+- catch (std::out_of_range &/*e*/) { | |
+- throw ParseError("Unable to parse component [" + pieces[i] + "] to a double, out of range (while parsing a vector value)"); | |
+- } | |
+ } | |
+ } | |
+ | |
+diff --git a/urdf_model/include/urdf_model/utils.h b/urdf_model/include/urdf_model/utils.h | |
+index e295496..f9f59c1 100644 | |
+--- a/urdf_model/include/urdf_model/utils.h | |
++++ b/urdf_model/include/urdf_model/utils.h | |
+@@ -37,6 +37,9 @@ | |
+ #ifndef URDF_INTERFACE_UTILS_H | |
+ #define URDF_INTERFACE_UTILS_H | |
+ | |
++#include <locale> | |
++#include <sstream> | |
++#include <stdexcept> | |
+ #include <string> | |
+ #include <vector> | |
+ | |
+@@ -62,6 +65,28 @@ void split_string(std::vector<std::string> &result, | |
+ } | |
+ } | |
+ | |
++// This is a locale-safe version of string-to-double, which is suprisingly | |
++// difficult to do correctly. This function ensures that the C locale is used | |
++// for parsing, as that matches up with what the XSD for double specifies. | |
++// On success, the double is returned; on failure, a std::runtime_error is | |
++// thrown. | |
++static inline double strToDouble(const char *in) | |
++{ | |
++ std::stringstream ss; | |
++ ss.imbue(std::locale::classic()); | |
++ | |
++ ss << in; | |
++ | |
++ double out; | |
++ ss >> out; | |
++ | |
++ if (ss.fail() || !ss.eof()) { | |
++ throw std::runtime_error("Failed converting string to double"); | |
++ } | |
++ | |
++ return out; | |
++} | |
++ | |
+ } | |
+ | |
+ #endif | |
diff -Nru urdfdom-headers-1.0.0/debian/patches/series urdfdom-headers-1.0.0/debian/patches/series | |
--- urdfdom-headers-1.0.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 | |
+++ urdfdom-headers-1.0.0/debian/patches/series 2019-08-08 17:49:30.000000000 +0000 | |
@@ -0,0 +1 @@ | |
+avoid_truncating_floating_values.patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment