diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 19c29272..1e47202f 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -59,7 +59,7 @@ namespace { std::pair cast_numeric(const std::string &s) { auto str_end = static_cast(nullptr); - auto result = std::strtold(s.c_str(), &str_end); + auto result = std::strtod(s.c_str(), &str_end); return (str_end != s.c_str() + s.size()) ? std::make_pair(false, 0.0) @@ -529,7 +529,7 @@ void cell::clear_value() template <> XLNT_API bool cell::value() const { - return d_->value_numeric_ != 0.L; + return d_->value_numeric_ != 0.0; } template <> diff --git a/source/detail/cryptography/xlsx_crypto_consumer.cpp b/source/detail/cryptography/xlsx_crypto_consumer.cpp index be96920b..a614523a 100644 --- a/source/detail/cryptography/xlsx_crypto_consumer.cpp +++ b/source/detail/cryptography/xlsx_crypto_consumer.cpp @@ -283,18 +283,18 @@ encryption_info read_encryption_info(std::istream &info_stream, const std::u16st throw xlnt::exception("unsupported encryption version"); } - if ((encryption_flags & 0b00000011) != 0) // Reserved1 and Reserved2, MUST be 0 + if ((encryption_flags & 0x03) != 0) // Reserved1 and Reserved2, MUST be 0 { throw xlnt::exception("bad header"); } - if ((encryption_flags & 0b00000100) == 0 // fCryptoAPI - || (encryption_flags & 0b00010000) != 0) // fExternal + if ((encryption_flags & 0x04) == 0 // fCryptoAPI + || (encryption_flags & 0x10) != 0) // fExternal { throw xlnt::exception("extensible encryption is not supported"); } - if ((encryption_flags & 0b00100000) == 0) // fAES + if ((encryption_flags & 0x20) == 0) // fAES { throw xlnt::exception("not an OOXML document"); } diff --git a/source/detail/cryptography/xlsx_crypto_producer.cpp b/source/detail/cryptography/xlsx_crypto_producer.cpp index 07448d8b..2916b155 100644 --- a/source/detail/cryptography/xlsx_crypto_producer.cpp +++ b/source/detail/cryptography/xlsx_crypto_producer.cpp @@ -181,7 +181,7 @@ void write_standard_encryption_info(const encryption_info &info, std::ostream &i const auto version_major = std::uint16_t(4); const auto version_minor = std::uint16_t(2); - const auto encryption_flags = std::uint32_t(0b00010000 & 0b00100000); + const auto encryption_flags = std::uint32_t(0x10 & 0x20); writer.write(version_major); writer.write(version_minor); diff --git a/source/detail/number_format/number_formatter.cpp b/source/detail/number_format/number_formatter.cpp index e002f3f6..eb9f1dc7 100644 --- a/source/detail/number_format/number_formatter.cpp +++ b/source/detail/number_format/number_formatter.cpp @@ -96,9 +96,9 @@ bool format_condition::satisfied_by(double number) const case condition_type::less_than: return number < value; case condition_type::not_equal: - return std::fabs(number - value) != 0.0L; + return std::fabs(number - value) != 0.0; case condition_type::equal: - return std::fabs(number - value) == 0.0L; + return std::fabs(number - value) == 0.0; } default_case(false); @@ -221,7 +221,7 @@ void number_format_parser::parse() value = token.string.substr(1); } - section.condition.value = std::stold(value); + section.condition.value = std::stod(value); break; } @@ -1263,7 +1263,7 @@ std::string number_formatter::fill_scientific_placeholders(const format_placehol { std::size_t logarithm = 0; - if (number != 0.L) + if (number != 0.0) { logarithm = static_cast(std::log10(number)); @@ -1280,7 +1280,7 @@ std::string number_formatter::fill_scientific_placeholders(const format_placehol std::string integer_string = std::to_string(integer); - if (number == 0.L) + if (number == 0.0) { integer_string = std::string(integer_part.num_zeros + integer_part.num_optionals, '0'); } @@ -1318,8 +1318,8 @@ std::string number_formatter::fill_fraction_placeholders(const format_placeholde auto original_fractional_part = fractional_part; fractional_part *= 10; - while (std::abs(fractional_part - static_cast(fractional_part)) > 0.000001L - && std::abs(fractional_part - static_cast(fractional_part)) < 0.999999L) + while (std::abs(fractional_part - static_cast(fractional_part)) > 0.000001 + && std::abs(fractional_part - static_cast(fractional_part)) < 0.999999) { fractional_part *= 10; } @@ -1331,7 +1331,7 @@ std::string number_formatter::fill_fraction_placeholders(const format_placeholde auto lower = static_cast(std::pow(10, denominator_digits - 1)); auto upper = static_cast(std::pow(10, denominator_digits)); auto best_denominator = lower; - auto best_difference = 1000.0L; + auto best_difference = 1000.0; for (int i = lower; i < upper; ++i) { @@ -1377,7 +1377,7 @@ std::string number_formatter::format_number(const format_code &format, double nu if (format.is_datetime) { - if (number != 0.L) + if (number != 0.0) { dt = xlnt::datetime::from_number(number, calendar_); } @@ -1434,7 +1434,7 @@ std::string number_formatter::format_number(const format_code &format, double nu auto digits = std::min( static_cast(6), part.placeholders.num_zeros + part.placeholders.num_optionals); auto denominator = static_cast(std::pow(10.0, digits)); - auto fractional_seconds = dt.microsecond / 1.0E6L * denominator; + auto fractional_seconds = dt.microsecond / 1.0E6 * denominator; fractional_seconds = std::round(fractional_seconds) / denominator; result.append(fill_placeholders(part.placeholders, fractional_seconds)); break; @@ -1449,7 +1449,7 @@ std::string number_formatter::format_number(const format_code &format, double nu { i += 2; - if (number == 0.L) + if (number == 0.0) { result.pop_back(); break; diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index cb9e19b4..4b474386 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -24,6 +24,7 @@ #include #include // for std::accumulate #include +#include #include #include @@ -116,7 +117,7 @@ struct number_converter stream.clear(); stream >> result; return result; - }; + } std::istringstream stream; double result; @@ -203,7 +204,7 @@ cell xlsx_consumer::read_cell() if (!in_element(qn("spreadsheetml", "row"))) { return cell(nullptr); - } + } expect_start_element(qn("spreadsheetml", "c"), xml::content::complex); @@ -563,7 +564,7 @@ void xlsx_consumer::read_worksheet_sheetdata() { return; } - + number_converter converter; while (in_element(qn("spreadsheetml", "sheetData"))) diff --git a/source/detail/serialization/xlsx_producer.cpp b/source/detail/serialization/xlsx_producer.cpp index 2fad2f5c..e181960e 100644 --- a/source/detail/serialization/xlsx_producer.cpp +++ b/source/detail/serialization/xlsx_producer.cpp @@ -49,7 +49,7 @@ namespace { /// bool is_integral(double d) { - return std::fabs(d - static_cast(static_cast(d))) == 0.L; + return std::fabs(d - static_cast(static_cast(d))) == 0.0; } std::vector> core_property_namespace(xlnt::core_property type) diff --git a/source/utils/time.cpp b/source/utils/time.cpp index 4c3365ac..147e41f0 100644 --- a/source/utils/time.cpp +++ b/source/utils/time.cpp @@ -117,9 +117,9 @@ double time::to_number() const microseconds += static_cast(minute * 1e6 * 60); auto microseconds_per_hour = static_cast(1e6) * 60 * 60; microseconds += static_cast(hour) * microseconds_per_hour; - auto number = microseconds / (24.0L * microseconds_per_hour); + auto number = microseconds / (24.0 * microseconds_per_hour); auto hundred_billion = static_cast(1e9) * 100; - number = std::floor(number * hundred_billion + 0.5L) / hundred_billion; + number = std::floor(number * hundred_billion + 0.5) / hundred_billion; return number; } diff --git a/source/utils/timedelta.cpp b/source/utils/timedelta.cpp index 0ae9c7d6..88391a01 100644 --- a/source/utils/timedelta.cpp +++ b/source/utils/timedelta.cpp @@ -68,7 +68,7 @@ timedelta timedelta::from_number(double raw_time) fractional_part = 1000000 * (fractional_part - result.seconds); result.microseconds = static_cast(fractional_part); - if (result.microseconds == 999999 && fractional_part - result.microseconds > 0.5L) + if (result.microseconds == 999999 && fractional_part - result.microseconds > 0.5) { result.microseconds = 0; result.seconds += 1; diff --git a/tests/workbook/serialization_test_suite.hpp b/tests/workbook/serialization_test_suite.hpp index 2c077e08..88c4f9cb 100644 --- a/tests/workbook/serialization_test_suite.hpp +++ b/tests/workbook/serialization_test_suite.hpp @@ -476,11 +476,10 @@ public: while (reader.has_cell()) { - const auto cell = reader.read_cell(); - //std::cout << cell.reference().to_string() << " " << cell.to_string() << std::endl; + reader.read_cell(); } - const auto ws = reader.end_worksheet(); + reader.end_worksheet(); } }