15 Commits

Author SHA1 Message Date
Ariadne Conill
be8459e5fe libpkgconf: buffer: add pkgconf_buffer_escape
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2026-01-20 13:02:26 -08:00
Elizabeth Kiara Regina Ashford
f887c83082 buffer: Style fixes
Signed-off-by: Elizabeth Kiara Regina Ashford <elizabeth.jennifer.myers@gmail.com>
2026-01-17 17:06:02 -08:00
Elizabeth Kiara Regina Ashford
cceebf098f buffer: fix undefined behaviour in variable argument function
When arguments are passed through ..., the C standard mandates that char
is promoted to int (other types are promoted as well, but that's outside
the scope of this commit). This happens with any argument passed through
va_start as well. Therefore, the last argument before variable arguments
in C must be a promoted type. Otherwise, the behaviour is undefined
(probably fine on most ABIs, but stricter ABIs might break).

Signed-off-by: Elizabeth Kiara Regina Ashford <elizabeth.jennifer.myers@gmail.com>
2026-01-17 17:06:02 -08:00
Elizabeth Kiara Regina Ashford
97e2d0433e buffer: Add pkgconf_buffer_copy and pkgconf_buffer_contains_byte
Signed-off-by: Elizabeth Kiara Regina Ashford <elizabeth.jennifer.myers@gmail.com>
2026-01-17 17:06:02 -08:00
Ariadne Conill
8230b86da9 libpkgconf: buffer: add pkgconf_buffer_subst
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-29 19:52:57 -08:00
Ariadne Conill
db6bcbdcbe libpkgconf: buffer: add pkgconf_buffer_contains and pkgconf_buffer_match
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-27 15:07:50 -08:00
Ariadne Conill
def161ad50 libpkgconf: buffer: add pkgconf_buffer_append_vfmt
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-23 13:31:40 -08:00
Ariadne Conill
5f6681478e libpkgconf: buffer: add pkgconf_buffer_[v]join
This is a convenience function for combining multiple strings into a buffer
with a delimiter.

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-20 00:19:22 -08:00
Ariadne Conill
1fcc01aa4f libpkgconf: buffer: add pkgconf_buffer_fputs
This dumps a pkgconf_buffer_t to the given stdio FILE stream
with puts(3)-like semantics.

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-07 20:54:02 -08:00
Ariadne Conill
16cebd6262 libpkgconf: buffer: null out buffer references when freeing it
This allows for pkgconf_buffer_finalize() to reset a buffer, not simply free the
underlying resources.

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-02 11:26:12 -08:00
Ariadne Conill
0a3cd05bcd libpkgconf: buffer: add pkgconf_buffer_append_fmt
Roughly similar to asprintf(3) but with pkgconf_buffer.

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-02 10:38:24 -08:00
Ariadne Conill
75b57db562 libpkgconf: buffer: fix pkgconf_buffer_append
Previously, pkgconf_buffer_append would append a nul byte to the buffer
because buffer->end was set to include the nul byte added by pkgconf_strlcpy.

(Buffers internally are a multiple of PAGE_SIZE, so this was not a security problem.)

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-12-02 00:44:51 -08:00
Ariadne Conill
88258bd908
libpkgconf: buffer: round up buffer allocations to 4KB granules
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-02-04 16:31:01 -08:00
Ariadne Conill
83a2ae0434 libpkgconf: buffer: fix memory allocation logic, add push/trim byte functions
Fixes: 1001750 ("libpkgconf: add buffer management functions")
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-02-02 01:30:54 -08:00
Ariadne Conill
10017500ff libpkgconf: add buffer management functions
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2024-12-09 19:49:50 -08:00