mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +00:00
Fix parsing of flags.
This commit is contained in:
parent
f16aff8033
commit
438eba1402
36
format.cc
36
format.cc
@ -657,18 +657,26 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
switch (have_width) {
|
switch (have_width) {
|
||||||
case false:
|
case false:
|
||||||
// TODO: parse optional flags
|
// TODO: parse optional flags
|
||||||
switch (*s) {
|
for (bool stop = false; !stop;) {
|
||||||
case '-':
|
switch (*s) {
|
||||||
++s;
|
case '-':
|
||||||
spec.align_ = ALIGN_LEFT;
|
++s;
|
||||||
break;
|
spec.align_ = ALIGN_LEFT;
|
||||||
case '+':
|
break;
|
||||||
// TODO
|
case '+':
|
||||||
spec.flags_ |= SIGN_FLAG | PLUS_FLAG;
|
// TODO
|
||||||
case ' ':
|
++s;
|
||||||
case '#':
|
spec.flags_ |= SIGN_FLAG | PLUS_FLAG;
|
||||||
++s;
|
break;
|
||||||
break;
|
case '0':
|
||||||
|
spec.fill_ = '0';
|
||||||
|
case ' ':
|
||||||
|
case '#':
|
||||||
|
++s;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -731,10 +739,6 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
|
|||||||
// Parse width and zero flag.
|
// Parse width and zero flag.
|
||||||
if (*s < '0' || *s > '9')
|
if (*s < '0' || *s > '9')
|
||||||
break;
|
break;
|
||||||
if (*s == '0')
|
|
||||||
spec.fill_ = '0';
|
|
||||||
// Zero may be parsed again as a part of the width, but it is simpler
|
|
||||||
// and more efficient than checking if the next char is a digit.
|
|
||||||
spec.width_ = internal::ParseNonnegativeInt(s, error);
|
spec.width_ = internal::ParseNonnegativeInt(s, error);
|
||||||
// Fall through.
|
// Fall through.
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user