Subject: Re: Printf builtin missing v flag support
From: Bart Schaefer <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Fri, 1 Jan 2016 20:17:24 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Jan 1, 11:12pm, Sebastian Gniazdowski wrote:
} Subject: Re: Printf builtin missing v flag support
}
} On 1 January 2016 at 22:52, Bart Schaefer <[email-masked]> wrote:
} >
} > To make it work with -x, -X, -C, etc. would require moving the memstream
} > code to the top of the function, plus some related fiddling around later.
} 
} Could you implement that? The move of memstream code seems like a
} cleanup, print would have full control of whether do memstream or not.

I looked at it, but it's more messy than I thought, because the printf
branch keeps a running count of the number of bytes printed, which is
then needed for handling the result.  No sub-part of the print branch
maintains that byte count, so a lot of fiddly little changes are needed.

Also the print branch does some extra work to detect write errors on
redirection -- which it looks like might actually be buggy in the
-z/-s case when HAVE_OPEN_MEMSTREAM is not defined, and which have to
be rewritten for the -v case -- so this is not going to happen quickly.