mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Fix warnings.
This commit is contained in:
15
format.cc
15
format.cc
@ -594,7 +594,7 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
}
|
}
|
||||||
writer.buffer_.append(start, s - 1);
|
writer.buffer_.append(start, s - 1);
|
||||||
|
|
||||||
FormatSpec spec;
|
FormatSpec spec(UINT_MAX);
|
||||||
spec.align_ = ALIGN_RIGHT;
|
spec.align_ = ALIGN_RIGHT;
|
||||||
|
|
||||||
// Reporting errors is delayed till the format specification is
|
// Reporting errors is delayed till the format specification is
|
||||||
@ -610,17 +610,15 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
const char *error = 0;
|
const char *error = 0;
|
||||||
|
|
||||||
unsigned arg_index = 0;
|
unsigned arg_index = 0;
|
||||||
bool have_width = false, have_arg_index = false;
|
bool have_arg_index = false;
|
||||||
c = *s;
|
c = *s;
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
unsigned value = internal::ParseNonnegativeInt(s, error);
|
unsigned value = internal::ParseNonnegativeInt(s, error);
|
||||||
if (*s != '$') {
|
if (*s != '$') {
|
||||||
if (c == '0')
|
if (c == '0')
|
||||||
spec.fill_ = '0';
|
spec.fill_ = '0';
|
||||||
if (value != 0) {
|
if (value != 0)
|
||||||
have_width = true;
|
|
||||||
spec.width_ = value;
|
spec.width_ = value;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
++s;
|
++s;
|
||||||
if (next_arg_index_ <= 0) {
|
if (next_arg_index_ <= 0) {
|
||||||
@ -654,8 +652,9 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int precision = -1;
|
int precision = -1;
|
||||||
switch (have_width) {
|
switch (spec.width_) {
|
||||||
case false: {
|
case UINT_MAX: {
|
||||||
|
spec.width_ = 0;
|
||||||
// TODO: parse optional flags
|
// TODO: parse optional flags
|
||||||
bool stop = false;
|
bool stop = false;
|
||||||
do {
|
do {
|
||||||
@ -742,7 +741,7 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
break;
|
break;
|
||||||
spec.width_ = internal::ParseNonnegativeInt(s, error);
|
spec.width_ = internal::ParseNonnegativeInt(s, error);
|
||||||
}
|
}
|
||||||
// Fall through.
|
// Fall through.
|
||||||
default:
|
default:
|
||||||
if (spec.fill_ == '0') {
|
if (spec.fill_ == '0') {
|
||||||
spec.align_ = ALIGN_NUMERIC;
|
spec.align_ = ALIGN_NUMERIC;
|
||||||
|
@ -188,7 +188,7 @@ TEST(FileTest, ReadRetry) {
|
|||||||
std::streamsize count = 0;
|
std::streamsize count = 0;
|
||||||
EXPECT_RETRY(count = read_end.read(buffer, SIZE),
|
EXPECT_RETRY(count = read_end.read(buffer, SIZE),
|
||||||
read, "cannot read from file");
|
read, "cannot read from file");
|
||||||
EXPECT_EQ_POSIX(SIZE, count);
|
EXPECT_EQ_POSIX(static_cast<std::streamsize>(SIZE), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FileTest, WriteRetry) {
|
TEST(FileTest, WriteRetry) {
|
||||||
@ -200,7 +200,7 @@ TEST(FileTest, WriteRetry) {
|
|||||||
write, "cannot write to file");
|
write, "cannot write to file");
|
||||||
write_end.close();
|
write_end.close();
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
EXPECT_EQ(SIZE, count);
|
EXPECT_EQ(static_cast<std::streamsize>(SIZE), count);
|
||||||
char buffer[SIZE + 1];
|
char buffer[SIZE + 1];
|
||||||
read_end.read(buffer, SIZE);
|
read_end.read(buffer, SIZE);
|
||||||
buffer[SIZE] = '\0';
|
buffer[SIZE] = '\0';
|
||||||
|
Reference in New Issue
Block a user