Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Printf builtin missing v flag support



On Jan 2,  8:17am, Sebastian Gniazdowski wrote:
}
} Maybe one other way is available - instead of moving memstream to the
} top, moving -X/x above memstream?

It's not that simple (and anyway it would be moving -X/-x down).  The
code is structured like

    do expansion for -P/-D
    do sorting for -o/-O
    if (not -z or -s [added: or -v])
       change output stream for -p or -u
    if (there is no format string) {
       if (-c/-C) {
          do columnation
	  test for write error
          return
       }
       if (-z or -s [added: or -v]) {
          copy argument list into data structure
          return
       }
       do -x/-X or -l/-N
       test for write error
       return
    }

    if (-z or -s [added: or -v])
       set up memstream [or tempfile if memstream not supported]

    do all the printf stuff
    if (there was a memstream)
       copy the memstream [or tempfile] into data structure

The two largest problems are that -x/-X are implemented by a function
that writes directly to a stdio object without keeping track of the
number of bytes written (needed for the "copy" step), and that the
test for write error is structured in a way incompatible with the
maybe-memstream-or-maybe-tempfile compile-time conditional.

Also it would be sort of annoying/inconsistent to have -v work with -x
but not with -c or -l.  -N is an oddball, I don't even know what to do
with that one; would we want a parameter value with embedded NULs?

Having written that out, it looks like there might be bugs with using
all off -u/-p plus -z/-s/-v plus -c/-C.  Haven't actually tried.  There
might also be bugs with printf-ing of NUL bytes into the memstream.



Messages sorted by: Reverse Date, Date, Thread, Author