mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix clang warnings
This commit is contained in:
parent
12007fe2d8
commit
396e6eb948
|
@ -59,7 +59,7 @@ namespace {
|
||||||
std::pair<bool, double> cast_numeric(const std::string &s)
|
std::pair<bool, double> cast_numeric(const std::string &s)
|
||||||
{
|
{
|
||||||
auto str_end = static_cast<char *>(nullptr);
|
auto str_end = static_cast<char *>(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())
|
return (str_end != s.c_str() + s.size())
|
||||||
? std::make_pair(false, 0.0)
|
? std::make_pair(false, 0.0)
|
||||||
|
@ -529,7 +529,7 @@ void cell::clear_value()
|
||||||
template <>
|
template <>
|
||||||
XLNT_API bool cell::value() const
|
XLNT_API bool cell::value() const
|
||||||
{
|
{
|
||||||
return d_->value_numeric_ != 0.L;
|
return d_->value_numeric_ != 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|
|
@ -283,18 +283,18 @@ encryption_info read_encryption_info(std::istream &info_stream, const std::u16st
|
||||||
throw xlnt::exception("unsupported encryption version");
|
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");
|
throw xlnt::exception("bad header");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((encryption_flags & 0b00000100) == 0 // fCryptoAPI
|
if ((encryption_flags & 0x04) == 0 // fCryptoAPI
|
||||||
|| (encryption_flags & 0b00010000) != 0) // fExternal
|
|| (encryption_flags & 0x10) != 0) // fExternal
|
||||||
{
|
{
|
||||||
throw xlnt::exception("extensible encryption is not supported");
|
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");
|
throw xlnt::exception("not an OOXML document");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_major = std::uint16_t(4);
|
||||||
const auto version_minor = std::uint16_t(2);
|
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_major);
|
||||||
writer.write(version_minor);
|
writer.write(version_minor);
|
||||||
|
|
|
@ -96,9 +96,9 @@ bool format_condition::satisfied_by(double number) const
|
||||||
case condition_type::less_than:
|
case condition_type::less_than:
|
||||||
return number < value;
|
return number < value;
|
||||||
case condition_type::not_equal:
|
case condition_type::not_equal:
|
||||||
return std::fabs(number - value) != 0.0L;
|
return std::fabs(number - value) != 0.0;
|
||||||
case condition_type::equal:
|
case condition_type::equal:
|
||||||
return std::fabs(number - value) == 0.0L;
|
return std::fabs(number - value) == 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
default_case(false);
|
default_case(false);
|
||||||
|
@ -221,7 +221,7 @@ void number_format_parser::parse()
|
||||||
value = token.string.substr(1);
|
value = token.string.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
section.condition.value = std::stold(value);
|
section.condition.value = std::stod(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,7 +1263,7 @@ std::string number_formatter::fill_scientific_placeholders(const format_placehol
|
||||||
{
|
{
|
||||||
std::size_t logarithm = 0;
|
std::size_t logarithm = 0;
|
||||||
|
|
||||||
if (number != 0.L)
|
if (number != 0.0)
|
||||||
{
|
{
|
||||||
logarithm = static_cast<std::size_t>(std::log10(number));
|
logarithm = static_cast<std::size_t>(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);
|
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');
|
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;
|
auto original_fractional_part = fractional_part;
|
||||||
fractional_part *= 10;
|
fractional_part *= 10;
|
||||||
|
|
||||||
while (std::abs(fractional_part - static_cast<int>(fractional_part)) > 0.000001L
|
while (std::abs(fractional_part - static_cast<int>(fractional_part)) > 0.000001
|
||||||
&& std::abs(fractional_part - static_cast<int>(fractional_part)) < 0.999999L)
|
&& std::abs(fractional_part - static_cast<int>(fractional_part)) < 0.999999)
|
||||||
{
|
{
|
||||||
fractional_part *= 10;
|
fractional_part *= 10;
|
||||||
}
|
}
|
||||||
|
@ -1331,7 +1331,7 @@ std::string number_formatter::fill_fraction_placeholders(const format_placeholde
|
||||||
auto lower = static_cast<int>(std::pow(10, denominator_digits - 1));
|
auto lower = static_cast<int>(std::pow(10, denominator_digits - 1));
|
||||||
auto upper = static_cast<int>(std::pow(10, denominator_digits));
|
auto upper = static_cast<int>(std::pow(10, denominator_digits));
|
||||||
auto best_denominator = lower;
|
auto best_denominator = lower;
|
||||||
auto best_difference = 1000.0L;
|
auto best_difference = 1000.0;
|
||||||
|
|
||||||
for (int i = lower; i < upper; ++i)
|
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 (format.is_datetime)
|
||||||
{
|
{
|
||||||
if (number != 0.L)
|
if (number != 0.0)
|
||||||
{
|
{
|
||||||
dt = xlnt::datetime::from_number(number, calendar_);
|
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(
|
auto digits = std::min(
|
||||||
static_cast<std::size_t>(6), part.placeholders.num_zeros + part.placeholders.num_optionals);
|
static_cast<std::size_t>(6), part.placeholders.num_zeros + part.placeholders.num_optionals);
|
||||||
auto denominator = static_cast<int>(std::pow(10.0, digits));
|
auto denominator = static_cast<int>(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;
|
fractional_seconds = std::round(fractional_seconds) / denominator;
|
||||||
result.append(fill_placeholders(part.placeholders, fractional_seconds));
|
result.append(fill_placeholders(part.placeholders, fractional_seconds));
|
||||||
break;
|
break;
|
||||||
|
@ -1449,7 +1449,7 @@ std::string number_formatter::format_number(const format_code &format, double nu
|
||||||
{
|
{
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
if (number == 0.L)
|
if (number == 0.0)
|
||||||
{
|
{
|
||||||
result.pop_back();
|
result.pop_back();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <numeric> // for std::accumulate
|
#include <numeric> // for std::accumulate
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <detail/constants.hpp>
|
#include <detail/constants.hpp>
|
||||||
#include <detail/header_footer/header_footer_code.hpp>
|
#include <detail/header_footer/header_footer_code.hpp>
|
||||||
|
@ -116,7 +117,7 @@ struct number_converter
|
||||||
stream.clear();
|
stream.clear();
|
||||||
stream >> result;
|
stream >> result;
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
std::istringstream stream;
|
std::istringstream stream;
|
||||||
double result;
|
double result;
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool is_integral(double d)
|
bool is_integral(double d)
|
||||||
{
|
{
|
||||||
return std::fabs(d - static_cast<double>(static_cast<long long int>(d))) == 0.L;
|
return std::fabs(d - static_cast<double>(static_cast<long long int>(d))) == 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> core_property_namespace(xlnt::core_property type)
|
std::vector<std::pair<std::string, std::string>> core_property_namespace(xlnt::core_property type)
|
||||||
|
|
|
@ -117,9 +117,9 @@ double time::to_number() const
|
||||||
microseconds += static_cast<std::uint64_t>(minute * 1e6 * 60);
|
microseconds += static_cast<std::uint64_t>(minute * 1e6 * 60);
|
||||||
auto microseconds_per_hour = static_cast<std::uint64_t>(1e6) * 60 * 60;
|
auto microseconds_per_hour = static_cast<std::uint64_t>(1e6) * 60 * 60;
|
||||||
microseconds += static_cast<std::uint64_t>(hour) * microseconds_per_hour;
|
microseconds += static_cast<std::uint64_t>(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<std::uint64_t>(1e9) * 100;
|
auto hundred_billion = static_cast<std::uint64_t>(1e9) * 100;
|
||||||
number = std::floor(number * hundred_billion + 0.5L) / hundred_billion;
|
number = std::floor(number * hundred_billion + 0.5) / hundred_billion;
|
||||||
|
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ timedelta timedelta::from_number(double raw_time)
|
||||||
fractional_part = 1000000 * (fractional_part - result.seconds);
|
fractional_part = 1000000 * (fractional_part - result.seconds);
|
||||||
result.microseconds = static_cast<int>(fractional_part);
|
result.microseconds = static_cast<int>(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.microseconds = 0;
|
||||||
result.seconds += 1;
|
result.seconds += 1;
|
||||||
|
|
|
@ -476,11 +476,10 @@ public:
|
||||||
|
|
||||||
while (reader.has_cell())
|
while (reader.has_cell())
|
||||||
{
|
{
|
||||||
const auto cell = reader.read_cell();
|
reader.read_cell();
|
||||||
//std::cout << cell.reference().to_string() << " " << cell.to_string() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ws = reader.end_worksheet();
|
reader.end_worksheet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user