Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Michael S Newsgroups: comp.lang.c Subject: Re: Something like string-streams existing in "C"? Date: Fri, 20 Dec 2024 13:00:56 +0200 Organization: A noiseless patient Spider Lines: 59 Message-ID: <20241220130056.000029e4@yahoo.com> References: <20241219114135.611@kylheku.com> <20241219220435.00001140@yahoo.com> <20241219140545.869@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Date: Fri, 20 Dec 2024 12:00:59 +0100 (CET) Injection-Info: dont-email.me; posting-host="cd72757de727eb0edb19146209da36f1"; logging-data="3577881"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hD8ntPZ6nI2Bqx7FXgrLt162YRzHKCUY=" Cancel-Lock: sha1:u7KXnHXZWdZ5EBIXpAJTwj2wGw8= X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32) Bytes: 2987 On Thu, 19 Dec 2024 23:14:17 -0300 Thiago Adams wrote: > Em 12/19/2024 7:06 PM, Kaz Kylheku escreveu: > > On 2024-12-19, Michael S wrote: =20 > >> On Thu, 19 Dec 2024 19:47:28 -0000 (UTC) > >> Kaz Kylheku <643-408-1753@kylheku.com> wrote: > >> =20 > >>> On 2024-12-19, BlueManedHawk > >>> wrote: =20 > >>>> The =E2=80=98asprintf=E2=80=99 subroutine is standardized by POSIX.1= -2024, > >>>> meaning that you can use it now and blame somebody else if it > >>>> doesn't work. If you =20 > >>> > >>> Regardless of how it is made visible, you can detect it via a > >>> compile test in a configure script, and provide your own if it > >>> wasn't found: > >>> > >>> #if !HAVE_ASPRINTF > >>> > >>> int asprintf(char **out, const char *fmt, ...) > >>> { > >>> ... // more or less trivial to implement using malloc, realloc > >>> and vsprintf =20 > >> > >> Don't you mean, vsnprintf ? =20 > >=20 > > That detail will become obvious when you try to implement it. > > =20 >=20 > I did on implementation in 2020 (not using it) >=20 > http://thradams.com/vadsprintf.html >=20 You mean, you don't use asprintf() that you implemented? That's understandable. The API is rather badly designed. Can be handy in toy examples, less so in production software. >=20 > The standard should have a string stream compatible with FILE because > - differently of asprintf - if cannot be implemented separately. >=20 What level of compatibility? IMHO, the level that makes sense is where compatibility excludes fopen, fclose and fflush. I.e. you have new functions, mem_fopen() and mem_fclose() and do not allow fflush(). Pluse, you add few more functions or macros for direct access to buffer.