mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 13:02:37 +07:00
There exist two possible basename functions, a xpg compliant one in libgen.h and a GLIBC exclusive one declared in string.h, that was previously also declared by musl libc. Both implementations are expecting different parameter types (`const char *` for GLIBC and `char *` for xpg) With the removal of the basename function from string.h in musl libc, we could only rely on the xpg implementation. Unfortunately, the xpg implementation of basename does modify the contents of whatever you put in it, even though that there really is no need for it. This is an issue in some cases, where we might want to get the basename of a read-only variable, e.g. a `const char *`, as trying to modify something read-only is undefined behavior. So in order to keep things consistent for us, we implement our own version of basename called `basenm`, that does not modify the passed argument.