diff --git a/octa/format.hh b/octa/format.hh index b0d41cc..86ba356 100644 --- a/octa/format.hh +++ b/octa/format.hh @@ -261,8 +261,7 @@ protected: } bool read_spec_range() { - p_nested_escape = (*p_fmt != '-'); - if (!p_nested_escape) ++p_fmt; + p_nested_escape = !(p_flags & FMT_FLAG_DASH); ++p_fmt; const char *begin_inner = p_fmt; if (!read_until_dummy()) { @@ -319,9 +318,6 @@ protected: } bool read_spec() { - if ((*p_fmt == '(') || ((*p_fmt == '-') && (*(p_fmt + 1) == '('))) { - return read_spec_range(); - } Size ndig = detail::read_digits(p_fmt, p_buf); bool havepos = false; @@ -336,11 +332,6 @@ protected: havepos = true; } - if (havepos && ((*p_fmt == '(') || ((*p_fmt == '-') && - (*(p_fmt + 1) == '(')))) { - return read_spec_range(); - } - /* parse flags */ p_flags = 0; Size skipd = 0; @@ -356,6 +347,11 @@ protected: 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 */ p_width = 0; p_has_width = false;