[libosmium] 02/05: Imported Upstream version 2.11.1

Bas Couwenberg sebastic at debian.org
Tue Mar 7 18:01:38 UTC 2017


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

sebastic pushed a commit to branch master
in repository libosmium.

commit 03ce3d9907abe26669a8b18f4d1bfe4878059fb7
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Mar 7 18:26:02 2017 +0100

    Imported Upstream version 2.11.1
---
 CHANGELOG.md                                  | 14 +++++++++++---
 CMakeLists.txt                                |  2 +-
 include/osmium/builder/builder.hpp            | 18 +++++++++++++++++-
 include/osmium/builder/osm_object_builder.hpp | 20 +++++++++++---------
 include/osmium/io/reader.hpp                  |  8 +++++---
 include/osmium/tags/filter.hpp                |  2 +-
 include/osmium/version.hpp                    |  4 ++--
 test/CMakeLists.txt                           |  1 +
 test/t/io/test_reader_fileformat.cpp          | 10 ++++++++++
 9 files changed, 59 insertions(+), 20 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d12bb76..5aab3f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,12 +6,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 ## [unreleased] -
 
-### Added
+### Fixed
 
-### Changed
+
+## [2.11.1] - 2017-03-07
 
 ### Fixed
 
+- Terminate called on full non-auto-growing buffer. (Issue #189.)
+- When file formats were used that were not compiled into the binary, it
+  terminated instead of throwing. (Issue #197.)
+- The `Filter::count()` method didn't compile at all.
+
 
 ## [2.11.0] - 2017-01-14
 
@@ -525,7 +531,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
   Doxygen (up to version 1.8.8). This version contains a workaround to fix
   this.
 
-[unreleased]: https://github.com/osmcode/libosmium/compare/v2.10.3...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v2.11.1...HEAD
+[2.11.1]: https://github.com/osmcode/libosmium/compare/v2.11.0...v2.11.1
+[2.11.0]: https://github.com/osmcode/libosmium/compare/v2.10.3...v2.11.0
 [2.10.3]: https://github.com/osmcode/libosmium/compare/v2.10.2...v2.10.3
 [2.10.2]: https://github.com/osmcode/libosmium/compare/v2.10.1...v2.10.2
 [2.10.1]: https://github.com/osmcode/libosmium/compare/v2.10.0...v2.10.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21478ec..372a2a4 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 0)
+set(LIBOSMIUM_VERSION_PATCH 1)
 
 set(LIBOSMIUM_VERSION
     "${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
diff --git a/include/osmium/builder/builder.hpp b/include/osmium/builder/builder.hpp
index 107f4a9..d435884 100644
--- a/include/osmium/builder/builder.hpp
+++ b/include/osmium/builder/builder.hpp
@@ -168,6 +168,20 @@ namespace osmium {
             }
 
             /**
+             * Append data to buffer and append an additional \0.
+             *
+             * @param data Pointer to data.
+             * @param length Length of data in bytes.
+             * @returns The number of bytes appended (length + 1).
+             */
+            osmium::memory::item_size_type append_with_zero(const char* data, const osmium::memory::item_size_type length) {
+                unsigned char* target = reserve_space(length + 1);
+                std::copy_n(reinterpret_cast<const unsigned char*>(data), length, target);
+                target[length] = '\0';
+                return length + 1;
+            }
+
+            /**
              * Append \0-terminated string to buffer.
              *
              * @param str \0-terminated string.
@@ -180,9 +194,11 @@ namespace osmium {
             /**
              * Append '\0' to the buffer.
              *
+             * @deprecated Use append_with_zero() instead.
+             *
              * @returns The number of bytes appended (always 1).
              */
-            osmium::memory::item_size_type append_zero() {
+            OSMIUM_DEPRECATED osmium::memory::item_size_type append_zero() {
                 *reserve_space(1) = '\0';
                 return 1;
             }
diff --git a/include/osmium/builder/osm_object_builder.hpp b/include/osmium/builder/osm_object_builder.hpp
index 1dd5f97..d4483b1 100644
--- a/include/osmium/builder/osm_object_builder.hpp
+++ b/include/osmium/builder/osm_object_builder.hpp
@@ -99,7 +99,8 @@ namespace osmium {
                 if (std::strlen(value) > osmium::max_osm_string_length) {
                     throw std::length_error("OSM tag value is too long");
                 }
-                add_size(append(key) + append(value));
+                add_size(append(key));
+                add_size(append(value));
             }
 
             /**
@@ -117,8 +118,8 @@ namespace osmium {
                 if (value_length > osmium::max_osm_string_length) {
                     throw std::length_error("OSM tag value is too long");
                 }
-                add_size(append(key,   osmium::memory::item_size_type(key_length))   + append_zero() +
-                         append(value, osmium::memory::item_size_type(value_length)) + append_zero());
+                add_size(append_with_zero(key,   osmium::memory::item_size_type(key_length)));
+                add_size(append_with_zero(value, osmium::memory::item_size_type(value_length)));
             }
 
             /**
@@ -134,8 +135,8 @@ namespace osmium {
                 if (value.size() > osmium::max_osm_string_length) {
                     throw std::length_error("OSM tag value is too long");
                 }
-                add_size(append(key.data(),   osmium::memory::item_size_type(key.size())   + 1) +
-                         append(value.data(), osmium::memory::item_size_type(value.size()) + 1));
+                add_size(append(key.data(),   osmium::memory::item_size_type(key.size())   + 1));
+                add_size(append(value.data(), osmium::memory::item_size_type(value.size()) + 1));
             }
 
             /**
@@ -144,7 +145,8 @@ namespace osmium {
              * @param tag Tag.
              */
             void add_tag(const osmium::Tag& tag) {
-                add_size(append(tag.key()) + append(tag.value()));
+                add_size(append(tag.key()));
+                add_size(append(tag.value()));
             }
 
             /**
@@ -226,7 +228,7 @@ namespace osmium {
                     throw std::length_error("OSM relation member role is too long");
                 }
                 member.set_role_size(osmium::string_size_type(length) + 1);
-                add_size(append(role, osmium::memory::item_size_type(length)) + append_zero());
+                add_size(append_with_zero(role, osmium::memory::item_size_type(length)));
                 add_padding(true);
             }
 
@@ -310,7 +312,7 @@ namespace osmium {
                     throw std::length_error("OSM user name is too long");
                 }
                 comment.set_user_size(osmium::string_size_type(length) + 1);
-                add_size(append(user, osmium::memory::item_size_type(length)) + append_zero());
+                add_size(append_with_zero(user, osmium::memory::item_size_type(length)));
             }
 
             void add_text(osmium::ChangesetComment& comment, const char* text, const size_t length) {
@@ -322,7 +324,7 @@ namespace osmium {
                     throw std::length_error("OSM changeset comment is too long");
                 }
                 comment.set_text_size(osmium::string_size_type(length) + 1);
-                add_size(append(text, osmium::memory::item_size_type(length)) + append_zero());
+                add_size(append_with_zero(text, osmium::memory::item_size_type(length)));
                 add_padding(true);
             }
 
diff --git a/include/osmium/io/reader.hpp b/include/osmium/io/reader.hpp
index c39eaaa..825cb41 100644
--- a/include/osmium/io/reader.hpp
+++ b/include/osmium/io/reader.hpp
@@ -92,6 +92,8 @@ namespace osmium {
 
             osmium::io::File m_file;
 
+            detail::ParserFactory::create_parser_type m_creator;
+
             enum class status {
                 okay   = 0, // normal reading
                 error  = 1, // some error occurred while reading
@@ -128,13 +130,12 @@ namespace osmium {
             }
 
             // This function will run in a separate thread.
-            static void parser_thread(const osmium::io::File& file,
+            static void parser_thread(const detail::ParserFactory::create_parser_type& creator,
                                       detail::future_string_queue_type& input_queue,
                                       detail::future_buffer_queue_type& osmdata_queue,
                                       std::promise<osmium::io::Header>&& header_promise,
                                       osmium::io::detail::reader_options options) {
                 std::promise<osmium::io::Header> promise = std::move(header_promise);
-                const auto creator = detail::ParserFactory::instance().get_creator_function(file);
                 const auto parser = creator(input_queue, osmdata_queue, promise, options);
                 parser->parse();
             }
@@ -236,6 +237,7 @@ namespace osmium {
             template <typename... TArgs>
             explicit Reader(const osmium::io::File& file, TArgs&&... args) :
                 m_file(file.check()),
+                m_creator(detail::ParserFactory::instance().get_creator_function(m_file)),
                 m_status(status::okay),
                 m_childpid(0),
                 m_input_queue(detail::get_input_queue_size(), "raw_input"),
@@ -256,7 +258,7 @@ namespace osmium {
 
                 std::promise<osmium::io::Header> header_promise;
                 m_header_future = header_promise.get_future();
-                m_thread = osmium::thread::thread_handler{parser_thread, std::ref(m_file), std::ref(m_input_queue), std::ref(m_osmdata_queue), std::move(header_promise), m_options};
+                m_thread = osmium::thread::thread_handler{parser_thread, std::ref(m_creator), std::ref(m_input_queue), std::ref(m_osmdata_queue), std::move(header_promise), m_options};
             }
 
             template <typename... TArgs>
diff --git a/include/osmium/tags/filter.hpp b/include/osmium/tags/filter.hpp
index 22abb14..797565d 100644
--- a/include/osmium/tags/filter.hpp
+++ b/include/osmium/tags/filter.hpp
@@ -140,7 +140,7 @@ namespace osmium {
              * Return the number of rules in this filter.
              */
             size_t count() const {
-                return m_rules.count();
+                return m_rules.size();
             }
 
             /**
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index d32641a..1bda080 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 0
+#define LIBOSMIUM_VERSION_PATCH 1
 
-#define LIBOSMIUM_VERSION_STRING "2.11.0"
+#define LIBOSMIUM_VERSION_STRING "2.11.1"
 
 #endif // OSMIUM_VERSION_HPP
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index db0e934..61376e7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -167,6 +167,7 @@ add_unit_test(io test_compression_factory)
 add_unit_test(io test_bzip2 ENABLE_IF ${BZIP2_FOUND} LIBS ${BZIP2_LIBRARIES})
 add_unit_test(io test_file_formats)
 add_unit_test(io test_reader LIBS "${OSMIUM_XML_LIBRARIES};${OSMIUM_PBF_LIBRARIES}")
+add_unit_test(io test_reader_fileformat ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
 add_unit_test(io test_reader_with_mock_decompression ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
 add_unit_test(io test_reader_with_mock_parser ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
 add_unit_test(io test_opl_parser)
diff --git a/test/t/io/test_reader_fileformat.cpp b/test/t/io/test_reader_fileformat.cpp
new file mode 100644
index 0000000..a64932e
--- /dev/null
+++ b/test/t/io/test_reader_fileformat.cpp
@@ -0,0 +1,10 @@
+
+#include "catch.hpp"
+#include "utils.hpp"
+
+#include <osmium/io/reader.hpp>
+
+TEST_CASE("Reader throws on unsupported file format") {
+    REQUIRE_THROWS_AS(osmium::io::Reader{with_data_dir("t/io/data.osm")}, osmium::unsupported_file_format_error);
+}
+

-- 
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