aboutsummaryrefslogtreecommitdiff
path: root/du.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-07 22:49:43 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-07 22:49:43 +0000
commitcc6a9ff8318468123a107e9c3c13c0b12a2e4c19 (patch)
tree3459f582185256f84a7aa9c9e9953267f93e8684 /du.c
parent85caa0d1cf94b166d06ea575e214de759b3784c2 (diff)
downloadbusybox-w32-cc6a9ff8318468123a107e9c3c13c0b12a2e4c19.tar.gz
busybox-w32-cc6a9ff8318468123a107e9c3c13c0b12a2e4c19.tar.bz2
busybox-w32-cc6a9ff8318468123a107e9c3c13c0b12a2e4c19.zip
Patch from Vladimir to use last_char_is to simplify du.c
git-svn-id: svn://busybox.net/trunk/busybox@2563 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'du.c')
-rw-r--r--du.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/du.c b/du.c
index b618e0760..3e4821a39 100644
--- a/du.c
+++ b/du.c
@@ -76,7 +76,6 @@ static long du(char *filename)
76{ 76{
77 struct stat statbuf; 77 struct stat statbuf;
78 long sum; 78 long sum;
79 int len;
80 79
81 if ((lstat(filename, &statbuf)) != 0) { 80 if ((lstat(filename, &statbuf)) != 0) {
82 perror_msg("%s", filename); 81 perror_msg("%s", filename);
@@ -95,6 +94,7 @@ static long du(char *filename)
95 if (S_ISDIR(statbuf.st_mode)) { 94 if (S_ISDIR(statbuf.st_mode)) {
96 DIR *dir; 95 DIR *dir;
97 struct dirent *entry; 96 struct dirent *entry;
97 char *newfile;
98 98
99 dir = opendir(filename); 99 dir = opendir(filename);
100 if (!dir) { 100 if (!dir) {
@@ -102,12 +102,11 @@ static long du(char *filename)
102 return 0; 102 return 0;
103 } 103 }
104 104
105 len = strlen(filename); 105 newfile = last_char_is(filename, '/');
106 if (filename[len - 1] == '/') 106 if (newfile)
107 filename[--len] = '\0'; 107 *newfile = '\0';
108 108
109 while ((entry = readdir(dir))) { 109 while ((entry = readdir(dir))) {
110 char *newfile;
111 char *name = entry->d_name; 110 char *name = entry->d_name;
112 111
113 if ((strcmp(name, "..") == 0) 112 if ((strcmp(name, "..") == 0)
@@ -188,7 +187,7 @@ int du_main(int argc, char **argv)
188 return status; 187 return status;
189} 188}
190 189
191/* $Id: du.c,v 1.46 2001/05/03 04:45:40 kraai Exp $ */ 190/* $Id: du.c,v 1.47 2001/05/07 22:49:43 andersen Exp $ */
192/* 191/*
193Local Variables: 192Local Variables:
194c-file-style: "linux" 193c-file-style: "linux"