Page MenuHomeFreeBSD

seq(1): print integers up to 2^mantissa as integers
Needs ReviewPublic

Authored by daniel_octaforge.org on Jun 29 2023, 4:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 2 2025, 1:15 PM
Unknown Object (File)
Nov 21 2025, 6:23 PM
Unknown Object (File)
Nov 19 2025, 3:47 AM
Unknown Object (File)
Nov 19 2025, 3:01 AM
Unknown Object (File)
Nov 19 2025, 12:33 AM
Unknown Object (File)
Nov 18 2025, 11:58 PM
Unknown Object (File)
Oct 29 2025, 2:09 AM
Unknown Object (File)
Oct 21 2025, 2:45 PM
Subscribers

Details

Reviewers
emaste
bapt
Summary

The previous behavior would unconditionally use the %g format
string by default, which resulted in all integers above 999999
being truncated and printed in exponent form.

As this behavior differs from GNU seq(1) and is not very useful
in most cases, perform additional checks for whether all three
given numbers are really integers (i.e. they do not truncate if
floored and their absolute value can be represented as an integer
within mantissa precision) and if that is the case, print the
whole sequence as if it was integers.

If any part requires floating point, the old behavior is still
followed. The existing behavior of zero-or-space padding is also
followed, merely adapting it for integer printing.

Additionally, for when we are in charge of the format string and
we know that no formatting truncation will happen, skip past the
workaround for last value of truncated prints in order to avoid
memory allocations, for more robust behavior.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped