mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 19:49:36 +03:00
Fix issue 19252: avoid ridiculous format length overestimate; dynamic-width strings should estimate width 0, not int.max
This commit is contained in:
parent
e80038b9d0
commit
c156f4ad95
1 changed files with 5 additions and 1 deletions
|
@ -6321,8 +6321,11 @@ private size_t guessLength(Char, S)(S fmtString)
|
|||
|
||||
if (spec.width == spec.precision)
|
||||
len += spec.width;
|
||||
else if (spec.width > 0 && (spec.precision == spec.UNSPECIFIED || spec.width > spec.precision))
|
||||
else if (spec.width > 0 && spec.width != spec.DYNAMIC &&
|
||||
(spec.precision == spec.UNSPECIFIED || spec.width > spec.precision))
|
||||
{
|
||||
len += spec.width;
|
||||
}
|
||||
else if (spec.precision != spec.UNSPECIFIED && spec.precision > spec.width)
|
||||
len += spec.precision;
|
||||
}
|
||||
|
@ -6345,6 +6348,7 @@ unittest
|
|||
assert(guessLength!char("%2.4f") == 4);
|
||||
assert(guessLength!char("%02d:%02d:%02d") == 8);
|
||||
assert(guessLength!char("%0.2f") == 7);
|
||||
assert(guessLength!char("%0*d") == 0);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue