fix clang warnings

This commit is contained in:
Thomas Fussell 2017-09-08 22:59:19 -04:00
parent 12007fe2d8
commit 396e6eb948
9 changed files with 28 additions and 28 deletions

View File

@ -59,7 +59,7 @@ namespace {
std::pair<bool, double> cast_numeric(const std::string &s)
{
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())
? 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 <>

View File

@ -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");
}

View File

@ -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);

View File

@ -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::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);
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<int>(fractional_part)) > 0.000001L
&& std::abs(fractional_part - static_cast<int>(fractional_part)) < 0.999999L)
while (std::abs(fractional_part - static_cast<int>(fractional_part)) > 0.000001
&& std::abs(fractional_part - static_cast<int>(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<int>(std::pow(10, denominator_digits - 1));
auto upper = static_cast<int>(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<std::size_t>(6), part.placeholders.num_zeros + part.placeholders.num_optionals);
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;
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;

View File

@ -24,6 +24,7 @@
#include <cctype>
#include <numeric> // for std::accumulate
#include <sstream>
#include <unordered_map>
#include <detail/constants.hpp>
#include <detail/header_footer/header_footer_code.hpp>
@ -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")))

View File

@ -49,7 +49,7 @@ namespace {
/// </summary>
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)

View File

@ -117,9 +117,9 @@ double time::to_number() const
microseconds += static_cast<std::uint64_t>(minute * 1e6 * 60);
auto microseconds_per_hour = static_cast<std::uint64_t>(1e6) * 60 * 60;
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;
number = std::floor(number * hundred_billion + 0.5L) / hundred_billion;
number = std::floor(number * hundred_billion + 0.5) / hundred_billion;
return number;
}

View File

@ -68,7 +68,7 @@ timedelta timedelta::from_number(double raw_time)
fractional_part = 1000000 * (fractional_part - result.seconds);
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.seconds += 1;

View File

@ -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();
}
}