fix mingw build, closes #80

This commit is contained in:
Thomas Fussell 2016-11-19 19:41:21 -05:00
parent daab3cf8ba
commit 455be8fb5f
10 changed files with 15 additions and 28 deletions

View File

@ -4,6 +4,8 @@ set(LIBRARY_VERSION 0.9.0)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# Global platform-specific definitions # Global platform-specific definitions
if(MSVC) if(MSVC)
add_definitions(-DUNICODE -D_UNICODE) add_definitions(-DUNICODE -D_UNICODE)

View File

@ -375,7 +375,7 @@ public:
void load(std::istream &stream, const std::string &password); void load(std::istream &stream, const std::string &password);
void load(const std::vector<std::uint8_t> &data, const std::string &password); void load(const std::vector<std::uint8_t> &data, const std::string &password);
#ifdef WIN32 #ifdef _MSC_VER
void save(const std::wstring &filename); void save(const std::wstring &filename);
void save(const std::wstring &filename, const std::string &password); void save(const std::wstring &filename, const std::string &password);

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <cmath>
#include <ctime> #include <ctime>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>

View File

@ -9,6 +9,7 @@
#define XML_DETAILS_CONFIG_H #define XML_DETAILS_CONFIG_H
#undef LIBSTUDXML_STATIC_LIB #undef LIBSTUDXML_STATIC_LIB
#define LIBSTUDXML_STATIC_LIB
#undef LIBSTUDXML_EXTERNAL_EXPAT #undef LIBSTUDXML_EXTERNAL_EXPAT
#undef LIBSTUDXML_BYTEORDER #undef LIBSTUDXML_BYTEORDER

View File

@ -37,7 +37,7 @@
namespace { namespace {
#ifdef _MSC_VER #ifdef WIN32
char system_separator() char system_separator()
{ {

View File

@ -59,10 +59,8 @@ timedelta timedelta::from_number(long double raw_time)
{ {
timedelta result; timedelta result;
long double integer_part; result.days = static_cast<int>(raw_time);
long double fractional_part = std::modf(raw_time, &integer_part); long double fractional_part = raw_time - result.days;
result.days = static_cast<int>(integer_part);
fractional_part *= 24; fractional_part *= 24;
result.hours = static_cast<int>(fractional_part); result.hours = static_cast<int>(fractional_part);

View File

@ -67,13 +67,15 @@ public:
void test_read_unicode_filename() void test_read_unicode_filename()
{ {
#ifdef WIN32 #ifdef _MSC_VER
xlnt::workbook wb; xlnt::workbook wb;
wb.load(L"data\\19_unicode_Λ.xlsx"); wb.load(L"data\\19_unicode_Λ.xlsx");
TS_ASSERT_EQUALS(wb.get_active_sheet().get_cell("A1").get_value<std::string>(), "unicode!"); TS_ASSERT_EQUALS(wb.get_active_sheet().get_cell("A1").get_value<std::string>(), "unicode!");
#endif #endif
#ifndef __MINGW32__
xlnt::workbook wb2; xlnt::workbook wb2;
wb2.load(u8"data/19_unicode_Λ.xlsx"); wb2.load(u8"data/19_unicode_Λ.xlsx");
TS_ASSERT_EQUALS(wb2.get_active_sheet().get_cell("A1").get_value<std::string>(), "unicode!"); TS_ASSERT_EQUALS(wb2.get_active_sheet().get_cell("A1").get_value<std::string>(), "unicode!");
#endif
} }
}; };

View File

@ -64,7 +64,7 @@
namespace { namespace {
#ifdef WIN32 #ifdef _MSC_VER
std::wstring utf8_to_utf16(const std::string &utf8_string) std::wstring utf8_to_utf16(const std::string &utf8_string)
{ {
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert; std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
@ -822,7 +822,7 @@ void workbook::save(std::ostream &stream, const std::string &password)
producer.write(stream, password); producer.write(stream, password);
} }
#ifdef WIN32 #ifdef _MSC_VER
void workbook::save(const std::wstring &filename) void workbook::save(const std::wstring &filename)
{ {
std::ofstream file_stream; std::ofstream file_stream;

View File

@ -11,24 +11,7 @@ namespace {
static std::string create_temporary_filename() static std::string create_temporary_filename()
{ {
#ifdef _MSC_VER return "temp.xlsx";
std::array<TCHAR, MAX_PATH> buffer;
DWORD result = GetTempPath(static_cast<DWORD>(buffer.size()), buffer.data());
if (result > MAX_PATH)
{
throw std::runtime_error("buffer is too small");
}
if (result == 0)
{
throw std::runtime_error("GetTempPath failed");
}
return std::string(buffer.begin(), buffer.begin() + result) + "xlnt.xlsx";
#else
return "/tmp/xlnt.xlsx";
#endif
} }
} // namespace } // namespace

2
third-party/botan vendored

@ -1 +1 @@
Subproject commit 923a95d546df5b6d31f39b0af900d0361fb2e6a6 Subproject commit 523b2a4ca48fa5cf04ea371aabe7167ce2e5cd13