Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-06 Thread Johannes Sixt
Am 06.02.19 um 12:56 schrieb Johannes Schindelin: > On Tue, 5 Feb 2019, Johannes Sixt wrote: >> Am 05.02.19 um 12:06 schrieb Johannes Schindelin: >>> The real examples are much more mundane, and very different from what you >>> suspected, e.g. inserting the tag header before the tag message in >>>

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-06 Thread Johannes Schindelin
Hi Hannes, On Tue, 5 Feb 2019, Johannes Sixt wrote: > Am 05.02.19 um 12:06 schrieb Johannes Schindelin: > > The real examples are much more mundane, and very different from what you > > suspected, e.g. inserting the tag header before the tag message in > > `create_tag()` in `builtin/tag.c`. Basic

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-06 Thread Johannes Schindelin
Hi Junio, On Tue, 5 Feb 2019, Junio C Hamano wrote: > Johannes Schindelin writes: > > >> Thanks for finding it. This needs to be squashed into bfc3fe33 > >> ("strbuf.c: add `strbuf_insertf()` and `strbuf_vinsertf()`", > >> 2018-12-20)? > > > > Since you want to open that can of worms again, yo

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-05 Thread Johannes Sixt
Am 05.02.19 um 12:06 schrieb Johannes Schindelin: > The real examples are much more mundane, and very different from what you > suspected, e.g. inserting the tag header before the tag message in > `create_tag()` in `builtin/tag.c`. Basically, it is building up a strbuf > for the sake of calling `st

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-05 Thread Junio C Hamano
Johannes Schindelin writes: > Or that they are read with a fine toothed comb, but that the focus lies > more on style and maintainability than correctness. We talked about this > in the past. Perhaps we can do better the next time, then. I find unreadable code is impossible to reason about its

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-05 Thread Johannes Schindelin
Hi Junio, On Mon, 4 Feb 2019, Junio C Hamano wrote: > Johannes Sixt writes: > > > strbuf_vinsertf inserts a formatted string in the middle of an existing > > strbuf value. It makes room in the strbuf by moving existing string to > > the back, then formats the string to insert directly into the

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-05 Thread Johannes Schindelin
Hi Hannes, On Mon, 4 Feb 2019, Johannes Sixt wrote: > Am 04.02.19 um 11:38 schrieb Johannes Schindelin: > > On Mon, 4 Feb 2019, Johannes Sixt wrote: > > > >> Am 03.02.19 um 17:51 schrieb Johannes Sixt: > >>> strbuf_vinsertf inserts a formatted string in the middle of an existing > >>> strbuf val

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-04 Thread Junio C Hamano
Johannes Sixt writes: > strbuf_vinsertf inserts a formatted string in the middle of an existing > strbuf value. It makes room in the strbuf by moving existing string to > the back, then formats the string to insert directly into the hole. > > It uses vsnprintf to format the string. The buffer siz

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-04 Thread Johannes Sixt
Am 04.02.19 um 11:38 schrieb Johannes Schindelin: > On Mon, 4 Feb 2019, Johannes Sixt wrote: > >> Am 03.02.19 um 17:51 schrieb Johannes Sixt: >>> strbuf_vinsertf inserts a formatted string in the middle of an existing >>> strbuf value. >> >> Quite frankly, this is a really unusual operation, and I

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-04 Thread Johannes Schindelin
Hi Hannes, On Sun, 3 Feb 2019, Johannes Sixt wrote: > strbuf_vinsertf inserts a formatted string in the middle of an existing > strbuf value. It makes room in the strbuf by moving existing string to > the back, then formats the string to insert directly into the hole. > > It uses vsnprintf to fo

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-04 Thread Johannes Schindelin
Hi Hannes, On Mon, 4 Feb 2019, Johannes Sixt wrote: > Am 03.02.19 um 17:51 schrieb Johannes Sixt: > > strbuf_vinsertf inserts a formatted string in the middle of an existing > > strbuf value. > > Quite frankly, this is a really unusual operation, and I'd prefer to get > rid of it. There is only

Re: [PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-03 Thread Johannes Sixt
Am 03.02.19 um 17:51 schrieb Johannes Sixt: > strbuf_vinsertf inserts a formatted string in the middle of an existing > strbuf value. Quite frankly, this is a really unusual operation, and I'd prefer to get rid of it. There is only one call, and it looks like it only wants to be lazy and save one

[PATCH ps/stash-in-c] strbuf_vinsertf: provide the correct buffer size to vsnprintf

2019-02-03 Thread Johannes Sixt
strbuf_vinsertf inserts a formatted string in the middle of an existing strbuf value. It makes room in the strbuf by moving existing string to the back, then formats the string to insert directly into the hole. It uses vsnprintf to format the string. The buffer size provided in the invocation is t