Closed
Conversation
This header exists in glibc, but otherwise isn't particularly portable. For example it doesn't exist in musl-libc. Fortunately, it isn't actually needed.
The basename(3) manpage states:
There are two different versions of basename() - the POSIX version
described above, and the GNU version, which one gets after
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
The GNU version never modifies its argument, and returns the empty
string when path has a trailing slash, and in particular also when it
is "/". There is no GNU version of dirname().
With glibc, one gets the POSIX version of basename() when <libgen.h> is
included, and the GNU version otherwise.
Using the POSIX version is more portable: For example, musl-libc only
implements the POSIX version and not the GNU version.
Regarding memory management, basename(3) says:
These functions may return pointers to statically allocated memory
which may be overwritten by subsequent calls. Alternatively, they may
return a pointer to some part of path, so that the string referred to
by path should not be modified or freed until the pointer returned by
the function is no longer required.
Owner
|
It's 2AM here and I can't verify this tonight. Would review this later. |
7Ji
reviewed
Mar 4, 2025
Owner
There was a problem hiding this comment.
Yes this should be removed, I didn't require the header. It was probably added by clangd by accident in 0fa8598
7Ji
added a commit
that referenced
this pull request
Mar 4, 2025
closes #23 Co-authored-by: J. Neuschäfer <j.ne@posteo.net>
Contributor
Author
|
Thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is slightly more complex, but makes it possible to build ampart on musl-libc-based systems such as Alpine Linux