bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'string-buffer'


From: Bruno Haible
Subject: new module 'string-buffer'
Date: Sun, 21 Feb 2021 21:55:02 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-201-generic; KDE/5.18.0; x86_64; ; )

What alternative does gnulib offer to people who use open_memstream()?
open_memstream is not portable:
  https://www.gnu.org/software/gnulib/manual/html_node/open_005fmemstream.html
But gnulib cannot provide a drop-in replacement since it would require
unportable stream hackery (worse that stdio-impl.h).

The alternative is a string buffer module. Gnulib has some modules that
sound good at first sight but don't fulfil the need:
  * scratch_buffer stores only one size_t in the struct; it requires
    the program to keep track how much of the buffer is already occupied.
    Also it does not have printf-like formatting.
  * dynarray: Likewise.
  * line-buffer: Has the right members in the struct. But lacks piecewise
    accumulation functions.
  * obstack: Does not have printf-like formatting. Also lacks a
    "small strings are stack allocated" optimization.

So, I'm adding one that fulfils that need.


2021-02-21  Bruno Haible  <bruno@clisp.org>

        string-buffer: Add tests.
        * tests/test-string-buffer.c: New file.
        * modules/string-buffer-tests: New file.

        string-buffer: New module.
        * lib/string-buffer.h: New file.
        * lib/string-buffer.c: New file.
        * modules/string-buffer: New file.
        * doc/posix-functions/open_memstream.texi: Mention the new module.

Attachment: 0001-string-buffer-New-module.patch
Description: Text Data

Attachment: 0002-string-buffer-Add-tests.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]