saner range format parsing

master
Daniel Kolesa 2015-07-10 00:24:47 +01:00
parent 30d57aec7d
commit cfcb35575a
1 changed files with 6 additions and 10 deletions

View File

@ -261,8 +261,7 @@ protected:
} }
bool read_spec_range() { bool read_spec_range() {
p_nested_escape = (*p_fmt != '-'); p_nested_escape = !(p_flags & FMT_FLAG_DASH);
if (!p_nested_escape) ++p_fmt;
++p_fmt; ++p_fmt;
const char *begin_inner = p_fmt; const char *begin_inner = p_fmt;
if (!read_until_dummy()) { if (!read_until_dummy()) {
@ -319,9 +318,6 @@ protected:
} }
bool read_spec() { bool read_spec() {
if ((*p_fmt == '(') || ((*p_fmt == '-') && (*(p_fmt + 1) == '('))) {
return read_spec_range();
}
Size ndig = detail::read_digits(p_fmt, p_buf); Size ndig = detail::read_digits(p_fmt, p_buf);
bool havepos = false; bool havepos = false;
@ -336,11 +332,6 @@ protected:
havepos = true; havepos = true;
} }
if (havepos && ((*p_fmt == '(') || ((*p_fmt == '-') &&
(*(p_fmt + 1) == '(')))) {
return read_spec_range();
}
/* parse flags */ /* parse flags */
p_flags = 0; p_flags = 0;
Size skipd = 0; Size skipd = 0;
@ -356,6 +347,11 @@ protected:
p_flags = detail::parse_fmt_flags(p_fmt, p_flags); p_flags = detail::parse_fmt_flags(p_fmt, p_flags);
} }
/* range/array formatting */
if ((*p_fmt == '(') && (havepos || !(ndig - skipd))) {
return read_spec_range();
}
/* parse width */ /* parse width */
p_width = 0; p_width = 0;
p_has_width = false; p_has_width = false;