};
typedef struct dnode dnode_t;
-struct dnode **list_dir(char *);
-struct dnode **dnalloc(int);
-int list_single(struct dnode *);
+static struct dnode **list_dir(char *);
+static struct dnode **dnalloc(int);
+static int list_single(struct dnode *);
static unsigned int disp_opts;
static unsigned int style_fmt;
static int status = EXIT_SUCCESS;
#ifdef BB_FEATURE_HUMAN_READABLE
-unsigned long ls_disp_hr = KILOBYTE;
+static unsigned long ls_disp_hr = 0;
#endif
static int my_stat(struct dnode *cur)
strcmp(dn->name, "..") != 0);
}
-int countdirs(struct dnode **dn, int nfiles)
+static int countdirs(struct dnode **dn, int nfiles)
{
int i, dirs;
return(dirs);
}
-int countsubdirs(struct dnode **dn, int nfiles)
+static int countsubdirs(struct dnode **dn, int nfiles)
{
int i, subdirs;
return subdirs;
}
-int countfiles(struct dnode **dnp)
+static int countfiles(struct dnode **dnp)
{
int nfiles;
struct dnode *cur;
}
/* get memory to hold an array of pointers */
-struct dnode **dnalloc(int num)
+static struct dnode **dnalloc(int num)
{
struct dnode **p;
return(p);
}
-void dfree(struct dnode **dnp)
+static void dfree(struct dnode **dnp)
{
struct dnode *cur, *next;
free(dnp); /* free the array holding the dnode pointers */
}
-struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
+static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
{
int dncnt, i, d;
struct dnode **dnp;
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_SORTFILES
-int sortcmp(struct dnode *d1, struct dnode *d2)
+static int sortcmp(struct dnode *d1, struct dnode *d2)
{
int cmp, dif;
}
/*----------------------------------------------------------------------*/
-void shellsort(struct dnode **dn, int size)
+static void shellsort(struct dnode **dn, int size)
{
struct dnode *temp;
int gap, i, j;
#endif
/*----------------------------------------------------------------------*/
-void showfiles(struct dnode **dn, int nfiles)
+static void showfiles(struct dnode **dn, int nfiles)
{
int i, ncols, nrows, row, nc;
#ifdef BB_FEATURE_AUTOWIDTH
}
/*----------------------------------------------------------------------*/
-void showdirs(struct dnode **dn, int ndirs)
+static void showdirs(struct dnode **dn, int ndirs)
{
int i, nfiles;
struct dnode **subdnp;
}
/*----------------------------------------------------------------------*/
-struct dnode **list_dir(char *path)
+static struct dnode **list_dir(char *path)
{
struct dnode *dn, *cur, **dnp;
struct dirent *entry;
}
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;
}
/*----------------------------------------------------------------------*/
-int list_single(struct dnode *dn)
+static int list_single(struct dnode *dn)
{
int i, len;
char scratch[BUFSIZ + 1];
break;
case LIST_BLOCKS:
#ifdef BB_FEATURE_HUMAN_READABLE
- fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, 1));
+ fprintf(stdout, "%5s ", make_human_readable_str(dn->dstat.st_blocks>>1,
+ (ls_disp_hr==TRUE)? 0: 1));
#else
#if _FILE_OFFSET_BITS == 64
printf("%4lld ", dn->dstat.st_blocks>>1);
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:
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#ifdef BB_FEATURE_HUMAN_READABLE
- fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr));
-#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>>1);
+ printf("%9lld ", (long long)dn->dstat.st_size);
#else
- printf("%9ld ", dn->dstat.st_size>>1);
-#endif
+ printf("%9ld ", dn->dstat.st_size);
#endif
+ }
}
column += 10;
break;
style_fmt = STYLE_LONG;
list_fmt |= LIST_LONG;
#ifdef BB_FEATURE_HUMAN_READABLE
- ls_disp_hr = 1;
+ ls_disp_hr = FALSE;
#endif
break;
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
case 'w': terminal_width= atoi(optarg); break;
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
- case 'h': ls_disp_hr = 0; break;
+ case 'h': ls_disp_hr = TRUE; break;
#endif
case 'k': break;
default: