From 3cba82678b139965fc37a277c6162a9e2795679f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 3 Sep 2001 19:17:48 +0000 Subject: [PATCH] Eliminate improper consts and allow standard version to override. --- busybox/include/libbb.h | 2 +- busybox/libbb/dirname.c | 18 ++++++++++++------ busybox/libbb/libbb.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/busybox/include/libbb.h b/busybox/include/libbb.h index a7e38325b..30f0bb9a7 100644 --- a/busybox/include/libbb.h +++ b/busybox/include/libbb.h @@ -259,7 +259,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid); 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); diff --git a/busybox/libbb/dirname.c b/busybox/libbb/dirname.c index 5f839945d..df9a49daa 100644 --- a/busybox/libbb/dirname.c +++ b/busybox/libbb/dirname.c @@ -22,11 +22,14 @@ #include #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; @@ -43,7 +46,10 @@ char *dirname(const char *path) s--; if (s < path) - return xstrdup ("."); - else - return xstrndup (path, s - path + 1); + return "."; + + s[1] = '\0'; + return path; } + +#endif diff --git a/busybox/libbb/libbb.h b/busybox/libbb/libbb.h index a7e38325b..30f0bb9a7 100644 --- a/busybox/libbb/libbb.h +++ b/busybox/libbb/libbb.h @@ -259,7 +259,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid); 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); -- 2.25.1