Eliminate improper consts and allow standard version to override.
authorEric Andersen <andersen@codepoet.org>
Mon, 3 Sep 2001 19:17:48 +0000 (19:17 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 3 Sep 2001 19:17:48 +0000 (19:17 -0000)
busybox/include/libbb.h
busybox/libbb/dirname.c
busybox/libbb/libbb.h

index a7e38325b88115ffb76f6d3fa20f012a440e2d2f..30f0bb9a78563f707204f1c7dc701afbc97e1fb9 100644 (file)
@@ -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);
 
index 5f839945d3dd68e37a5e18ebd992a03538014f1a..df9a49daa77c9341d360ffe78b3e9d1ce5b24b92 100644 (file)
 #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;
@@ -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
index a7e38325b88115ffb76f6d3fa20f012a440e2d2f..30f0bb9a78563f707204f1c7dc701afbc97e1fb9 100644 (file)
@@ -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);