X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dus.git;a=blobdiff_plain;f=dus.c;h=780d36084a2a260f2d681dd0a9305ae6f0edfb39;hp=e00d3df9325222a459344b52d49e53594f44ae3f;hb=622f9a38a823a17f47dfcc2956a3b3606299d949;hpb=b2a5aa36454c6b0d66eb0f1451ac0e07aad3b242 diff --git a/dus.c b/dus.c index e00d3df..780d360 100644 --- a/dus.c +++ b/dus.c @@ -85,7 +85,7 @@ int ignore_entry(const char *name) { return strcmp(name, ".") == 0 || strcmp(name, "..") == 0 || - (ignore_dotfiles && name[0] == '.' && name[1] != '/'); + (ignore_dotfiles && name[0] == '.' && name[1] != '/'); } size_sum_t entry_size(const char *name) { @@ -395,7 +395,7 @@ static struct option long_options[] = { }; int main(int argc, char **argv) { - int c; + int c, l; struct entry_node *root; struct winsize win; @@ -449,8 +449,9 @@ int main(int argc, char **argv) { if (optind < argc) { while (optind < argc) { - if(argv[optind][strlen(argv[optind]) - 1] == '/') { - argv[optind][strlen(argv[optind]) - 1] = '\0'; + l = strlen(argv[optind]); + if(l > 0 && argv[optind][l - 1] == '/') { + argv[optind][l - 1] = '\0'; root = push_dir_content(argv[optind++], root); } else { root = push_entry(argv[optind++], root);