extern struct hostent *xgethostbyname(const char *name);
extern int create_icmp_socket(void);
-char *dirname (const char *path);
+char *dirname (char *path);
int make_directory (char *path, long mode, int flags);
#include <string.h>
#include "libbb.h"
-/* Return a string on the heap containing the directory component of PATH. */
+#if defined __UCLIBC__ || __GNU_LIBRARY___ < 5
-char *dirname(const char *path)
+/* Return a string containing the path name of the parent
+ * directory of PATH. */
+
+char *dirname(char *path)
{
- const char *s;
+ char *s;
/* Go to the end of the string. */
s = path + strlen(path) - 1;
s--;
if (s < path)
- return xstrdup (".");
- else
- return xstrndup (path, s - path + 1);
+ return ".";
+
+ s[1] = '\0';
+ return path;
}
+
+#endif
extern struct hostent *xgethostbyname(const char *name);
extern int create_icmp_socket(void);
-char *dirname (const char *path);
+char *dirname (char *path);
int make_directory (char *path, long mode, int flags);