aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-04-23 01:07:00 +0000
committerMatt Kraai <kraai@debian.org>2001-04-23 01:07:00 +0000
commit782ab3ccf85360e86e4559aff51bd1e8ca38b36a (patch)
treecfb9f9c8bac1f4a67ec2089c86d971284b375578
parentee0d93ed04b608ae128ac18c89f0057eb0eb5ee4 (diff)
downloadbusybox-w32-782ab3ccf85360e86e4559aff51bd1e8ca38b36a.tar.gz
busybox-w32-782ab3ccf85360e86e4559aff51bd1e8ca38b36a.tar.bz2
busybox-w32-782ab3ccf85360e86e4559aff51bd1e8ca38b36a.zip
Simplify pathname building, in which a bug was noted by Larry Doolittle,
a patch was provided by Vladimir Oleynik, and am improved patch commited by me.
-rw-r--r--coreutils/ls.c18
-rw-r--r--ls.c18
2 files changed, 18 insertions, 18 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 8f4cae10d..d24ba9866 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -543,16 +543,16 @@ static struct dnode **list_dir(char *path)
543 } 543 }
544 while ((entry = readdir(dir)) != NULL) { 544 while ((entry = readdir(dir)) != NULL) {
545 /* are we going to list the file- it may be . or .. or a hidden file */ 545 /* are we going to list the file- it may be . or .. or a hidden file */
546 if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue; 546 if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
547 if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue; 547 continue;
548 if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue; 548 if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
549 continue;
550 if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN))
551 continue;
549 cur= (struct dnode *)xmalloc(sizeof(struct dnode)); 552 cur= (struct dnode *)xmalloc(sizeof(struct dnode));
550 cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1); 553 cur->fullname = concat_path_file(path, entry->d_name);
551 strcpy(cur->fullname, path); 554 cur->name = cur->fullname +
552 if (cur->fullname[strlen(cur->fullname)-1] != '/') 555 (strlen(cur->fullname) - strlen(entry->d_name));
553 strcat(cur->fullname, "/");
554 cur->name= cur->fullname + strlen(cur->fullname);
555 strcat(cur->fullname, entry->d_name);
556 if (my_stat(cur)) 556 if (my_stat(cur))
557 continue; 557 continue;
558 cur->next= dn; 558 cur->next= dn;
diff --git a/ls.c b/ls.c
index 8f4cae10d..d24ba9866 100644
--- a/ls.c
+++ b/ls.c
@@ -543,16 +543,16 @@ static struct dnode **list_dir(char *path)
543 } 543 }
544 while ((entry = readdir(dir)) != NULL) { 544 while ((entry = readdir(dir)) != NULL) {
545 /* are we going to list the file- it may be . or .. or a hidden file */ 545 /* are we going to list the file- it may be . or .. or a hidden file */
546 if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue; 546 if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
547 if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue; 547 continue;
548 if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue; 548 if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
549 continue;
550 if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN))
551 continue;
549 cur= (struct dnode *)xmalloc(sizeof(struct dnode)); 552 cur= (struct dnode *)xmalloc(sizeof(struct dnode));
550 cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1); 553 cur->fullname = concat_path_file(path, entry->d_name);
551 strcpy(cur->fullname, path); 554 cur->name = cur->fullname +
552 if (cur->fullname[strlen(cur->fullname)-1] != '/') 555 (strlen(cur->fullname) - strlen(entry->d_name));
553 strcat(cur->fullname, "/");
554 cur->name= cur->fullname + strlen(cur->fullname);
555 strcat(cur->fullname, entry->d_name);
556 if (my_stat(cur)) 556 if (my_stat(cur))
557 continue; 557 continue;
558 cur->next= dn; 558 cur->next= dn;