libiberty: add ldirname function

This patch adds a function ldirname to libiberty.  It is implemented
in terms of lbasename.  Basically, given a given pathname, the dirname
part is what is not the basename minus the last directory separator
separating the dirname with the basename.

include/ChangeLog

	* libiberty.h (ldirname): New function declaration.
	(dos_ldirname): Likewise.
	(unix_ldirname): Likewise.

libiberty/ChangeLog

	* ldirname.c: New file.
	* Makefile.in (CFILES): Add ldirname.c.
	(REQUIRED_OFILES): Add ldirname.$(objext).
	(./ldirname.$(objext)): New rule.
	* makefile.vms (OBJS): Add ldirname.obj.
	* configure.com (FILES): Add ldirname.
This commit is contained in:
Jose E. Marchesi
2025-03-17 12:47:40 +01:00
parent 7865869b44
commit 31dd621796
5 changed files with 121 additions and 3 deletions

View File

@@ -133,6 +133,18 @@ extern const char *dos_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIB
extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
/* A dirname () that is always compiled in. */
extern char *ldirname (const char *) ATTRIBUTE_NONNULL(1);
/* Same, but assumes DOS semantics regardless of host. */
extern char *dos_ldirname (const char *) ATTRIBUTE_NONNULL(1);
/* Same, but assumes Unix semantics regardless of host. */
extern char *unix_ldirname (const char *) ATTRIBUTE_NONNULL(1);
/* A well-defined realpath () that is always compiled in. */
extern char *lrealpath (const char *);