fix ZAM "cat" of doubles/times to include trailing ".0" per normal BiF behavior

This commit is contained in:
Vern Paxson 2024-03-20 14:15:40 -07:00 committed by Tim Wojtulewicz
parent 86d1812d49
commit 4cafacf90b
5 changed files with 48 additions and 15 deletions

View file

@ -68,10 +68,18 @@ void FixedCatArg::RenderInto(ZVal* zframe, int slot, char*& res) {
break;
case TYPE_DOUBLE:
case TYPE_TIME:
n = modp_dtoa2(z.AsDouble(), res, 6);
case TYPE_TIME: {
auto d = z.AsDouble();
n = modp_dtoa2(d, res, 6);
res += n;
if ( util::approx_equal(d, nearbyint(d), 1e-9) && std::isfinite(d) && ! strchr(tmp, 'e') ) {
// disambiguate from integer
*(res++) = '.';
*(res++) = '0';
}
break;
}
case TYPE_PATTERN:
text = z.AsPattern()->AsPattern()->PatternText();