From 39503e8bf03c5b5e742e4a0a47f8588451723ce5 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Thu, 26 Dec 2019 12:52:14 -0500 Subject: [PATCH] fix warnings and other minor issues --- source/CMakeLists.txt | 8 ++++++-- source/detail/external/include_libstudxml.hpp | 8 ++++---- source/detail/serialization/xlsx_consumer.cpp | 2 +- source/detail/unicode.cpp | 2 +- source/utils/date.cpp | 2 +- tests/CMakeLists.txt | 3 ++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a6d57b25..f7ca529a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -84,6 +84,8 @@ file(GLOB WORKBOOK_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/workbook/*.hpp) file(GLOB WORKBOOK_SOURCES ${XLNT_SOURCE_DIR}/workbook/*.cpp) file(GLOB WORKSHEET_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/worksheet/*.hpp) file(GLOB WORKSHEET_SOURCES ${XLNT_SOURCE_DIR}/worksheet/*.cpp) +file(GLOB MINIZ_HEADERS ${THIRD_PARTY_DIR}/miniz/*.h) +file(GLOB MINIZ_SOURCES ${THIRD_PARTY_DIR}/miniz/*.c) file(GLOB DETAIL_ROOT_HEADERS ${XLNT_SOURCE_DIR}/detail/*.hpp) file(GLOB DETAIL_ROOT_SOURCES ${XLNT_SOURCE_DIR}/detail/*.cpp) @@ -113,12 +115,12 @@ set(XLNT_HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} ${CHARTSHEET_HEADERS} ${DRAWING_HEADERS} ${FORMULA_HEADERS} ${PACKAGING_HEADERS} ${STYLES_HEADERS} ${UTILS_HEADERS} ${WORKBOOK_HEADERS} ${WORKSHEET_HEADERS} ${DETAIL_HEADERS} ${DETAIL_CRYPTO_HEADERS} - ${DRAWING_HEADERS}) + ${DRAWING_HEADERS} ${MINIZ_HEADERS}) set(XLNT_SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES} ${DRAWING_SOURCES} ${FORMULA_SOURCES} ${PACKAGING_SOURCES} ${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES} ${WORKSHEET_SOURCES} ${DETAIL_SOURCES} ${DETAIL_CRYPTO_SOURCES} - ${DRAWING_SOURCES}) + ${DRAWING_SOURCES} ${MINIZ_SOURCES}) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Set a default CMAKE_INSTALL_PREFIX if one wasn't specified @@ -184,6 +186,7 @@ target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR} ${XLNT_SOURCE_DIR}/../third-party/libstudxml + ${XLNT_SOURCE_DIR}/../third-party/miniz ${XLNT_SOURCE_DIR}/../third-party/utfcpp) # Platform- and file-specific settings, MSVC @@ -237,6 +240,7 @@ source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES}) source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES}) source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES}) source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES}) +source_group(third-party\\miniz FILES ${MINIZ_HEADERS} ${MINIZ_SOURCES}) # Install library install(TARGETS xlnt EXPORT XlntTargets diff --git a/source/detail/external/include_libstudxml.hpp b/source/detail/external/include_libstudxml.hpp index ec1c18ec..1360204f 100644 --- a/source/detail/external/include_libstudxml.hpp +++ b/source/detail/external/include_libstudxml.hpp @@ -26,8 +26,8 @@ #pragma clang diagnostic ignored "-Wweak-vtables" #pragma clang diagnostic ignored "-Wextra-semi" #pragma clang diagnostic ignored "-Wdeprecated" -#include -#include -#include -#include +#include +#include +#include +#include #pragma clang diagnostic pop diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index a775e6a6..79607075 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -349,7 +349,7 @@ std::pair parse_row(xml::parser *parser, xlnt::detail switch (e) { case xml::parser::start_element: { - parsed_cells.push_back(parse_cell(props.second, parser)); + parsed_cells.push_back(parse_cell(static_cast(props.second), parser)); break; } case xml::parser::end_element: { diff --git a/source/detail/unicode.cpp b/source/detail/unicode.cpp index 121dcfd2..f176fd83 100644 --- a/source/detail/unicode.cpp +++ b/source/detail/unicode.cpp @@ -78,7 +78,7 @@ size_t string_length(const std::string &utf8_string) throw xlnt::exception("Invalid UTF-8 encoding detected"); } - return utf8::distance(utf8_string.begin(), end_it); + return static_cast(utf8::distance(utf8_string.begin(), end_it)); } } // namespace detail diff --git a/source/utils/date.cpp b/source/utils/date.cpp index 9e9a8450..bd8f1b04 100644 --- a/source/utils/date.cpp +++ b/source/utils/date.cpp @@ -126,7 +126,7 @@ date date::today() int date::weekday() const { - std::tm tm{0, 0, 0, day, month - 1, year - 1900}; + std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, nullptr}; std::time_t time = std::mktime(&tm); return safe_localtime(time).tm_wday; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 22264304..b46b5403 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,7 +48,8 @@ target_link_libraries(xlnt.test PRIVATE xlnt) target_include_directories(xlnt.test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml) + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/miniz) set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data) target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})