GNU bug report logs -
#69822
[PATCH] format-spec pads when it should only truncate
Previous Next
Reported by: Adam Porter <adam <at> alphapapa.net>
Date: Sat, 16 Mar 2024 02:30:02 UTC
Severity: normal
Tags: patch
Done: Adam Porter <adam <at> alphapapa.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Adam Porter [2024-03-15 21:28 -0500] wrote:
> Please see the attached patch which fixes a bug in `format-spec': that a format
> spec like "%>15t", which is intended to limit the width of a string to 15
> characters, would also pad a string less than that length to be that length.
In this format string, 15 is the 'width' (which controls padding), not
the 'precision' (which controls truncation).
To truncate beyond 15 without padding, specify a precision instead of a
width: "%>.15t".
So I'm not sure there's a bug here, or at least not the one you
describe.
What's not clear in the documentation is what happens when one specifies
< or > without an explicit precision, as in the example you give. I'm
guessing this was the source of confusion here. But I think this can be
addressed as a docfix. Or am I missing something?
Thanks,
--
Basil
This bug report was last modified 1 year and 56 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.