Currently all compat.h does is define the appropriate POSIX macro unless
you are on windows, as well as conditionally enabling
__attribute__(format...).
There are lots of places in muon where we want to manipulate strings.
In some cases it is appropriate to use the make_str() + str_app()
method. However, in other cases, it would be better to avoid
allocation.
The solution so far has been to write specialized buffer functions that
append a buffer and check that it doesn't overflow, etc., for every
different case. Sometimes these buffers can grow with realloc,
sometimes they are static only.
sbuf is a sort of compromise. It starts out with a stack allocated
static array that is somewhat small, and can be configured to overflow
into either an unmanaged allocation, or into the workspace string pool.
Some other nice features include a mode that transparently writes output
to a FILE * rather than a buffer, which means that there is no longer a
limit on the length obj_fprintf can output.
The plan is to change the signature of the path_ functions to use sbuf
rather than a buffer + length. That means we can finally get away from
PATH_MAX everywhere.
Strings were originally indices into an array of chars. This was
eventually refactored to an array of `str` structs to allow strings to
contain null bytes. This intermediate array mapping objects to strings
was actually unnecessary, and this commit removes it.
In muon strings were represented as C strings internally. In Meson, strings
are python strings, which notably are allowed to contain null bytes. In
order to be compatible string handling needed to be rewritten. Use this
opportunity also to allow handling larger strings, and pushing strings
without invalidating others.