From 2a95a80845eaffbcb0dca68244c545b8ef274439 Mon Sep 17 00:00:00 2001 From: Andrei BENCSIK Date: Tue, 9 Apr 2024 22:35:59 +0300 Subject: [PATCH 1/8] testing the prs --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 900e4de..54863b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +this is an error + # Toggle integration tests option(INPUTOSM_INTEGRATION_TESTS "Build integration tests" ON) option(WARNINGS_AS_ERRORS "Treat warnings as errors" ON) From 0b0416b43e11e7288c6a080ad56d5707ab1c9722 Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Thu, 3 Oct 2024 16:55:16 +0300 Subject: [PATCH 2/8] Fix ASAN reported glitch (#16) --- src/inputosmpbf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inputosmpbf.cpp b/src/inputosmpbf.cpp index a3126dd..94a4e22 100644 --- a/src/inputosmpbf.cpp +++ b/src/inputosmpbf.cpp @@ -56,7 +56,7 @@ struct field_t struct string_table_t { - std::vector st_index; + std::vector st_index; std::vector st_buffer; void clear() From 458081e560cb56384732870e7fb22b6d70a0b072 Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Fri, 23 May 2025 21:08:03 +0300 Subject: [PATCH 3/8] Fix XML reader string management to avoid iterator/pointer invalidation (#17) --- src/inputosmxml.cpp | 59 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/src/inputosmxml.cpp b/src/inputosmxml.cpp index 4bcf546..4b54da4 100644 --- a/src/inputosmxml.cpp +++ b/src/inputosmxml.cpp @@ -46,9 +46,13 @@ enum class current_tag_t }; current_tag_t current_tag; std::vector current_strings; -std::vector current_tags; +std::vector> current_tags; std::vector current_refs; -std::vector current_members; +struct ext_relation_member_t : relation_member_t +{ + int role_index = -1; +}; +std::vector current_members; static void xml_start_node(const char **attr) { @@ -80,7 +84,14 @@ static void xml_end_node() { // node end current_tag = current_tag_t::none; - current_node.tags = {current_tags.data(), current_tags.size()}; + // assemble tags + std::vector tags; + for (auto i = 0; i < current_tags.size(); i++) + { + tags.emplace_back( + tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); + } + current_node.tags = {tags.data(), tags.size()}; if (parser_enabled && node_handler) parser_enabled = node_handler({¤t_node, 1}); current_tags.clear(); current_strings.clear(); @@ -104,7 +115,14 @@ static void xml_end_way() { // way end current_tag = current_tag_t::none; - current_way.tags = {current_tags.data(), current_tags.size()}; + // assemble tags + std::vector tags; + for (auto i = 0; i < current_tags.size(); i++) + { + tags.emplace_back( + tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); + } + current_way.tags = {tags.data(), tags.size()}; current_way.node_refs = {current_refs.data(), current_refs.size()}; if (parser_enabled && way_handler) parser_enabled = way_handler({¤t_way, 1}); current_tags.clear(); @@ -130,8 +148,22 @@ static void xml_end_relation() { // end relation current_tag = current_tag_t::none; - current_relation.tags = {current_tags.data(), current_tags.size()}; - current_relation.members = {current_members.data(), current_members.size()}; + // assemble tags + std::vector tags; + for (auto i = 0; i < current_tags.size(); i++) + { + tags.emplace_back( + tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); + } + current_relation.tags = {tags.data(), tags.size()}; + // assemble members + std::vector members; + for (const auto &m : current_members) + { + members.emplace_back( + relation_member_t{m.type, m.id, m.role_index >= 0 ? current_strings[m.role_index].c_str() : nullptr}); + } + current_relation.members = {members.data(), members.size()}; if (parser_enabled && relation_handler) parser_enabled = relation_handler({¤t_relation, 1}); current_tags.clear(); current_strings.clear(); @@ -150,7 +182,7 @@ static void xml_start_xtag(const char **attr) if (strcmp(attr[i], "v") == 0) current_strings.emplace_back(attr[i + 1]); } for (auto i = istart; i < current_strings.size(); i += 2) - current_tags.emplace_back(tag_t{current_strings[i].c_str(), current_strings[i + 1].c_str()}); + current_tags.emplace_back(std::pair{i, i + 1}); } } @@ -171,7 +203,7 @@ static void xml_start_member(const char **attr) // member start if (current_tag == current_tag_t::relation) { - relation_member_t member; + ext_relation_member_t member; for (int i = 0; attr[i]; i += 2) { if (strcmp(attr[i], "ref") == 0) member.id = atoll(attr[i + 1]); @@ -184,14 +216,19 @@ static void xml_start_member(const char **attr) if (strcmp(attr[i], "role") == 0) { current_strings.emplace_back(attr[i + 1]); - member.role = current_strings.back().c_str(); + member.role_index = current_strings.size() - 1; } } + if (member.role_index < 0) + { + current_strings.emplace_back(); + member.role_index = current_strings.size() - 1; + } current_members.emplace_back(member); } } -static void xml_start_tag(void */*data*/, const char *el, const char **attr) +static void xml_start_tag(void * /*data*/, const char *el, const char **attr) { // XML tag start if (strcmp(el, "node") == 0) xml_start_node(attr); @@ -207,7 +244,7 @@ static void xml_start_tag(void */*data*/, const char *el, const char **attr) if (strcmp(el, "delete") == 0) osc_mode = mode_t::destroy; } -static void xml_end_tag(void */*data*/, const char *el) +static void xml_end_tag(void * /*data*/, const char *el) { // XML tag end if (strcmp(el, "node") == 0) xml_end_node(); From 72cbfc7a68b644c52ec8af8fc96ee3011f872f0c Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Tue, 26 Aug 2025 23:44:16 +0300 Subject: [PATCH 4/8] Fix include (#18) * Update .gitignore to ignore /.cache * Add missing include for std::getenv usage --- .gitignore | 3 ++- src/inputosmlog.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ada7844..618fe20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ # artifacts build install +/.cache # ide .vscode -*.user \ No newline at end of file +*.user diff --git a/src/inputosmlog.cpp b/src/inputosmlog.cpp index 6378eea..ecaf337 100644 --- a/src/inputosmlog.cpp +++ b/src/inputosmlog.cpp @@ -3,6 +3,7 @@ #include #include #include +#include constexpr const char* kError = "err"; constexpr const char* kInfo = "inf"; From 9ee8aad5f0cfd28ee6fd28a5c77455eb9da56aab Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Thu, 16 Oct 2025 14:14:35 +0300 Subject: [PATCH 5/8] fix warnings (#19) --- src/inputosmxml.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/inputosmxml.cpp b/src/inputosmxml.cpp index 4b54da4..2735262 100644 --- a/src/inputosmxml.cpp +++ b/src/inputosmxml.cpp @@ -15,6 +15,7 @@ #include "inputosmlog.h" #include "timeutil.h" +#include #include #include #include @@ -86,7 +87,7 @@ static void xml_end_node() current_tag = current_tag_t::none; // assemble tags std::vector tags; - for (auto i = 0; i < current_tags.size(); i++) + for (std::size_t i = 0; i < current_tags.size(); i++) { tags.emplace_back( tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); @@ -117,7 +118,7 @@ static void xml_end_way() current_tag = current_tag_t::none; // assemble tags std::vector tags; - for (auto i = 0; i < current_tags.size(); i++) + for (std::size_t i = 0; i < current_tags.size(); i++) { tags.emplace_back( tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); @@ -150,7 +151,7 @@ static void xml_end_relation() current_tag = current_tag_t::none; // assemble tags std::vector tags; - for (auto i = 0; i < current_tags.size(); i++) + for (std::size_t i = 0; i < current_tags.size(); i++) { tags.emplace_back( tag_t{current_strings[current_tags[i].first].c_str(), current_strings[current_tags[i].second].c_str()}); From b761d9b5f6fef05e58003ff700564e906f4b339a Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Sat, 18 Oct 2025 22:50:38 +0300 Subject: [PATCH 6/8] Fix member type assignment in xml_start_member function (#20) --- src/inputosmxml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inputosmxml.cpp b/src/inputosmxml.cpp index 2735262..241b8a0 100644 --- a/src/inputosmxml.cpp +++ b/src/inputosmxml.cpp @@ -211,7 +211,7 @@ static void xml_start_member(const char **attr) if (strcmp(attr[i], "type") == 0) { if (strcmp(attr[i + 1], "node") == 0) member.type = 0; - if (strcmp(attr[i + 1], "way") == 0) member.type = 2; + if (strcmp(attr[i + 1], "way") == 0) member.type = 1; if (strcmp(attr[i + 1], "relation") == 0) member.type = 2; } if (strcmp(attr[i], "role") == 0) From 68c59d5664bdd22ba54d5f9767a44b5c94499b43 Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Sat, 1 Nov 2025 14:01:12 +0200 Subject: [PATCH 7/8] Refactor timestamp parsing functions to handle errors and use timegm for UTC conversion (#21) --- src/timeutil.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/timeutil.cpp b/src/timeutil.cpp index af44232..716e0ac 100644 --- a/src/timeutil.cpp +++ b/src/timeutil.cpp @@ -13,7 +13,8 @@ #include "timeutil.h" #include -#include +#include +#include int64_t now_ms() { @@ -29,16 +30,24 @@ int64_t now_us() time_t str_to_timestamp(const char* str) { - struct tm timeinfo; - strptime(str, "%FT%TZ", &timeinfo); - return mktime(&timeinfo); + struct tm timeinfo{}; + if (strptime(str, "%FT%TZ", &timeinfo) == nullptr) + { + return 0; + } + return timegm(&timeinfo); } + time_t str_to_timestamp_osmstate(const char* str) { - struct tm timeinfo; - strptime(str, "%FT%H\\:%M\\:%SZ", &timeinfo); - return mktime(&timeinfo); + struct tm timeinfo{}; + if (strptime(str, "%FT%H\\:%M\\:%SZ", &timeinfo) == nullptr) + { + return 0; + } + return timegm(&timeinfo); } + std::string timestamp_to_str(const time_t rawtime) { struct tm* dt; From 08f1fd553139ef0d741e2a0a89cd5ec2aac05f3b Mon Sep 17 00:00:00 2001 From: Andrei-Florin Bencsik Date: Mon, 3 Nov 2025 20:15:48 +0200 Subject: [PATCH 8/8] Test initial version of github actions (#12) * Test adding github actions * Update GitHub Actions workflow to support pull requests and enhance build process * Rename workflow file --------- Co-authored-by: Stefan Karschti --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8dbf26d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: Build +run-name: ${{github.actor}} build +on: + push: + pull_request: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential cmake clang clang-tidy libexpat1-dev zlib1g-dev + - name: Configure + run: cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + - name: Build + run: cmake --build build -- -j$(nproc) +