[libosmium] 01/03: Add patches to fix timestamp test failures.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Sun Nov 29 21:31:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository libosmium.
commit 9b7a2be999a95d0cf033a15d9b03e4bf1d66a2df
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Thu Nov 19 22:04:18 2015 +0100
Add patches to fix timestamp test failures.
---
debian/changelog | 6 +
...ion-and-comparison-operators-to-Timestamp.patch | 239 +++++++++++++++++++++
...lizing-a-Timestamp-from-any-integral-type.patch | 48 +++++
debian/patches/series | 2 +
4 files changed, 295 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 26d8d57..741d62b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libosmium (2.5.3-1~exp2) UNRELEASED; urgency=medium
+
+ * Add patches to fix timestamp test failures.
+
+ -- Bas Couwenberg <sebastic at debian.org> Thu, 19 Nov 2015 22:03:50 +0100
+
libosmium (2.5.3-1~exp1) experimental; urgency=medium
* New upstream release.
diff --git a/debian/patches/0001-Add-conversion-and-comparison-operators-to-Timestamp.patch b/debian/patches/0001-Add-conversion-and-comparison-operators-to-Timestamp.patch
new file mode 100644
index 0000000..6f95ae1
--- /dev/null
+++ b/debian/patches/0001-Add-conversion-and-comparison-operators-to-Timestamp.patch
@@ -0,0 +1,239 @@
+From 39fe3a5b5bf5ac2cebb4048f0c7aecd3a9d3c8be Mon Sep 17 00:00:00 2001
+From: Jochen Topf <jochen at topf.org>
+Date: Mon, 23 Nov 2015 23:43:20 +0100
+Subject: [PATCH] Add conversion and comparison operators to Timestamp.
+Origin: https://github.com/osmcode/libosmium/commit/39fe3a5b5bf5ac2cebb4048f0c7aecd3a9d3c8be
+
+See 135.
+---
+ include/osmium/io/detail/pbf_output_format.hpp | 8 ++--
+ include/osmium/osm/timestamp.hpp | 52 ++++++++++++++++++++++----
+ test/t/basic/test_node.cpp | 4 +-
+ test/t/basic/test_relation.cpp | 2 +-
+ test/t/basic/test_timestamp.cpp | 10 ++---
+ test/t/basic/test_way.cpp | 2 +-
+ test/t/buffer/test_buffer_node.cpp | 6 +--
+ 7 files changed, 61 insertions(+), 23 deletions(-)
+
+--- a/include/osmium/io/detail/pbf_output_format.hpp
++++ b/include/osmium/io/detail/pbf_output_format.hpp
+@@ -224,7 +224,7 @@ namespace osmium {
+
+ osmium::util::DeltaEncode<object_id_type, int64_t> m_delta_id;
+
+- osmium::util::DeltaEncode<time_t, int64_t> m_delta_timestamp;
++ osmium::util::DeltaEncode<uint32_t, int64_t> m_delta_timestamp;
+ osmium::util::DeltaEncode<changeset_id_type, int64_t> m_delta_changeset;
+ osmium::util::DeltaEncode<user_id_type, int32_t> m_delta_uid;
+ osmium::util::DeltaEncode<uint32_t, int32_t> m_delta_user_sid;
+@@ -276,7 +276,7 @@ namespace osmium {
+
+ if (m_options.add_metadata) {
+ m_versions.push_back(static_cast_with_assert<int32_t>(node.version()));
+- m_timestamps.push_back(m_delta_timestamp.update(node.timestamp()));
++ m_timestamps.push_back(m_delta_timestamp.update(uint32_t(node.timestamp())));
+ m_changesets.push_back(m_delta_changeset.update(node.changeset()));
+ m_uids.push_back(m_delta_uid.update(node.uid()));
+ m_user_sids.push_back(m_delta_user_sid.update(m_stringtable.add(node.user())));
+@@ -462,7 +462,7 @@ namespace osmium {
+ protozero::pbf_builder<OSMFormat::Info> pbf_info(pbf_object, T::enum_type::optional_Info_info);
+
+ pbf_info.add_int32(OSMFormat::Info::optional_int32_version, static_cast_with_assert<int32_t>(object.version()));
+- pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, object.timestamp());
++ pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, uint32_t(object.timestamp()));
+ pbf_info.add_int64(OSMFormat::Info::optional_int64_changeset, object.changeset());
+ pbf_info.add_int32(OSMFormat::Info::optional_int32_uid, static_cast_with_assert<int32_t>(object.uid()));
+ pbf_info.add_uint32(OSMFormat::Info::optional_uint32_user_sid, m_primitive_block.store_in_stringtable(object.user()));
+@@ -526,7 +526,7 @@ namespace osmium {
+ std::string osmosis_replication_timestamp = header.get("osmosis_replication_timestamp");
+ if (!osmosis_replication_timestamp.empty()) {
+ osmium::Timestamp ts(osmosis_replication_timestamp.c_str());
+- pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp, ts);
++ pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp, uint32_t(ts));
+ }
+
+ std::string osmosis_replication_sequence_number = header.get("osmosis_replication_sequence_number");
+--- a/include/osmium/osm/timestamp.hpp
++++ b/include/osmium/osm/timestamp.hpp
+@@ -137,19 +137,33 @@ namespace osmium {
+ return m_timestamp != 0;
+ }
+
+- /// Explicit conversion into time_t.
+- constexpr time_t seconds_since_epoch() const noexcept {
+- return static_cast<time_t>(m_timestamp);
++ /// Explicit conversion into bool.
++ explicit constexpr operator bool() const noexcept {
++ return m_timestamp != 0;
+ }
+
+- /// Implicit conversion into time_t.
+- constexpr operator time_t() const noexcept {
+- return static_cast<time_t>(m_timestamp);
++ /// Explicit conversion into time_t.
++ constexpr time_t seconds_since_epoch() const noexcept {
++ return time_t(m_timestamp);
+ }
+
+ /// Explicit conversion into uint32_t.
+ explicit constexpr operator uint32_t() const noexcept {
+- return m_timestamp;
++ return uint32_t(m_timestamp);
++ }
++
++ /// Explicit conversion into uint64_t.
++ explicit constexpr operator uint64_t() const noexcept {
++ return uint64_t(m_timestamp);
++ }
++
++ /**
++ * Implicit conversion into time_t.
++ *
++ * @deprecated You should call seconds_since_epoch() explicitly instead.
++ */
++ OSMIUM_DEPRECATED constexpr operator time_t() const noexcept {
++ return static_cast<time_t>(m_timestamp);
+ }
+
+ template <typename T>
+@@ -214,6 +228,30 @@ namespace osmium {
+ return out;
+ }
+
++ inline bool operator==(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return uint32_t(lhs) == uint32_t(rhs);
++ }
++
++ inline bool operator!=(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return !(lhs == rhs);
++ }
++
++ inline bool operator<(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return uint32_t(lhs) < uint32_t(rhs);
++ }
++
++ inline bool operator>(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return rhs < lhs;
++ }
++
++ inline bool operator<=(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return ! (rhs < lhs);
++ }
++
++ inline bool operator>=(const Timestamp& lhs, const Timestamp& rhs) noexcept {
++ return ! (lhs < rhs);
++ }
++
+ template <>
+ inline osmium::Timestamp min_op_start_value<osmium::Timestamp>() {
+ return end_of_time();
+--- a/test/t/basic/test_node.cpp
++++ b/test/t/basic/test_node.cpp
+@@ -37,7 +37,7 @@ SECTION("node_builder") {
+ REQUIRE(333 == node.changeset());
+ REQUIRE(21 == node.uid());
+ REQUIRE(std::string("foo") == node.user());
+- REQUIRE(123 == node.timestamp());
++ REQUIRE(123 == uint32_t(node.timestamp()));
+ REQUIRE(osmium::Location(3.5, 4.7) == node.location());
+ REQUIRE(2 == node.tags().size());
+
+@@ -61,7 +61,7 @@ SECTION("node_default_attributes") {
+ REQUIRE(0 == node.changeset());
+ REQUIRE(0 == node.uid());
+ REQUIRE(std::string("") == node.user());
+- REQUIRE(0 == node.timestamp());
++ REQUIRE(0 == uint32_t(node.timestamp()));
+ REQUIRE(osmium::Location() == node.location());
+ REQUIRE(0 == node.tags().size());
+ }
+--- a/test/t/basic/test_relation.cpp
++++ b/test/t/basic/test_relation.cpp
+@@ -36,7 +36,7 @@ TEST_CASE("Build relation") {
+ REQUIRE(333 == relation.changeset());
+ REQUIRE(21 == relation.uid());
+ REQUIRE(std::string("foo") == relation.user());
+- REQUIRE(123 == relation.timestamp());
++ REQUIRE(123 == uint32_t(relation.timestamp()));
+ REQUIRE(2 == relation.tags().size());
+ REQUIRE(3 == relation.members().size());
+
+--- a/test/t/basic/test_timestamp.cpp
++++ b/test/t/basic/test_timestamp.cpp
+@@ -8,21 +8,21 @@ TEST_CASE("Timestamp") {
+
+ SECTION("can be default initialized to invalid value") {
+ osmium::Timestamp t;
+- REQUIRE(0 == t);
++ REQUIRE(0 == uint32_t(t));
+ REQUIRE("" == t.to_iso());
+ REQUIRE_FALSE(t.valid());
+ }
+
+ SECTION("invalid value is zero") {
+ osmium::Timestamp t(static_cast<time_t>(0));
+- REQUIRE(0 == t);
++ REQUIRE(0 == uint32_t(t));
+ REQUIRE("" == t.to_iso());
+ REQUIRE_FALSE(t.valid());
+ }
+
+ SECTION("can be initialized from time_t") {
+ osmium::Timestamp t(static_cast<time_t>(1));
+- REQUIRE(1 == t);
++ REQUIRE(1 == uint32_t(t));
+ REQUIRE("1970-01-01T00:00:01Z" == t.to_iso());
+ REQUIRE(t.valid());
+ }
+@@ -44,9 +44,9 @@ TEST_CASE("Timestamp") {
+ REQUIRE_THROWS_AS(osmium::Timestamp("x"), std::invalid_argument);
+ }
+
+- SECTION("can be implicitly cast to time_t") {
++ SECTION("can be explicitly cast to time_t") {
+ osmium::Timestamp t(4242);
+- time_t x = t;
++ time_t x = t.seconds_since_epoch();
+ REQUIRE(x == 4242);
+ }
+
+--- a/test/t/basic/test_way.cpp
++++ b/test/t/basic/test_way.cpp
+@@ -36,7 +36,7 @@ SECTION("way_builder") {
+ REQUIRE(333 == way.changeset());
+ REQUIRE(21 == way.uid());
+ REQUIRE(std::string("foo") == way.user());
+- REQUIRE(123 == way.timestamp());
++ REQUIRE(123 == uint32_t(way.timestamp()));
+ REQUIRE(2 == way.tags().size());
+ REQUIRE(3 == way.nodes().size());
+ REQUIRE(1 == way.nodes()[0].ref());
+--- a/test/t/buffer/test_buffer_node.cpp
++++ b/test/t/buffer/test_buffer_node.cpp
+@@ -9,7 +9,7 @@ void check_node_1(osmium::Node& node) {
+ REQUIRE(true == node.visible());
+ REQUIRE(333 == node.changeset());
+ REQUIRE(21 == node.uid());
+- REQUIRE(123 == node.timestamp());
++ REQUIRE(123 == uint32_t(node.timestamp()));
+ REQUIRE(osmium::Location(3.5, 4.7) == node.location());
+ REQUIRE(std::string("testuser") == node.user());
+
+@@ -28,7 +28,7 @@ void check_node_2(osmium::Node& node) {
+ REQUIRE(true == node.visible());
+ REQUIRE(333 == node.changeset());
+ REQUIRE(21 == node.uid());
+- REQUIRE(123 == node.timestamp());
++ REQUIRE(123 == uint32_t(node.timestamp()));
+ REQUIRE(osmium::Location(3.5, 4.7) == node.location());
+ REQUIRE(std::string("testuser") == node.user());
+
+@@ -162,7 +162,7 @@ TEST_CASE("Node in Buffer") {
+ REQUIRE(buffer.committed() == buffer2.committed());
+ const osmium::Node& node = buffer2.get<osmium::Node>(0);
+ REQUIRE(node.id() == 1);
+- REQUIRE(node.timestamp() == 123);
++ REQUIRE(123 == uint32_t(node.timestamp()));
+ }
+
+ }
diff --git a/debian/patches/0001-Allow-initializing-a-Timestamp-from-any-integral-type.patch b/debian/patches/0001-Allow-initializing-a-Timestamp-from-any-integral-type.patch
new file mode 100644
index 0000000..3374997
--- /dev/null
+++ b/debian/patches/0001-Allow-initializing-a-Timestamp-from-any-integral-type.patch
@@ -0,0 +1,48 @@
+From 19508530adce7a58280ccf0e38c0519dcccd7521 Mon Sep 17 00:00:00 2001
+From: Jochen Topf <jochen at topf.org>
+Date: Thu, 19 Nov 2015 14:55:35 +0100
+Subject: Allow initializing a Timestamp from any integral type.
+Origin: https://github.com/osmcode/libosmium/commit/19508530adce7a58280ccf0e38c0519dcccd7521
+Bug: https://github.com/osmcode/libosmium/issues/135
+
+Fixes #135.
+---
+ include/osmium/osm/timestamp.hpp | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+--- a/include/osmium/osm/timestamp.hpp
++++ b/include/osmium/osm/timestamp.hpp
+@@ -47,7 +47,10 @@ namespace osmium {
+
+ /**
+ * A timestamp. Internal representation is an unsigned 32bit integer
+- * holding seconds since epoch, so this will overflow in 2038.
++ * holding seconds since epoch (1970-01-01T00:00:00Z), so this will
++ * overflow in 2106. We can use an unsigned integer here, because the
++ * OpenStreetMap project was started long after 1970, so there will
++ * never be dates before that.
+ */
+ class Timestamp {
+
+@@ -73,14 +76,17 @@ namespace osmium {
+ }
+
+ /**
+- * Construct a Timestamp from a time_t containing the seconds since
+- * the epoch.
++ * Construct a Timestamp from any integer type containing the seconds
++ * since the epoch. This will not check for overruns, you have to
++ * make sure the value fits into a uint32_t which is used internally
++ * in the Timestamp.
+ *
+ * The constructor is not declared "explicit" so that conversions
+ * like @code node.set_timestamp(123); @endcode work.
+ */
+- constexpr Timestamp(time_t timestamp) noexcept :
+- m_timestamp(static_cast<uint32_t>(timestamp)) {
++ template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
++ constexpr Timestamp(T timestamp) noexcept :
++ m_timestamp(uint32_t(timestamp)) {
+ }
+
+ /**
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..7a6ffdb
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+0001-Allow-initializing-a-Timestamp-from-any-integral-type.patch
+0001-Add-conversion-and-comparison-operators-to-Timestamp.patch
--
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