git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15592 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
aecddb8a9e
commit
b6aa2da1b4
|
@ -37,12 +37,20 @@ static bool qflg = false;
|
||||||
|
|
||||||
struct afile {
|
struct afile {
|
||||||
char ftype;
|
char ftype;
|
||||||
|
long fnum;
|
||||||
short fnlink;
|
short fnlink;
|
||||||
mode_t fflags;
|
mode_t fflags;
|
||||||
off_t fsize;
|
off_t fsize;
|
||||||
char *fname;
|
char *fname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ISARG 0x8000 /* extra ``mode'' */
|
||||||
|
|
||||||
|
struct subdirs {
|
||||||
|
char *sd_name;
|
||||||
|
struct subdirs *sd_next;
|
||||||
|
} *subdirs;
|
||||||
|
|
||||||
static void usage(void) {
|
static void usage(void) {
|
||||||
fprintf(stderr, "Usage: ls [<opts>] [<file>]..." NEWLINE_STR);
|
fprintf(stderr, "Usage: ls [<opts>] [<file>]..." NEWLINE_STR);
|
||||||
fprintf(stderr, "Options:" NEWLINE_STR);
|
fprintf(stderr, "Options:" NEWLINE_STR);
|
||||||
|
@ -416,8 +424,8 @@ static void formatd(char *name, int title) {
|
||||||
for (fp = dfp0; fp < dfplast; fp++) {
|
for (fp = dfp0; fp < dfplast; fp++) {
|
||||||
if ((fp->fflags & ISARG) == 0 && fp->fname)
|
if ((fp->fflags & ISARG) == 0 && fp->fname)
|
||||||
free(fp->fname);
|
free(fp->fname);
|
||||||
if (fp->flinkto)
|
// if (fp->flinkto)
|
||||||
free(fp->flinkto);
|
// free(fp->flinkto);
|
||||||
}
|
}
|
||||||
free((char*)dfp0);
|
free((char*)dfp0);
|
||||||
}
|
}
|
||||||
|
@ -485,16 +493,17 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||||
|
|
||||||
/* Allocating a single big buffer for all files.*/
|
/* Allocating a single big buffer for all files.*/
|
||||||
bufp = calloc(argc, sizeof (struct afile));
|
bufp = calloc(argc, sizeof (struct afile));
|
||||||
fp0 = (struct afile *)bufp;
|
fp = (struct afile *)bufp;
|
||||||
if (bufp == NULL) {
|
if (bufp == NULL) {
|
||||||
error("out of memory");
|
error("out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scanning all arguments and populating the array.*/
|
/* Scanning all arguments and populating the array.*/
|
||||||
fp = fp0;
|
fp0 = fp;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (!gstat(fp, *argv, true)) {
|
if (!gstat(fp, *argv, true)) {
|
||||||
fp->fname = *argv;
|
fp->fname = *argv;
|
||||||
|
fp->fflags |= ISARG;
|
||||||
fp++;
|
fp++;
|
||||||
}
|
}
|
||||||
argv++;
|
argv++;
|
||||||
|
|
Loading…
Reference in New Issue