Skip to content

Commit

Permalink
xdu.c: correctly parse output from du
Browse files Browse the repository at this point in the history
Former version would also take leading numbers
from du records.
(Closes github issue #26)
thomas committed Jul 9, 2021
1 parent e8e1863 commit d7f8c84
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions xdu.c
Original file line number Diff line number Diff line change
@@ -300,10 +300,8 @@ static void parse_file(char* filename)
*/
sscanf(buf, "%lld", &size);
buff = buf;
while ((*buff >= '0' && *buff <= '9')
|| (*buff == ' ' || *buff == '\t')) {
buff++;
}
while (*buff != ' ' && *buff != '\t') { buff++; }
while (*buff == ' ' || *buff == '\t') { buff++; }
strncpy(name, buff, strlen(buff) - 1);
name[strlen(buff) - 1] = '\0';
/*

0 comments on commit d7f8c84

Please sign in to comment.