[libosmium] 01/01: New upstream version 2.11.4

Bas Couwenberg sebastic at debian.org
Sat Aug 26 15:34:25 UTC 2017


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

sebastic pushed a commit to branch upstream-2.11
in repository libosmium.

commit 28b188529037bbb532be42b03feb1e1cc5746fac
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Aug 26 15:04:15 2017 +0200

    New upstream version 2.11.4
---
 CHANGELOG.md                    |  8 ++++++++
 CMakeLists.txt                  |  2 +-
 include/osmium/memory/item.hpp  |  3 ++-
 include/osmium/osm/location.hpp |  7 +++++++
 include/osmium/version.hpp      |  4 ++--
 test/t/osm/test_location.cpp    | 16 ++++++++++++++++
 6 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc1fdcc..808a8b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 ### Fixed
 
+## [2.11.4] - 2017-08-15
+
+### Fixed
+
+- Output coordinate with value of -2^31 correctly.
+- Buffers larger than 2^32 bytes do now work.
+
+
 ## [2.11.3] - 2017-05-03
 
 ### Fixed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e536c34..0d31969 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ project(libosmium)
 
 set(LIBOSMIUM_VERSION_MAJOR 2)
 set(LIBOSMIUM_VERSION_MINOR 11)
-set(LIBOSMIUM_VERSION_PATCH 3)
+set(LIBOSMIUM_VERSION_PATCH 4)
 
 set(LIBOSMIUM_VERSION
     "${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
diff --git a/include/osmium/memory/item.hpp b/include/osmium/memory/item.hpp
index 6714ce2..a03e057 100644
--- a/include/osmium/memory/item.hpp
+++ b/include/osmium/memory/item.hpp
@@ -62,7 +62,8 @@ namespace osmium {
         constexpr const item_size_type align_bytes = 8;
 
         inline constexpr std::size_t padded_length(std::size_t length) noexcept {
-            return (length + align_bytes - 1) & ~(align_bytes - 1);
+            return (length + static_cast<std::size_t>(align_bytes) - 1) &
+                   ~(static_cast<std::size_t>(align_bytes) - 1);
         }
 
         /**
diff --git a/include/osmium/osm/location.hpp b/include/osmium/osm/location.hpp
index b2fdc1b..0d5e0e3 100644
--- a/include/osmium/osm/location.hpp
+++ b/include/osmium/osm/location.hpp
@@ -33,6 +33,7 @@ DEALINGS IN THE SOFTWARE.
 
 */
 
+#include <algorithm>
 #include <cmath>
 #include <cstdint>
 #include <cstring>
@@ -198,6 +199,12 @@ namespace osmium {
         // Convert integer as used by location for coordinates into a string.
         template <typename T>
         inline T append_location_coordinate_to_string(T iterator, int32_t value) {
+            // need to special-case this, because later `value = -value` would overflow.
+            if (value == std::numeric_limits<int32_t>::min()) {
+                static const char minresult[] = "-214.7483648";
+                return std::copy_n(minresult, sizeof(minresult) - 1, iterator);
+            }
+
             // handle negative values
             if (value < 0) {
                 *iterator++ = '-';
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index a36a4d9..0a4e5a1 100644
--- a/include/osmium/version.hpp
+++ b/include/osmium/version.hpp
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
 
 #define LIBOSMIUM_VERSION_MAJOR 2
 #define LIBOSMIUM_VERSION_MINOR 11
-#define LIBOSMIUM_VERSION_PATCH 3
+#define LIBOSMIUM_VERSION_PATCH 4
 
-#define LIBOSMIUM_VERSION_STRING "2.11.3"
+#define LIBOSMIUM_VERSION_STRING "2.11.4"
 
 #endif // OSMIUM_VERSION_HPP
diff --git a/test/t/osm/test_location.cpp b/test/t/osm/test_location.cpp
index 6aba91d..9331950 100644
--- a/test/t/osm/test_location.cpp
+++ b/test/t/osm/test_location.cpp
@@ -260,6 +260,7 @@ TEST_CASE("Parsing coordinates from strings") {
     C("179.9999999",  1799999999);
     C("179.99999999", 1800000000);
     C("200.123",      2001230000);
+    C("214.7483647",  2147483647);
 
     C("8.109E-4" , 8109);
     C("8.1090E-4" , 8109);
@@ -332,6 +333,12 @@ TEST_CASE("Parsing coordinates from strings") {
     C("1.1e2:", 1100000000, ":");
 }
 
+TEST_CASE("Parsing min coordinate from string") {
+    const char* minval = "-214.7483648";
+    const char** data = &minval;
+    REQUIRE(osmium::detail::string_to_location_coordinate(data) == -2147483648l);
+}
+
 TEST_CASE("Writing zero coordinate into string") {
     std::string buffer;
     osmium::detail::append_location_coordinate_to_string(std::back_inserter(buffer), 0);
@@ -369,6 +376,15 @@ TEST_CASE("Writing coordinate into string") {
     CW(  40101010, "4.010101");
     CW( 494561234, "49.4561234");
     CW(1799999999, "179.9999999");
+
+    CW(2147483647, "214.7483647");
+}
+
+TEST_CASE("Writing min coordinate into string") {
+    std::string buffer;
+
+    osmium::detail::append_location_coordinate_to_string(std::back_inserter(buffer), -2147483648l);
+    REQUIRE(buffer == "-214.7483648");
 }
 
 TEST_CASE("set lon/lat from string") {

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



More information about the Pkg-grass-devel mailing list