Some more patchelttes from Larry Doolittle.
[oweals/busybox.git] / du.c
diff --git a/du.c b/du.c
index 3f7621b3de2ac1972cb8502bd183a0e7b64fa526..3e4821a390010fa885d1a2937963f43eac2a025d 100644 (file)
--- a/du.c
+++ b/du.c
@@ -67,7 +67,6 @@ static void print_normal(long size, char *filename)
 static void print_summary(long size, char *filename)
 {
        if (du_depth == 1) {
-               printf("summary\n");
                print_normal(size, filename);
        }
 }
@@ -77,7 +76,6 @@ static long du(char *filename)
 {
        struct stat statbuf;
        long sum;
-       int len;
 
        if ((lstat(filename, &statbuf)) != 0) {
                perror_msg("%s", filename);
@@ -96,6 +94,7 @@ static long du(char *filename)
        if (S_ISDIR(statbuf.st_mode)) {
                DIR *dir;
                struct dirent *entry;
+               char *newfile;
 
                dir = opendir(filename);
                if (!dir) {
@@ -103,12 +102,11 @@ static long du(char *filename)
                        return 0;
                }
 
-               len = strlen(filename);
-               if (filename[len - 1] == '/')
-                       filename[--len] = '\0';
+               newfile = last_char_is(filename, '/');
+               if (newfile)
+                       *newfile = '\0';
 
                while ((entry = readdir(dir))) {
-                       char *newfile;
                        char *name = entry->d_name;
 
                        if ((strcmp(name, "..") == 0)
@@ -189,7 +187,7 @@ int du_main(int argc, char **argv)
        return status;
 }
 
-/* $Id: du.c,v 1.45 2001/04/25 05:39:18 andersen Exp $ */
+/* $Id: du.c,v 1.47 2001/05/07 22:49:43 andersen Exp $ */
 /*
 Local Variables:
 c-file-style: "linux"