Handle reporting widths that are too small
This commit is contained in:
parent
d0ac3a2e4e
commit
13812346b6
2 changed files with 3 additions and 2 deletions
|
|
@ -286,7 +286,7 @@ string format_t::truncate(const unistring& ustr, std::size_t width,
|
|||
assert(width < 4095);
|
||||
|
||||
const std::size_t len = ustr.length();
|
||||
if (len <= width)
|
||||
if (width == 0 || len <= width)
|
||||
return ustr.extract();
|
||||
|
||||
std::ostringstream buf;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ value_t report_t::fn_truncate(call_scope_t& args)
|
|||
var_t<long> width(args, 1);
|
||||
var_t<long> account_abbrev(args, 2);
|
||||
|
||||
return string_value(format_t::truncate(args[0].as_string(), *width,
|
||||
return string_value(format_t::truncate(args[0].as_string(),
|
||||
width && *width > 0 ? *width : 0,
|
||||
account_abbrev ? *account_abbrev : -1));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue