Fix more -Wshadow warnings

This commit is contained in:
Victor Zverovich 2014-12-10 07:24:05 -08:00
parent f9fc8fd09d
commit 2523f3b939

View File

@ -1098,8 +1098,8 @@ class IntFormatSpec : public SpecT {
T value_; T value_;
public: public:
IntFormatSpec(T value, const SpecT &spec = SpecT()) IntFormatSpec(T val, const SpecT &spec = SpecT())
: SpecT(spec), value_(value) {} : SpecT(spec), value_(val) {}
T value() const { return value_; } T value() const { return value_; }
}; };
@ -1885,13 +1885,13 @@ void BasicWriter<Char>::write_double(
if (value != value) { if (value != value) {
// Format NaN ourselves because sprintf's output is not consistent // Format NaN ourselves because sprintf's output is not consistent
// across platforms. // across platforms.
std::size_t size = 4; std::size_t nan_size = 4;
const char *nan = upper ? " NAN" : " nan"; const char *nan = upper ? " NAN" : " nan";
if (!sign) { if (!sign) {
--size; --nan_size;
++nan; ++nan;
} }
CharPtr out = write_str(nan, size, spec); CharPtr out = write_str(nan, nan_size, spec);
if (sign) if (sign)
*out = sign; *out = sign;
return; return;
@ -1900,13 +1900,13 @@ void BasicWriter<Char>::write_double(
if (internal::isinfinity(value)) { if (internal::isinfinity(value)) {
// Format infinity ourselves because sprintf's output is not consistent // Format infinity ourselves because sprintf's output is not consistent
// across platforms. // across platforms.
std::size_t size = 4; std::size_t inf_size = 4;
const char *inf = upper ? " INF" : " inf"; const char *inf = upper ? " INF" : " inf";
if (!sign) { if (!sign) {
--size; --inf_size;
++inf; ++inf;
} }
CharPtr out = write_str(inf, size, spec); CharPtr out = write_str(inf, inf_size, spec);
if (sign) if (sign)
*out = sign; *out = sign;
return; return;
@ -1949,19 +1949,19 @@ void BasicWriter<Char>::write_double(
// Format using snprintf. // Format using snprintf.
Char fill = static_cast<Char>(spec.fill()); Char fill = static_cast<Char>(spec.fill());
for (;;) { for (;;) {
std::size_t size = buffer_.capacity() - offset; std::size_t buffer_size = buffer_.capacity() - offset;
#if _MSC_VER #if _MSC_VER
// MSVC's vsnprintf_s doesn't work with zero size, so reserve // MSVC's vsnprintf_s doesn't work with zero size, so reserve
// space for at least one extra character to make the size non-zero. // space for at least one extra character to make the size non-zero.
// Note that the buffer's capacity will increase by more than 1. // Note that the buffer's capacity will increase by more than 1.
if (size == 0) { if (buffer_size == 0) {
buffer_.reserve(offset + 1); buffer_.reserve(offset + 1);
size = buffer_.capacity() - offset; buffer_size = buffer_.capacity() - offset;
} }
#endif #endif
Char *start = &buffer_[offset]; Char *start = &buffer_[offset];
int n = internal::CharTraits<Char>::format_float( int n = internal::CharTraits<Char>::format_float(
start, size, format, width_for_sprintf, spec.precision(), value); start, buffer_size, format, width_for_sprintf, spec.precision(), value);
if (n >= 0 && offset + n < buffer_.capacity()) { if (n >= 0 && offset + n < buffer_.capacity()) {
if (sign) { if (sign) {
if ((spec.align() != ALIGN_RIGHT && spec.align() != ALIGN_DEFAULT) || if ((spec.align() != ALIGN_RIGHT && spec.align() != ALIGN_DEFAULT) ||
@ -1975,7 +1975,7 @@ void BasicWriter<Char>::write_double(
} }
if (spec.align() == ALIGN_CENTER && if (spec.align() == ALIGN_CENTER &&
spec.width() > static_cast<unsigned>(n)) { spec.width() > static_cast<unsigned>(n)) {
unsigned width = spec.width(); width = spec.width();
CharPtr p = grow_buffer(width); CharPtr p = grow_buffer(width);
std::copy(p, p + n, p + (width - n) / 2); std::copy(p, p + n, p + (width - n) / 2);
fill_padding(p, spec.width(), n, fill); fill_padding(p, spec.width(), n, fill);