From: René Scharfe Date: Wed, 14 Jun 2017 17:34:26 GMT Subject: Re: [BUG] add_again() off-by-one error in custom format Message-ID: <1d4c9a93-5061-96db-d8aa-e798948650dc@web.de> In-Reply-To: <20170613222445.15575-1-szeder.dev@gmail.com> Am 14.06.2017 um 00:24 schrieb SZEDER Gábor: > [sorry for double post, forgot the mailing list...] > > To throw in a fourth option, this one adjusts the expansions' cached > offsets when the magic makes it necessary. It's not necessary for > '%-', because it only makes a difference when the expansion is empty, > and in that case > > - add_again() doesn't consider it cached, > - and even if it did, the offset of a zero-length string wouldn't > matter. > > pretty.c | 32 +++++++++++++++++++++----------- > 1 file changed, 21 insertions(+), 11 deletions(-) There are other modifiers, e.g. try the format '%h%>(20)%h' -- its output is obviously wrong (contains control characters), even with your patch. We'd have to update the offsets for each placeholder that changes the output of others. I don't think that approach scales, alas. René