On Thu, Apr 29, 2021 at 7:00 PM Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > On Thu, Apr 29, 2021 at 03:07:49PM +0200, Bartosz Golaszewski wrote: > > On Thu, Apr 29, 2021 at 1:23 PM Andy Shevchenko > > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > > On Thu, Apr 29, 2021 at 11:47:33AM +0200, Bartosz Golaszewski wrote: > > ... > > > > > +/* We don't have mkdtempat()... :( */ > > > > > > But we have tmpnam() / tmpnam_r(), why to reinvent it below? > > > > > > > Because of this: > > > > $man tmpnam_r > > ... > > The created pathname has a directory prefix P_tmpdir. > > ... > > > > And this: > > > > ./stdio.h:120:# define P_tmpdir "/tmp" > > Still you may advance the pointer by the length of P_tmpdir + 1. > > ... > > > > > + for (i = 0; i < num_names; i++) > > > > + written += snprintf(buf + written, size - written, > > > > + "\"%s\", ", names[i] ?: ""); > > > > + buf[size - 2] = '\0'; > > > > > > Dunno if you can use asprintf() and actually replace NULL by "" in the original > > > array. Ah, see you already using it somewhere else, why not here? > > > > > > > Not sure what you mean, we can't use asprintf() to create a composite > > string like what is needed here. Can you give me an example? > > I have got this after sending. Either you need to create a format string with > va_args, or do it manually. > > No can do, you can't create a va_list out of thin air. Bart > -- > With Best Regards, > Andy Shevchenko > >