(format): Pay attention to the max_width setting for each formatting
element. This means that "%.20N" can no longer exceed 20 characters of width.
This commit is contained in:
parent
632c54788c
commit
9cd4cf6df8
1 changed files with 8 additions and 1 deletions
|
|
@ -210,9 +210,11 @@ element_t * format_t::parse_elements(const std::string& fmt)
|
|||
return result.release();
|
||||
}
|
||||
|
||||
void format_t::format(std::ostream& out, const details_t& details) const
|
||||
void format_t::format(std::ostream& out_str, const details_t& details) const
|
||||
{
|
||||
for (const element_t * elem = elements; elem; elem = elem->next) {
|
||||
std::ostringstream out;
|
||||
|
||||
if (elem->align_left)
|
||||
out << std::left;
|
||||
else
|
||||
|
|
@ -430,6 +432,11 @@ void format_t::format(std::ostream& out, const details_t& details) const
|
|||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
std::string temp = out.str();
|
||||
if (elem->max_width > 0 && elem->max_width < temp.length())
|
||||
temp.erase(elem->max_width);
|
||||
out_str << temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue