libbb.h now includes ../busybox.h. This way, files in libbb that have
[oweals/busybox.git] / ls.c
diff --git a/ls.c b/ls.c
index 86691fdaf4b6d8a7dc7a052095b3758eae5eaf20..d24ba98663f12e2227d6ef4f0c6604a0a7f7b668 100644 (file)
--- a/ls.c
+++ b/ls.c
@@ -543,16 +543,16 @@ static struct dnode **list_dir(char *path)
        }
        while ((entry = readdir(dir)) != NULL) {
                /* are we going to list the file- it may be . or .. or a hidden file */
-               if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue;
-               if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue;
-               if ((entry->d_name[0] ==  '.') && !(disp_opts & DISP_HIDDEN)) continue;
+               if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
+                       continue;
+               if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
+                       continue;
+               if ((entry->d_name[0] ==  '.') && !(disp_opts & DISP_HIDDEN))
+                       continue;
                cur= (struct dnode *)xmalloc(sizeof(struct dnode));
-               cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1);
-               strcpy(cur->fullname, path);
-               if (cur->fullname[strlen(cur->fullname)-1] != '/')
-                       strcat(cur->fullname, "/");
-               cur->name= cur->fullname + strlen(cur->fullname);
-               strcat(cur->fullname, entry->d_name);
+               cur->fullname = concat_path_file(path, entry->d_name);
+               cur->name = cur->fullname +
+                               (strlen(cur->fullname) - strlen(entry->d_name));
                if (my_stat(cur))
                        continue;
                cur->next= dn;
@@ -626,7 +626,7 @@ static int list_single(struct dnode *dn)
                                column += 10;
                                break;
                        case LIST_NLINKS:
-                               printf("%4d ", dn->dstat.st_nlink);
+                               printf("%4ld ", (long)dn->dstat.st_nlink);
                                column += 10;
                                break;
                        case LIST_ID_NAME:
@@ -648,15 +648,18 @@ static int list_single(struct dnode *dn)
                                        printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
                                } else {
 #ifdef BB_FEATURE_HUMAN_READABLE
-                                       fprintf(stdout, "%9s ", make_human_readable_str(dn->dstat.st_size>>10,
-                                                               (ls_disp_hr==TRUE)? 0: 1));
-#else
+                                       if (ls_disp_hr==TRUE) {
+                                               fprintf(stdout, "%9s ", make_human_readable_str(
+                                                                       dn->dstat.st_size>>10, 0));
+                                       } else 
+#endif 
+                                       {
 #if _FILE_OFFSET_BITS == 64
-                                       printf("%9lld ", dn->dstat.st_size);
+                                               printf("%9lld ", (long long)dn->dstat.st_size);
 #else
-                                       printf("%9ld ", dn->dstat.st_size);
-#endif
+                                               printf("%9ld ", dn->dstat.st_size);
 #endif
+                                       }
                                }
                                column += 10;
                                break;