diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-22 18:13:54 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-22 18:13:54 +0000 |
commit | e3906fcd94f9ec7e58337d4241f6ffa95e4fd847 (patch) | |
tree | e28fc10fa80e6ab55f21794e3ee5ca9d976d3cad | |
parent | 99b12543cf14681d32d4d3a57695458dadc89baf (diff) | |
download | busybox-w32-e3906fcd94f9ec7e58337d4241f6ffa95e4fd847.tar.gz busybox-w32-e3906fcd94f9ec7e58337d4241f6ffa95e4fd847.tar.bz2 busybox-w32-e3906fcd94f9ec7e58337d4241f6ffa95e4fd847.zip |
Run through indent, fix BB_ define
-rw-r--r-- | coreutils/ls.c | 796 |
1 files changed, 441 insertions, 355 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 0c2cea199..344f8ffcb 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -42,9 +42,9 @@ | |||
42 | */ | 42 | */ |
43 | 43 | ||
44 | enum { | 44 | enum { |
45 | TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */ | 45 | TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */ |
46 | COLUMN_WIDTH = 14, /* default if AUTOWIDTH not defined */ | 46 | COLUMN_WIDTH = 14, /* default if AUTOWIDTH not defined */ |
47 | COLUMN_GAP = 2, /* includes the file type char */ | 47 | COLUMN_GAP = 2, /* includes the file type char */ |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
@@ -76,10 +76,10 @@ enum { | |||
76 | 76 | ||
77 | /* what is the overall style of the listing */ | 77 | /* what is the overall style of the listing */ |
78 | enum { | 78 | enum { |
79 | STYLE_AUTO = 0, | 79 | STYLE_AUTO = 0, |
80 | STYLE_LONG = 1, /* one record per line, extended info */ | 80 | STYLE_LONG = 1, /* one record per line, extended info */ |
81 | STYLE_SINGLE = 2, /* one record per line */ | 81 | STYLE_SINGLE = 2, /* one record per line */ |
82 | STYLE_COLUMNS = 3 /* fill columns */ | 82 | STYLE_COLUMNS = 3 /* fill columns */ |
83 | }; | 83 | }; |
84 | 84 | ||
85 | /* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */ | 85 | /* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */ |
@@ -100,7 +100,7 @@ STYLE_COLUMNS = 3 /* fill columns */ | |||
100 | #define LIST_EXEC (1<<13) | 100 | #define LIST_EXEC (1<<13) |
101 | 101 | ||
102 | /* what files will be displayed */ | 102 | /* what files will be displayed */ |
103 | #define DISP_NORMAL (0) /* show normal filenames */ | 103 | #define DISP_NORMAL (0) /* show normal filenames */ |
104 | #define DISP_DIRNAME (1<<0) /* 2 or more items? label directories */ | 104 | #define DISP_DIRNAME (1<<0) /* 2 or more items? label directories */ |
105 | #define DISP_HIDDEN (1<<1) /* show filenames starting with . */ | 105 | #define DISP_HIDDEN (1<<1) /* show filenames starting with . */ |
106 | #define DISP_DOT (1<<2) /* show . and .. */ | 106 | #define DISP_DOT (1<<2) /* show . and .. */ |
@@ -110,16 +110,16 @@ STYLE_COLUMNS = 3 /* fill columns */ | |||
110 | 110 | ||
111 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 111 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
112 | /* how will the files be sorted */ | 112 | /* how will the files be sorted */ |
113 | static const int SORT_FORWARD = 0; /* sort in reverse order */ | 113 | static const int SORT_FORWARD = 0; /* sort in reverse order */ |
114 | static const int SORT_REVERSE = 1; /* sort in reverse order */ | 114 | static const int SORT_REVERSE = 1; /* sort in reverse order */ |
115 | static const int SORT_NAME = 2; /* sort by file name */ | 115 | static const int SORT_NAME = 2; /* sort by file name */ |
116 | static const int SORT_SIZE = 3; /* sort by file size */ | 116 | static const int SORT_SIZE = 3; /* sort by file size */ |
117 | static const int SORT_ATIME = 4; /* sort by last access time */ | 117 | static const int SORT_ATIME = 4; /* sort by last access time */ |
118 | static const int SORT_CTIME = 5; /* sort by last change time */ | 118 | static const int SORT_CTIME = 5; /* sort by last change time */ |
119 | static const int SORT_MTIME = 6; /* sort by last modification time */ | 119 | static const int SORT_MTIME = 6; /* sort by last modification time */ |
120 | static const int SORT_VERSION = 7; /* sort by version */ | 120 | static const int SORT_VERSION = 7; /* sort by version */ |
121 | static const int SORT_EXT = 8; /* sort by file name extension */ | 121 | static const int SORT_EXT = 8; /* sort by file name extension */ |
122 | static const int SORT_DIR = 9; /* sort by file or directory */ | 122 | static const int SORT_DIR = 9; /* sort by file or directory */ |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 125 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
@@ -129,12 +129,11 @@ static const int TIME_CHANGE = 1; | |||
129 | static const int TIME_ACCESS = 2; | 129 | static const int TIME_ACCESS = 2; |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #define LIST_SHORT (LIST_FILENAME) | 132 | #define LIST_SHORT (LIST_FILENAME) |
133 | #define LIST_ISHORT (LIST_INO | LIST_FILENAME) | 133 | #define LIST_ISHORT (LIST_INO | LIST_FILENAME) |
134 | #define LIST_LONG (LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | \ | 134 | #define LIST_LONG (LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | LIST_SIZE | \ |
135 | LIST_SIZE | LIST_DATE_TIME | LIST_FILENAME | \ | 135 | LIST_DATE_TIME | LIST_FILENAME | LIST_SYMLINK) |
136 | LIST_SYMLINK) | 136 | #define LIST_ILONG (LIST_INO | LIST_LONG) |
137 | #define LIST_ILONG (LIST_INO | LIST_LONG) | ||
138 | 137 | ||
139 | static const int SPLIT_DIR = 0; | 138 | static const int SPLIT_DIR = 0; |
140 | static const int SPLIT_FILE = 1; | 139 | static const int SPLIT_FILE = 1; |
@@ -142,26 +141,29 @@ static const int SPLIT_SUBDIR = 2; | |||
142 | 141 | ||
143 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) | 142 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) |
144 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) | 143 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) |
144 | |||
145 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) | 145 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) |
146 | #define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) | 146 | # define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) |
147 | #endif | 147 | #endif |
148 | |||
148 | /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */ | 149 | /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */ |
149 | #ifdef CONFIG_FEATURE_LS_COLOR | 150 | #ifdef CONFIG_FEATURE_LS_COLOR |
150 | static int show_color = 0; | 151 | static int show_color = 0; |
151 | #define COLOR(mode) ("\000\043\043\043\042\000\043\043"\ | 152 | |
152 | "\000\000\044\000\043\000\000\040" [TYPEINDEX(mode)]) | 153 | #define COLOR(mode) ("\000\043\043\043\042\000\043\043"\ |
153 | #define ATTR(mode) ("\00\00\01\00\01\00\01\00"\ | 154 | "\000\000\044\000\043\000\000\040" [TYPEINDEX(mode)]) |
154 | "\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)]) | 155 | #define ATTR(mode) ("\00\00\01\00\01\00\01\00"\ |
156 | "\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)]) | ||
155 | #endif | 157 | #endif |
156 | 158 | ||
157 | /* | 159 | /* |
158 | * a directory entry and its stat info are stored here | 160 | * a directory entry and its stat info are stored here |
159 | */ | 161 | */ |
160 | struct dnode { /* the basic node */ | 162 | struct dnode { /* the basic node */ |
161 | char *name; /* the dir entry name */ | 163 | char *name; /* the dir entry name */ |
162 | char *fullname; /* the dir entry name */ | 164 | char *fullname; /* the dir entry name */ |
163 | struct stat dstat; /* the file stat info */ | 165 | struct stat dstat; /* the file stat info */ |
164 | struct dnode *next; /* point at the next node */ | 166 | struct dnode *next; /* point at the next node */ |
165 | }; | 167 | }; |
166 | typedef struct dnode dnode_t; | 168 | typedef struct dnode dnode_t; |
167 | 169 | ||
@@ -172,6 +174,7 @@ static int list_single(struct dnode *); | |||
172 | static unsigned int disp_opts; | 174 | static unsigned int disp_opts; |
173 | static unsigned int style_fmt; | 175 | static unsigned int style_fmt; |
174 | static unsigned int list_fmt; | 176 | static unsigned int list_fmt; |
177 | |||
175 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 178 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
176 | static unsigned int sort_opts; | 179 | static unsigned int sort_opts; |
177 | static unsigned int sort_order; | 180 | static unsigned int sort_order; |
@@ -180,10 +183,11 @@ static unsigned int sort_order; | |||
180 | static unsigned int time_fmt; | 183 | static unsigned int time_fmt; |
181 | #endif | 184 | #endif |
182 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS | 185 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS |
183 | static unsigned int follow_links=FALSE; | 186 | static unsigned int follow_links = FALSE; |
184 | #endif | 187 | #endif |
185 | 188 | ||
186 | static unsigned short column = 0; | 189 | static unsigned short column = 0; |
190 | |||
187 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 191 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
188 | static unsigned short terminal_width = TERMINAL_WIDTH; | 192 | static unsigned short terminal_width = TERMINAL_WIDTH; |
189 | static unsigned short column_width = COLUMN_WIDTH; | 193 | static unsigned short column_width = COLUMN_WIDTH; |
@@ -223,10 +227,10 @@ static int my_stat(struct dnode *cur) | |||
223 | 227 | ||
224 | static void newline(void) | 228 | static void newline(void) |
225 | { | 229 | { |
226 | if (column > 0) { | 230 | if (column > 0) { |
227 | putchar('\n'); | 231 | putchar('\n'); |
228 | column = 0; | 232 | column = 0; |
229 | } | 233 | } |
230 | } | 234 | } |
231 | 235 | ||
232 | /*----------------------------------------------------------------------*/ | 236 | /*----------------------------------------------------------------------*/ |
@@ -234,12 +238,12 @@ static void newline(void) | |||
234 | static char fgcolor(mode_t mode) | 238 | static char fgcolor(mode_t mode) |
235 | { | 239 | { |
236 | /* Check wheter the file is existing (if so, color it red!) */ | 240 | /* Check wheter the file is existing (if so, color it red!) */ |
237 | if ( errno == ENOENT ) { | 241 | if (errno == ENOENT) { |
238 | errno = 0; | 242 | errno = 0; |
239 | return '\037'; | 243 | return '\037'; |
240 | } | 244 | } |
241 | if ( LIST_EXEC && S_ISREG( mode ) | 245 | if (LIST_EXEC && S_ISREG(mode) |
242 | && ( mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) ) | 246 | && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) |
243 | return COLOR(0xF000); /* File is executable ... */ | 247 | return COLOR(0xF000); /* File is executable ... */ |
244 | return COLOR(mode); | 248 | return COLOR(mode); |
245 | } | 249 | } |
@@ -247,8 +251,8 @@ static char fgcolor(mode_t mode) | |||
247 | /*----------------------------------------------------------------------*/ | 251 | /*----------------------------------------------------------------------*/ |
248 | static char bgcolor(mode_t mode) | 252 | static char bgcolor(mode_t mode) |
249 | { | 253 | { |
250 | if ( LIST_EXEC && S_ISREG( mode ) | 254 | if (LIST_EXEC && S_ISREG(mode) |
251 | && ( mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) ) | 255 | && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) |
252 | return ATTR(0xF000); /* File is executable ... */ | 256 | return ATTR(0xF000); /* File is executable ... */ |
253 | return ATTR(mode); | 257 | return ATTR(mode); |
254 | } | 258 | } |
@@ -258,29 +262,31 @@ static char bgcolor(mode_t mode) | |||
258 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) | 262 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) |
259 | static char append_char(mode_t mode) | 263 | static char append_char(mode_t mode) |
260 | { | 264 | { |
261 | if ( !(list_fmt & LIST_FILETYPE)) | 265 | if (!(list_fmt & LIST_FILETYPE)) |
262 | return '\0'; | 266 | return '\0'; |
263 | if ((list_fmt & LIST_EXEC) && S_ISREG(mode) | 267 | if ((list_fmt & LIST_EXEC) && S_ISREG(mode) |
264 | && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return '*'; | 268 | && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) |
265 | return APPCHAR(mode); | 269 | return '*'; |
270 | return APPCHAR(mode); | ||
266 | } | 271 | } |
267 | #endif | 272 | #endif |
268 | 273 | ||
269 | /*----------------------------------------------------------------------*/ | 274 | /*----------------------------------------------------------------------*/ |
270 | static void nexttabstop( void ) | 275 | static void nexttabstop(void) |
271 | { | 276 | { |
272 | static short nexttab= 0; | 277 | static short nexttab = 0; |
273 | int n=0; | 278 | int n = 0; |
274 | 279 | ||
275 | if (column > 0) { | 280 | if (column > 0) { |
276 | n= nexttab - column; | 281 | n = nexttab - column; |
277 | if (n < 1) n= 1; | 282 | if (n < 1) |
283 | n = 1; | ||
278 | while (n--) { | 284 | while (n--) { |
279 | putchar(' '); | 285 | putchar(' '); |
280 | column++; | 286 | column++; |
281 | } | 287 | } |
282 | } | 288 | } |
283 | nexttab= column + column_width + COLUMN_GAP; | 289 | nexttab = column + column_width + COLUMN_GAP; |
284 | } | 290 | } |
285 | 291 | ||
286 | /*----------------------------------------------------------------------*/ | 292 | /*----------------------------------------------------------------------*/ |
@@ -294,19 +300,22 @@ static int countdirs(struct dnode **dn, int nfiles) | |||
294 | { | 300 | { |
295 | int i, dirs; | 301 | int i, dirs; |
296 | 302 | ||
297 | if (dn==NULL || nfiles < 1) return(0); | 303 | if (dn == NULL || nfiles < 1) |
298 | dirs= 0; | 304 | return (0); |
299 | for (i=0; i<nfiles; i++) { | 305 | dirs = 0; |
300 | if (S_ISDIR(dn[i]->dstat.st_mode)) dirs++; | 306 | for (i = 0; i < nfiles; i++) { |
307 | if (S_ISDIR(dn[i]->dstat.st_mode)) | ||
308 | dirs++; | ||
301 | } | 309 | } |
302 | return(dirs); | 310 | return (dirs); |
303 | } | 311 | } |
304 | 312 | ||
305 | static int countsubdirs(struct dnode **dn, int nfiles) | 313 | static int countsubdirs(struct dnode **dn, int nfiles) |
306 | { | 314 | { |
307 | int i, subdirs; | 315 | int i, subdirs; |
308 | 316 | ||
309 | if (dn == NULL || nfiles < 1) return 0; | 317 | if (dn == NULL || nfiles < 1) |
318 | return 0; | ||
310 | subdirs = 0; | 319 | subdirs = 0; |
311 | for (i = 0; i < nfiles; i++) | 320 | for (i = 0; i < nfiles; i++) |
312 | if (is_subdir(dn[i])) | 321 | if (is_subdir(dn[i])) |
@@ -319,11 +328,13 @@ static int countfiles(struct dnode **dnp) | |||
319 | int nfiles; | 328 | int nfiles; |
320 | struct dnode *cur; | 329 | struct dnode *cur; |
321 | 330 | ||
322 | if (dnp == NULL) return(0); | 331 | if (dnp == NULL) |
323 | nfiles= 0; | 332 | return (0); |
324 | for (cur= dnp[0]; cur->next != NULL ; cur= cur->next) nfiles++; | 333 | nfiles = 0; |
334 | for (cur = dnp[0]; cur->next != NULL; cur = cur->next) | ||
335 | nfiles++; | ||
325 | nfiles++; | 336 | nfiles++; |
326 | return(nfiles); | 337 | return (nfiles); |
327 | } | 338 | } |
328 | 339 | ||
329 | /* get memory to hold an array of pointers */ | 340 | /* get memory to hold an array of pointers */ |
@@ -331,10 +342,12 @@ static struct dnode **dnalloc(int num) | |||
331 | { | 342 | { |
332 | struct dnode **p; | 343 | struct dnode **p; |
333 | 344 | ||
334 | if (num < 1) return(NULL); | 345 | if (num < 1) |
346 | return (NULL); | ||
335 | 347 | ||
336 | p= (struct dnode **)xcalloc((size_t)num, (size_t)(sizeof(struct dnode *))); | 348 | p = (struct dnode **) xcalloc((size_t) num, |
337 | return(p); | 349 | (size_t) (sizeof(struct dnode *))); |
350 | return (p); | ||
338 | } | 351 | } |
339 | 352 | ||
340 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 353 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
@@ -342,16 +355,18 @@ static void dfree(struct dnode **dnp) | |||
342 | { | 355 | { |
343 | struct dnode *cur, *next; | 356 | struct dnode *cur, *next; |
344 | 357 | ||
345 | if(dnp == NULL) return; | 358 | if (dnp == NULL) |
359 | return; | ||
346 | 360 | ||
347 | cur=dnp[0]; | 361 | cur = dnp[0]; |
348 | while (cur != NULL) { | 362 | while (cur != NULL) { |
349 | if (cur->fullname != NULL) free(cur->fullname); /* free the filename */ | 363 | if (cur->fullname != NULL) |
350 | next= cur->next; | 364 | free(cur->fullname); /* free the filename */ |
351 | free(cur); /* free the dnode */ | 365 | next = cur->next; |
352 | cur= next; | 366 | free(cur); /* free the dnode */ |
367 | cur = next; | ||
353 | } | 368 | } |
354 | free(dnp); /* free the array holding the dnode pointers */ | 369 | free(dnp); /* free the array holding the dnode pointers */ |
355 | } | 370 | } |
356 | #endif | 371 | #endif |
357 | 372 | ||
@@ -360,37 +375,38 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) | |||
360 | int dncnt, i, d; | 375 | int dncnt, i, d; |
361 | struct dnode **dnp; | 376 | struct dnode **dnp; |
362 | 377 | ||
363 | if (dn==NULL || nfiles < 1) return(NULL); | 378 | if (dn == NULL || nfiles < 1) |
379 | return (NULL); | ||
364 | 380 | ||
365 | /* count how many dirs and regular files there are */ | 381 | /* count how many dirs and regular files there are */ |
366 | if (which == SPLIT_SUBDIR) | 382 | if (which == SPLIT_SUBDIR) |
367 | dncnt = countsubdirs(dn, nfiles); | 383 | dncnt = countsubdirs(dn, nfiles); |
368 | else { | 384 | else { |
369 | dncnt= countdirs(dn, nfiles); /* assume we are looking for dirs */ | 385 | dncnt = countdirs(dn, nfiles); /* assume we are looking for dirs */ |
370 | if (which == SPLIT_FILE) | 386 | if (which == SPLIT_FILE) |
371 | dncnt= nfiles - dncnt; /* looking for files */ | 387 | dncnt = nfiles - dncnt; /* looking for files */ |
372 | } | 388 | } |
373 | 389 | ||
374 | /* allocate a file array and a dir array */ | 390 | /* allocate a file array and a dir array */ |
375 | dnp= dnalloc(dncnt); | 391 | dnp = dnalloc(dncnt); |
376 | 392 | ||
377 | /* copy the entrys into the file or dir array */ | 393 | /* copy the entrys into the file or dir array */ |
378 | for (d= i=0; i<nfiles; i++) { | 394 | for (d = i = 0; i < nfiles; i++) { |
379 | if (which == SPLIT_DIR) { | 395 | if (which == SPLIT_DIR) { |
380 | if (S_ISDIR(dn[i]->dstat.st_mode)) { | 396 | if (S_ISDIR(dn[i]->dstat.st_mode)) { |
381 | dnp[d++]= dn[i]; | 397 | dnp[d++] = dn[i]; |
382 | } /* else skip the file */ | 398 | } /* else skip the file */ |
383 | } else if (which == SPLIT_SUBDIR) { | 399 | } else if (which == SPLIT_SUBDIR) { |
384 | if (is_subdir(dn[i])) { | 400 | if (is_subdir(dn[i])) { |
385 | dnp[d++]= dn[i]; | 401 | dnp[d++] = dn[i]; |
386 | } /* else skip the file or dir */ | 402 | } /* else skip the file or dir */ |
387 | } else { | 403 | } else { |
388 | if (!(S_ISDIR(dn[i]->dstat.st_mode))) { | 404 | if (!(S_ISDIR(dn[i]->dstat.st_mode))) { |
389 | dnp[d++]= dn[i]; | 405 | dnp[d++] = dn[i]; |
390 | } /* else skip the dir */ | 406 | } /* else skip the dir */ |
391 | } | 407 | } |
392 | } | 408 | } |
393 | return(dnp); | 409 | return (dnp); |
394 | } | 410 | } |
395 | 411 | ||
396 | /*----------------------------------------------------------------------*/ | 412 | /*----------------------------------------------------------------------*/ |
@@ -399,36 +415,40 @@ static int sortcmp(struct dnode *d1, struct dnode *d2) | |||
399 | { | 415 | { |
400 | int cmp, dif; | 416 | int cmp, dif; |
401 | 417 | ||
402 | cmp= 0; | 418 | cmp = 0; |
403 | if (sort_opts == SORT_SIZE) { | 419 | if (sort_opts == SORT_SIZE) { |
404 | dif= (int)(d1->dstat.st_size - d2->dstat.st_size); | 420 | dif = (int) (d1->dstat.st_size - d2->dstat.st_size); |
405 | } else if (sort_opts == SORT_ATIME) { | 421 | } else if (sort_opts == SORT_ATIME) { |
406 | dif= (int)(d1->dstat.st_atime - d2->dstat.st_atime); | 422 | dif = (int) (d1->dstat.st_atime - d2->dstat.st_atime); |
407 | } else if (sort_opts == SORT_CTIME) { | 423 | } else if (sort_opts == SORT_CTIME) { |
408 | dif= (int)(d1->dstat.st_ctime - d2->dstat.st_ctime); | 424 | dif = (int) (d1->dstat.st_ctime - d2->dstat.st_ctime); |
409 | } else if (sort_opts == SORT_MTIME) { | 425 | } else if (sort_opts == SORT_MTIME) { |
410 | dif= (int)(d1->dstat.st_mtime - d2->dstat.st_mtime); | 426 | dif = (int) (d1->dstat.st_mtime - d2->dstat.st_mtime); |
411 | } else if (sort_opts == SORT_DIR) { | 427 | } else if (sort_opts == SORT_DIR) { |
412 | dif= S_ISDIR(d1->dstat.st_mode) - S_ISDIR(d2->dstat.st_mode); | 428 | dif = S_ISDIR(d1->dstat.st_mode) - S_ISDIR(d2->dstat.st_mode); |
413 | /* } else if (sort_opts == SORT_VERSION) { */ | 429 | /* } else if (sort_opts == SORT_VERSION) { */ |
414 | /* } else if (sort_opts == SORT_EXT) { */ | 430 | /* } else if (sort_opts == SORT_EXT) { */ |
415 | } else { /* assume SORT_NAME */ | 431 | } else { /* assume SORT_NAME */ |
416 | dif= 0; | 432 | dif = 0; |
417 | } | 433 | } |
418 | 434 | ||
419 | if (dif > 0) cmp= -1; | 435 | if (dif > 0) |
420 | if (dif < 0) cmp= 1; | 436 | cmp = -1; |
437 | if (dif < 0) | ||
438 | cmp = 1; | ||
421 | if (dif == 0) { | 439 | if (dif == 0) { |
422 | /* sort by name- may be a tie_breaker for time or size cmp */ | 440 | /* sort by name- may be a tie_breaker for time or size cmp */ |
423 | dif= strcmp(d1->name, d2->name); | 441 | dif = strcmp(d1->name, d2->name); |
424 | if (dif > 0) cmp= 1; | 442 | if (dif > 0) |
425 | if (dif < 0) cmp= -1; | 443 | cmp = 1; |
444 | if (dif < 0) | ||
445 | cmp = -1; | ||
426 | } | 446 | } |
427 | 447 | ||
428 | if (sort_order == SORT_REVERSE) { | 448 | if (sort_order == SORT_REVERSE) { |
429 | cmp= -1 * cmp; | 449 | cmp = -1 * cmp; |
430 | } | 450 | } |
431 | return(cmp); | 451 | return (cmp); |
432 | } | 452 | } |
433 | 453 | ||
434 | /*----------------------------------------------------------------------*/ | 454 | /*----------------------------------------------------------------------*/ |
@@ -438,17 +458,18 @@ static void shellsort(struct dnode **dn, int size) | |||
438 | int gap, i, j; | 458 | int gap, i, j; |
439 | 459 | ||
440 | /* shell short the array */ | 460 | /* shell short the array */ |
441 | if(dn==NULL || size < 2) return; | 461 | if (dn == NULL || size < 2) |
462 | return; | ||
442 | 463 | ||
443 | for (gap= size/2; gap>0; gap /=2) { | 464 | for (gap = size / 2; gap > 0; gap /= 2) { |
444 | for (i=gap; i<size; i++) { | 465 | for (i = gap; i < size; i++) { |
445 | for (j= i-gap; j>=0; j-=gap) { | 466 | for (j = i - gap; j >= 0; j -= gap) { |
446 | if (sortcmp(dn[j], dn[j+gap]) <= 0) | 467 | if (sortcmp(dn[j], dn[j + gap]) <= 0) |
447 | break; | 468 | break; |
448 | /* they are out of order, swap them */ | 469 | /* they are out of order, swap them */ |
449 | temp= dn[j]; | 470 | temp = dn[j]; |
450 | dn[j]= dn[j+gap]; | 471 | dn[j] = dn[j + gap]; |
451 | dn[j+gap]= temp; | 472 | dn[j + gap] = temp; |
452 | } | 473 | } |
453 | } | 474 | } |
454 | } | 475 | } |
@@ -459,32 +480,33 @@ static void shellsort(struct dnode **dn, int size) | |||
459 | static void showfiles(struct dnode **dn, int nfiles) | 480 | static void showfiles(struct dnode **dn, int nfiles) |
460 | { | 481 | { |
461 | int i, ncols, nrows, row, nc; | 482 | int i, ncols, nrows, row, nc; |
483 | |||
462 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 484 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
463 | int len; | 485 | int len; |
464 | #endif | 486 | #endif |
465 | 487 | ||
466 | if(dn==NULL || nfiles < 1) return; | 488 | if (dn == NULL || nfiles < 1) |
489 | return; | ||
467 | 490 | ||
468 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 491 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
469 | /* find the longest file name- use that as the column width */ | 492 | /* find the longest file name- use that as the column width */ |
470 | column_width= 0; | 493 | column_width = 0; |
471 | for (i=0; i<nfiles; i++) { | 494 | for (i = 0; i < nfiles; i++) { |
472 | len= strlen(dn[i]->name) + | 495 | len = strlen(dn[i]->name) + |
473 | ((list_fmt & LIST_INO) ? 8 : 0) + | 496 | ((list_fmt & LIST_INO) ? 8 : 0) + |
474 | ((list_fmt & LIST_BLOCKS) ? 5 : 0) | 497 | ((list_fmt & LIST_BLOCKS) ? 5 : 0); |
475 | ; | 498 | if (column_width < len) |
476 | if (column_width < len) | 499 | column_width = len; |
477 | column_width= len; | ||
478 | } | 500 | } |
479 | ncols = (int)(terminal_width / (column_width + COLUMN_GAP)); | 501 | ncols = (int) (terminal_width / (column_width + COLUMN_GAP)); |
480 | #else | 502 | #else |
481 | ncols= TERMINAL_WIDTH; | 503 | ncols = TERMINAL_WIDTH; |
482 | #endif | 504 | #endif |
483 | switch (style_fmt) { | 505 | switch (style_fmt) { |
484 | case STYLE_LONG: /* one record per line, extended info */ | 506 | case STYLE_LONG: /* one record per line, extended info */ |
485 | case STYLE_SINGLE: /* one record per line */ | 507 | case STYLE_SINGLE: /* one record per line */ |
486 | ncols= 1; | 508 | ncols = 1; |
487 | break; | 509 | break; |
488 | } | 510 | } |
489 | 511 | ||
490 | if (ncols > 1) { | 512 | if (ncols > 1) { |
@@ -493,15 +515,17 @@ static void showfiles(struct dnode **dn, int nfiles) | |||
493 | nrows = nfiles; | 515 | nrows = nfiles; |
494 | ncols = 1; | 516 | ncols = 1; |
495 | } | 517 | } |
496 | if ((nrows * ncols) < nfiles) nrows++; /* round up fractionals */ | 518 | if ((nrows * ncols) < nfiles) |
519 | nrows++; /* round up fractionals */ | ||
497 | 520 | ||
498 | if (nrows > nfiles) nrows= nfiles; | 521 | if (nrows > nfiles) |
499 | for (row=0; row<nrows; row++) { | 522 | nrows = nfiles; |
500 | for (nc=0; nc<ncols; nc++) { | 523 | for (row = 0; row < nrows; row++) { |
524 | for (nc = 0; nc < ncols; nc++) { | ||
501 | /* reach into the array based on the column and row */ | 525 | /* reach into the array based on the column and row */ |
502 | i= (nc * nrows) + row; /* assume display by column */ | 526 | i = (nc * nrows) + row; /* assume display by column */ |
503 | if (disp_opts & DISP_ROWS) | 527 | if (disp_opts & DISP_ROWS) |
504 | i= (row * ncols) + nc; /* display across row */ | 528 | i = (row * ncols) + nc; /* display across row */ |
505 | if (i < nfiles) { | 529 | if (i < nfiles) { |
506 | nexttabstop(); | 530 | nexttabstop(); |
507 | list_single(dn[i]); | 531 | list_single(dn[i]); |
@@ -516,19 +540,21 @@ static void showdirs(struct dnode **dn, int ndirs) | |||
516 | { | 540 | { |
517 | int i, nfiles; | 541 | int i, nfiles; |
518 | struct dnode **subdnp; | 542 | struct dnode **subdnp; |
543 | |||
519 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 544 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
520 | int dndirs; | 545 | int dndirs; |
521 | struct dnode **dnd; | 546 | struct dnode **dnd; |
522 | #endif | 547 | #endif |
523 | 548 | ||
524 | if (dn==NULL || ndirs < 1) return; | 549 | if (dn == NULL || ndirs < 1) |
550 | return; | ||
525 | 551 | ||
526 | for (i=0; i<ndirs; i++) { | 552 | for (i = 0; i < ndirs; i++) { |
527 | if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) { | 553 | if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) { |
528 | printf("\n%s:\n", dn[i]->fullname); | 554 | printf("\n%s:\n", dn[i]->fullname); |
529 | } | 555 | } |
530 | subdnp= list_dir(dn[i]->fullname); | 556 | subdnp = list_dir(dn[i]->fullname); |
531 | nfiles= countfiles(subdnp); | 557 | nfiles = countfiles(subdnp); |
532 | if (nfiles > 0) { | 558 | if (nfiles > 0) { |
533 | /* list all files at this level */ | 559 | /* list all files at this level */ |
534 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 560 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
@@ -538,17 +564,17 @@ static void showdirs(struct dnode **dn, int ndirs) | |||
538 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 564 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
539 | if (disp_opts & DISP_RECURSIVE) { | 565 | if (disp_opts & DISP_RECURSIVE) { |
540 | /* recursive- list the sub-dirs */ | 566 | /* recursive- list the sub-dirs */ |
541 | dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); | 567 | dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); |
542 | dndirs= countsubdirs(subdnp, nfiles); | 568 | dndirs = countsubdirs(subdnp, nfiles); |
543 | if (dndirs > 0) { | 569 | if (dndirs > 0) { |
544 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 570 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
545 | shellsort(dnd, dndirs); | 571 | shellsort(dnd, dndirs); |
546 | #endif | 572 | #endif |
547 | showdirs(dnd, dndirs); | 573 | showdirs(dnd, dndirs); |
548 | free(dnd); /* free the array of dnode pointers to the dirs */ | 574 | free(dnd); /* free the array of dnode pointers to the dirs */ |
549 | } | 575 | } |
550 | } | 576 | } |
551 | dfree(subdnp); /* free the dnodes and the fullname mem */ | 577 | dfree(subdnp); /* free the dnodes and the fullname mem */ |
552 | #endif | 578 | #endif |
553 | } | 579 | } |
554 | } | 580 | } |
@@ -562,53 +588,56 @@ static struct dnode **list_dir(char *path) | |||
562 | DIR *dir; | 588 | DIR *dir; |
563 | int i, nfiles; | 589 | int i, nfiles; |
564 | 590 | ||
565 | if (path==NULL) return(NULL); | 591 | if (path == NULL) |
592 | return (NULL); | ||
566 | 593 | ||
567 | dn= NULL; | 594 | dn = NULL; |
568 | nfiles= 0; | 595 | nfiles = 0; |
569 | dir = opendir(path); | 596 | dir = opendir(path); |
570 | if (dir == NULL) { | 597 | if (dir == NULL) { |
571 | perror_msg("%s", path); | 598 | perror_msg("%s", path); |
572 | status = EXIT_FAILURE; | 599 | status = EXIT_FAILURE; |
573 | return(NULL); /* could not open the dir */ | 600 | return (NULL); /* could not open the dir */ |
574 | } | 601 | } |
575 | while ((entry = readdir(dir)) != NULL) { | 602 | while ((entry = readdir(dir)) != NULL) { |
576 | /* are we going to list the file- it may be . or .. or a hidden file */ | 603 | /* are we going to list the file- it may be . or .. or a hidden file */ |
577 | if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) | 604 | if ((strcmp(entry->d_name, ".") == 0) && !(disp_opts & DISP_DOT)) |
578 | continue; | 605 | continue; |
579 | if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) | 606 | if ((strcmp(entry->d_name, "..") == 0) && !(disp_opts & DISP_DOT)) |
580 | continue; | 607 | continue; |
581 | if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) | 608 | if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) |
582 | continue; | 609 | continue; |
583 | cur= (struct dnode *)xmalloc(sizeof(struct dnode)); | 610 | cur = (struct dnode *) xmalloc(sizeof(struct dnode)); |
584 | cur->fullname = concat_path_file(path, entry->d_name); | 611 | cur->fullname = concat_path_file(path, entry->d_name); |
585 | cur->name = cur->fullname + | 612 | cur->name = cur->fullname + |
586 | (strlen(cur->fullname) - strlen(entry->d_name)); | 613 | (strlen(cur->fullname) - strlen(entry->d_name)); |
587 | if (my_stat(cur)) | 614 | if (my_stat(cur)) |
588 | continue; | 615 | continue; |
589 | cur->next= dn; | 616 | cur->next = dn; |
590 | dn= cur; | 617 | dn = cur; |
591 | nfiles++; | 618 | nfiles++; |
592 | } | 619 | } |
593 | closedir(dir); | 620 | closedir(dir); |
594 | 621 | ||
595 | /* now that we know how many files there are | 622 | /* now that we know how many files there are |
596 | ** allocate memory for an array to hold dnode pointers | 623 | ** allocate memory for an array to hold dnode pointers |
597 | */ | 624 | */ |
598 | if (nfiles < 1) return(NULL); | 625 | if (nfiles < 1) |
599 | dnp= dnalloc(nfiles); | 626 | return (NULL); |
600 | for (i=0, cur=dn; i<nfiles; i++) { | 627 | dnp = dnalloc(nfiles); |
601 | dnp[i]= cur; /* save pointer to node in array */ | 628 | for (i = 0, cur = dn; i < nfiles; i++) { |
602 | cur= cur->next; | 629 | dnp[i] = cur; /* save pointer to node in array */ |
630 | cur = cur->next; | ||
603 | } | 631 | } |
604 | 632 | ||
605 | return(dnp); | 633 | return (dnp); |
606 | } | 634 | } |
607 | 635 | ||
608 | /*----------------------------------------------------------------------*/ | 636 | /*----------------------------------------------------------------------*/ |
609 | static int list_single(struct dnode *dn) | 637 | static int list_single(struct dnode *dn) |
610 | { | 638 | { |
611 | int i; | 639 | int i; |
640 | |||
612 | #ifdef CONFIG_FEATURE_LS_USERNAME | 641 | #ifdef CONFIG_FEATURE_LS_USERNAME |
613 | char scratch[BUFSIZ + 1]; | 642 | char scratch[BUFSIZ + 1]; |
614 | #endif | 643 | #endif |
@@ -616,158 +645,167 @@ static int list_single(struct dnode *dn) | |||
616 | char *filetime; | 645 | char *filetime; |
617 | time_t ttime, age; | 646 | time_t ttime, age; |
618 | #endif | 647 | #endif |
619 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) | 648 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined (CONFIG_FEATURE_LS_COLOR) |
620 | struct stat info; | 649 | struct stat info; |
621 | char append; | 650 | char append; |
622 | #endif | 651 | #endif |
623 | 652 | ||
624 | if (dn==NULL || dn->fullname==NULL) return(0); | 653 | if (dn == NULL || dn->fullname == NULL) |
654 | return (0); | ||
625 | 655 | ||
626 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 656 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
627 | ttime= dn->dstat.st_mtime; /* the default time */ | 657 | ttime = dn->dstat.st_mtime; /* the default time */ |
628 | if (time_fmt & TIME_ACCESS) ttime= dn->dstat.st_atime; | 658 | if (time_fmt & TIME_ACCESS) |
629 | if (time_fmt & TIME_CHANGE) ttime= dn->dstat.st_ctime; | 659 | ttime = dn->dstat.st_atime; |
630 | filetime= ctime(&ttime); | 660 | if (time_fmt & TIME_CHANGE) |
661 | ttime = dn->dstat.st_ctime; | ||
662 | filetime = ctime(&ttime); | ||
631 | #endif | 663 | #endif |
632 | #ifdef CONFIG_FEATURE_LS_FILETYPES | 664 | #ifdef CONFIG_FEATURE_LS_FILETYPES |
633 | append = append_char(dn->dstat.st_mode); | 665 | append = append_char(dn->dstat.st_mode); |
634 | #endif | 666 | #endif |
635 | 667 | ||
636 | for (i=0; i<=31; i++) { | 668 | for (i = 0; i <= 31; i++) { |
637 | switch (list_fmt & (1<<i)) { | 669 | switch (list_fmt & (1 << i)) { |
638 | case LIST_INO: | 670 | case LIST_INO: |
639 | printf("%7ld ", (long int)dn->dstat.st_ino); | 671 | printf("%7ld ", (long int) dn->dstat.st_ino); |
640 | column += 8; | 672 | column += 8; |
641 | break; | 673 | break; |
642 | case LIST_BLOCKS: | 674 | case LIST_BLOCKS: |
643 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 675 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
644 | fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1, | 676 | fprintf(stdout, "%6s ", |
645 | KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE)); | 677 | make_human_readable_str(dn->dstat.st_blocks >> 1, |
678 | KILOBYTE, | ||
679 | (ls_disp_hr == | ||
680 | TRUE) ? 0 : KILOBYTE)); | ||
646 | #else | 681 | #else |
647 | #if _FILE_OFFSET_BITS == 64 | 682 | #if _FILE_OFFSET_BITS == 64 |
648 | printf("%4lld ", dn->dstat.st_blocks>>1); | 683 | printf("%4lld ", dn->dstat.st_blocks >> 1); |
649 | #else | 684 | #else |
650 | printf("%4ld ", dn->dstat.st_blocks>>1); | 685 | printf("%4ld ", dn->dstat.st_blocks >> 1); |
651 | #endif | 686 | #endif |
652 | #endif | 687 | #endif |
653 | column += 5; | 688 | column += 5; |
654 | break; | 689 | break; |
655 | case LIST_MODEBITS: | 690 | case LIST_MODEBITS: |
656 | printf("%-10s ", (char *)mode_string(dn->dstat.st_mode)); | 691 | printf("%-10s ", (char *) mode_string(dn->dstat.st_mode)); |
657 | column += 10; | 692 | column += 10; |
658 | break; | 693 | break; |
659 | case LIST_NLINKS: | 694 | case LIST_NLINKS: |
660 | printf("%4ld ", (long)dn->dstat.st_nlink); | 695 | printf("%4ld ", (long) dn->dstat.st_nlink); |
661 | column += 10; | 696 | column += 10; |
662 | break; | 697 | break; |
663 | case LIST_ID_NAME: | 698 | case LIST_ID_NAME: |
664 | #ifdef CONFIG_FEATURE_LS_USERNAME | 699 | #ifdef CONFIG_FEATURE_LS_USERNAME |
665 | my_getpwuid(scratch, dn->dstat.st_uid); | 700 | my_getpwuid(scratch, dn->dstat.st_uid); |
666 | printf("%-8.8s ", scratch); | 701 | printf("%-8.8s ", scratch); |
667 | my_getgrgid(scratch, dn->dstat.st_gid); | 702 | my_getgrgid(scratch, dn->dstat.st_gid); |
668 | printf("%-8.8s", scratch); | 703 | printf("%-8.8s", scratch); |
669 | column += 17; | 704 | column += 17; |
670 | break; | 705 | break; |
671 | #endif | 706 | #endif |
672 | case LIST_ID_NUMERIC: | 707 | case LIST_ID_NUMERIC: |
673 | printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid); | 708 | printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid); |
674 | column += 17; | 709 | column += 17; |
675 | break; | 710 | break; |
676 | case LIST_SIZE: | 711 | case LIST_SIZE: |
677 | case LIST_DEV: | 712 | case LIST_DEV: |
678 | if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) { | 713 | if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) { |
679 | printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); | 714 | printf("%4d, %3d ", (int) MAJOR(dn->dstat.st_rdev), |
680 | } else { | 715 | (int) MINOR(dn->dstat.st_rdev)); |
716 | } else { | ||
681 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 717 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
682 | if (ls_disp_hr==TRUE) { | 718 | if (ls_disp_hr == TRUE) { |
683 | fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0)); | 719 | fprintf(stdout, "%8s ", |
684 | } else | 720 | make_human_readable_str(dn->dstat.st_size, 1, 0)); |
685 | #endif | 721 | } else |
686 | { | 722 | #endif |
723 | { | ||
687 | #if _FILE_OFFSET_BITS == 64 | 724 | #if _FILE_OFFSET_BITS == 64 |
688 | printf("%9lld ", (long long)dn->dstat.st_size); | 725 | printf("%9lld ", (long long) dn->dstat.st_size); |
689 | #else | 726 | #else |
690 | printf("%9ld ", dn->dstat.st_size); | 727 | printf("%9ld ", dn->dstat.st_size); |
691 | #endif | 728 | #endif |
692 | } | ||
693 | } | 729 | } |
694 | column += 10; | 730 | } |
695 | break; | 731 | column += 10; |
732 | break; | ||
696 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 733 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
697 | case LIST_FULLTIME: | 734 | case LIST_FULLTIME: |
698 | case LIST_DATE_TIME: | 735 | case LIST_DATE_TIME: |
699 | if (list_fmt & LIST_FULLTIME) { | 736 | if (list_fmt & LIST_FULLTIME) { |
700 | printf("%24.24s ", filetime); | 737 | printf("%24.24s ", filetime); |
701 | column += 25; | 738 | column += 25; |
702 | break; | ||
703 | } | ||
704 | age = time(NULL) - ttime; | ||
705 | printf("%6.6s ", filetime+4); | ||
706 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { | ||
707 | /* hh:mm if less than 6 months old */ | ||
708 | printf("%5.5s ", filetime+11); | ||
709 | } else { | ||
710 | printf(" %4.4s ", filetime+20); | ||
711 | } | ||
712 | column += 13; | ||
713 | break; | 739 | break; |
740 | } | ||
741 | age = time(NULL) - ttime; | ||
742 | printf("%6.6s ", filetime + 4); | ||
743 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { | ||
744 | /* hh:mm if less than 6 months old */ | ||
745 | printf("%5.5s ", filetime + 11); | ||
746 | } else { | ||
747 | printf(" %4.4s ", filetime + 20); | ||
748 | } | ||
749 | column += 13; | ||
750 | break; | ||
714 | #endif | 751 | #endif |
715 | case LIST_FILENAME: | 752 | case LIST_FILENAME: |
716 | #ifdef CONFIG_FEATURE_LS_COLOR | 753 | #ifdef CONFIG_FEATURE_LS_COLOR |
717 | errno = 0; | 754 | errno = 0; |
718 | if (show_color && !lstat(dn->fullname, &info)) { | 755 | if (show_color && !lstat(dn->fullname, &info)) { |
719 | printf( "\033[%d;%dm", bgcolor(info.st_mode), | 756 | printf("\033[%d;%dm", bgcolor(info.st_mode), |
720 | fgcolor(info.st_mode) ); | 757 | fgcolor(info.st_mode)); |
721 | } | 758 | } |
722 | #endif | 759 | #endif |
723 | printf("%s", dn->name); | 760 | printf("%s", dn->name); |
724 | #ifdef CONFIG_FEATURE_LS_COLOR | 761 | #ifdef CONFIG_FEATURE_LS_COLOR |
725 | if (show_color) { | 762 | if (show_color) { |
726 | printf( "\033[0m" ); | 763 | printf("\033[0m"); |
727 | } | 764 | } |
728 | #endif | 765 | #endif |
729 | column += strlen(dn->name); | 766 | column += strlen(dn->name); |
730 | break; | 767 | break; |
731 | case LIST_SYMLINK: | 768 | case LIST_SYMLINK: |
732 | if (S_ISLNK(dn->dstat.st_mode)) { | 769 | if (S_ISLNK(dn->dstat.st_mode)) { |
733 | char *lpath = xreadlink(dn->fullname); | 770 | char *lpath = xreadlink(dn->fullname); |
734 | if (lpath) { | 771 | |
735 | printf(" -> "); | 772 | if (lpath) { |
736 | #if defined(BB_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR) | 773 | printf(" -> "); |
737 | if (!stat(dn->fullname, &info)) { | 774 | #if defined(CONFIG_FEATURE_LS_FILETYPES) || defined (CONFIG_FEATURE_LS_COLOR) |
738 | append = append_char(info.st_mode); | 775 | if (!stat(dn->fullname, &info)) { |
739 | } | 776 | append = append_char(info.st_mode); |
777 | } | ||
740 | #endif | 778 | #endif |
741 | #ifdef CONFIG_FEATURE_LS_COLOR | 779 | #ifdef CONFIG_FEATURE_LS_COLOR |
742 | if (show_color) { | 780 | if (show_color) { |
743 | errno = 0; | 781 | errno = 0; |
744 | printf( "\033[%d;%dm", bgcolor(info.st_mode), | 782 | printf("\033[%d;%dm", bgcolor(info.st_mode), |
745 | fgcolor(info.st_mode) ); | 783 | fgcolor(info.st_mode)); |
746 | } | 784 | } |
747 | #endif | 785 | #endif |
748 | printf("%s", lpath); | 786 | printf("%s", lpath); |
749 | #ifdef CONFIG_FEATURE_LS_COLOR | 787 | #ifdef CONFIG_FEATURE_LS_COLOR |
750 | if (show_color) { | 788 | if (show_color) { |
751 | printf( "\033[0m" ); | 789 | printf("\033[0m"); |
752 | } | ||
753 | #endif | ||
754 | column += strlen(lpath) + 4; | ||
755 | free(lpath); | ||
756 | } | 790 | } |
791 | #endif | ||
792 | column += strlen(lpath) + 4; | ||
793 | free(lpath); | ||
757 | } | 794 | } |
758 | break; | 795 | } |
796 | break; | ||
759 | #ifdef CONFIG_FEATURE_LS_FILETYPES | 797 | #ifdef CONFIG_FEATURE_LS_FILETYPES |
760 | case LIST_FILETYPE: | 798 | case LIST_FILETYPE: |
761 | if (append != '\0') { | 799 | if (append != '\0') { |
762 | printf("%1c", append); | 800 | printf("%1c", append); |
763 | column++; | 801 | column++; |
764 | } | 802 | } |
765 | break; | 803 | break; |
766 | #endif | 804 | #endif |
767 | } | 805 | } |
768 | } | 806 | } |
769 | 807 | ||
770 | return(0); | 808 | return (0); |
771 | } | 809 | } |
772 | 810 | ||
773 | /*----------------------------------------------------------------------*/ | 811 | /*----------------------------------------------------------------------*/ |
@@ -780,19 +818,20 @@ extern int ls_main(int argc, char **argv) | |||
780 | int opt; | 818 | int opt; |
781 | int oi, ac; | 819 | int oi, ac; |
782 | char **av; | 820 | char **av; |
821 | |||
783 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 822 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
784 | struct winsize win = { 0, 0, 0, 0 }; | 823 | struct winsize win = { 0, 0, 0, 0 }; |
785 | #endif | 824 | #endif |
786 | 825 | ||
787 | disp_opts= DISP_NORMAL; | 826 | disp_opts = DISP_NORMAL; |
788 | style_fmt= STYLE_AUTO; | 827 | style_fmt = STYLE_AUTO; |
789 | list_fmt= LIST_SHORT; | 828 | list_fmt = LIST_SHORT; |
790 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 829 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
791 | sort_opts= SORT_NAME; | 830 | sort_opts = SORT_NAME; |
792 | sort_order= SORT_FORWARD; | 831 | sort_order = SORT_FORWARD; |
793 | #endif | 832 | #endif |
794 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 833 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
795 | time_fmt= TIME_MOD; | 834 | time_fmt = TIME_MOD; |
796 | #endif | 835 | #endif |
797 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 836 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
798 | ioctl(fileno(stdout), TIOCGWINSZ, &win); | 837 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |
@@ -801,7 +840,7 @@ extern int ls_main(int argc, char **argv) | |||
801 | if (win.ws_col > 0) | 840 | if (win.ws_col > 0) |
802 | terminal_width = win.ws_col - 1; | 841 | terminal_width = win.ws_col - 1; |
803 | #endif | 842 | #endif |
804 | nfiles=0; | 843 | nfiles = 0; |
805 | 844 | ||
806 | #ifdef CONFIG_FEATURE_LS_COLOR | 845 | #ifdef CONFIG_FEATURE_LS_COLOR |
807 | if (isatty(fileno(stdout))) | 846 | if (isatty(fileno(stdout))) |
@@ -811,108 +850,154 @@ extern int ls_main(int argc, char **argv) | |||
811 | /* process options */ | 850 | /* process options */ |
812 | while ((opt = getopt(argc, argv, "1AaCdgilnsx" | 851 | while ((opt = getopt(argc, argv, "1AaCdgilnsx" |
813 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 852 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
814 | "T:w:" | 853 | "T:w:" |
815 | #endif | 854 | #endif |
816 | #ifdef CONFIG_FEATURE_LS_FILETYPES | 855 | #ifdef CONFIG_FEATURE_LS_FILETYPES |
817 | "Fp" | 856 | "Fp" |
818 | #endif | 857 | #endif |
819 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 858 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
820 | "R" | 859 | "R" |
821 | #endif | 860 | #endif |
822 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 861 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
823 | "rSvX" | 862 | "rSvX" |
824 | #endif | 863 | #endif |
825 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 864 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
826 | "cetu" | 865 | "cetu" |
827 | #endif | 866 | #endif |
828 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS | 867 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS |
829 | "L" | 868 | "L" |
830 | #endif | 869 | #endif |
831 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 870 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
832 | "h" | 871 | "h" |
833 | #endif | 872 | #endif |
834 | "k")) > 0) { | 873 | "k")) > 0) { |
835 | switch (opt) { | 874 | switch (opt) { |
836 | case '1': style_fmt = STYLE_SINGLE; break; | 875 | case '1': |
837 | case 'A': disp_opts |= DISP_HIDDEN; break; | 876 | style_fmt = STYLE_SINGLE; |
838 | case 'a': disp_opts |= DISP_HIDDEN | DISP_DOT; break; | 877 | break; |
839 | case 'C': style_fmt = STYLE_COLUMNS; break; | 878 | case 'A': |
840 | case 'd': disp_opts |= DISP_NOLIST; break; | 879 | disp_opts |= DISP_HIDDEN; |
841 | case 'g': /* ignore -- for ftp servers */ break; | 880 | break; |
842 | case 'i': list_fmt |= LIST_INO; break; | 881 | case 'a': |
843 | case 'l': | 882 | disp_opts |= DISP_HIDDEN | DISP_DOT; |
844 | style_fmt = STYLE_LONG; | 883 | break; |
845 | list_fmt |= LIST_LONG; | 884 | case 'C': |
885 | style_fmt = STYLE_COLUMNS; | ||
886 | break; | ||
887 | case 'd': | ||
888 | disp_opts |= DISP_NOLIST; | ||
889 | break; | ||
890 | case 'g': /* ignore -- for ftp servers */ | ||
891 | break; | ||
892 | case 'i': | ||
893 | list_fmt |= LIST_INO; | ||
894 | break; | ||
895 | case 'l': | ||
896 | style_fmt = STYLE_LONG; | ||
897 | list_fmt |= LIST_LONG; | ||
846 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 898 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
847 | ls_disp_hr = FALSE; | 899 | ls_disp_hr = FALSE; |
848 | #endif | 900 | #endif |
849 | break; | 901 | break; |
850 | case 'n': list_fmt |= LIST_ID_NUMERIC; break; | 902 | case 'n': |
851 | case 's': list_fmt |= LIST_BLOCKS; break; | 903 | list_fmt |= LIST_ID_NUMERIC; |
852 | case 'x': disp_opts = DISP_ROWS; break; | 904 | break; |
905 | case 's': | ||
906 | list_fmt |= LIST_BLOCKS; | ||
907 | break; | ||
908 | case 'x': | ||
909 | disp_opts = DISP_ROWS; | ||
910 | break; | ||
853 | #ifdef CONFIG_FEATURE_LS_FILETYPES | 911 | #ifdef CONFIG_FEATURE_LS_FILETYPES |
854 | case 'F': list_fmt |= LIST_FILETYPE | LIST_EXEC; break; | 912 | case 'F': |
855 | case 'p': list_fmt |= LIST_FILETYPE; break; | 913 | list_fmt |= LIST_FILETYPE | LIST_EXEC; |
914 | break; | ||
915 | case 'p': | ||
916 | list_fmt |= LIST_FILETYPE; | ||
917 | break; | ||
856 | #endif | 918 | #endif |
857 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 919 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
858 | case 'R': disp_opts |= DISP_RECURSIVE; break; | 920 | case 'R': |
921 | disp_opts |= DISP_RECURSIVE; | ||
922 | break; | ||
859 | #endif | 923 | #endif |
860 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 924 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
861 | case 'r': sort_order |= SORT_REVERSE; break; | 925 | case 'r': |
862 | case 'S': sort_opts= SORT_SIZE; break; | 926 | sort_order |= SORT_REVERSE; |
863 | case 'v': sort_opts= SORT_VERSION; break; | 927 | break; |
864 | case 'X': sort_opts= SORT_EXT; break; | 928 | case 'S': |
929 | sort_opts = SORT_SIZE; | ||
930 | break; | ||
931 | case 'v': | ||
932 | sort_opts = SORT_VERSION; | ||
933 | break; | ||
934 | case 'X': | ||
935 | sort_opts = SORT_EXT; | ||
936 | break; | ||
865 | #endif | 937 | #endif |
866 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 938 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
867 | case 'e': list_fmt |= LIST_FULLTIME; break; | 939 | case 'e': |
868 | case 'c': | 940 | list_fmt |= LIST_FULLTIME; |
869 | time_fmt = TIME_CHANGE; | 941 | break; |
942 | case 'c': | ||
943 | time_fmt = TIME_CHANGE; | ||
870 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 944 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
871 | sort_opts= SORT_CTIME; | 945 | sort_opts = SORT_CTIME; |
872 | #endif | 946 | #endif |
873 | break; | 947 | break; |
874 | case 'u': | 948 | case 'u': |
875 | time_fmt = TIME_ACCESS; | 949 | time_fmt = TIME_ACCESS; |
876 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 950 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
877 | sort_opts= SORT_ATIME; | 951 | sort_opts = SORT_ATIME; |
878 | #endif | 952 | #endif |
879 | break; | 953 | break; |
880 | case 't': | 954 | case 't': |
881 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 955 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
882 | sort_opts= SORT_MTIME; | 956 | sort_opts = SORT_MTIME; |
883 | #endif | 957 | #endif |
884 | break; | 958 | break; |
885 | #endif | 959 | #endif |
886 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS | 960 | #ifdef CONFIG_FEATURE_LS_FOLLOWLINKS |
887 | case 'L': follow_links= TRUE; break; | 961 | case 'L': |
962 | follow_links = TRUE; | ||
963 | break; | ||
888 | #endif | 964 | #endif |
889 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 965 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
890 | case 'T': tabstops= atoi(optarg); break; | 966 | case 'T': |
891 | case 'w': terminal_width= atoi(optarg); break; | 967 | tabstops = atoi(optarg); |
968 | break; | ||
969 | case 'w': | ||
970 | terminal_width = atoi(optarg); | ||
971 | break; | ||
892 | #endif | 972 | #endif |
893 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 973 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
894 | case 'h': ls_disp_hr = TRUE; break; | 974 | case 'h': |
975 | ls_disp_hr = TRUE; | ||
976 | break; | ||
895 | #endif | 977 | #endif |
896 | case 'k': break; | 978 | case 'k': |
897 | default: | 979 | break; |
898 | goto print_usage_message; | 980 | default: |
981 | goto print_usage_message; | ||
899 | } | 982 | } |
900 | } | 983 | } |
901 | 984 | ||
902 | /* sort out which command line options take precedence */ | 985 | /* sort out which command line options take precedence */ |
903 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 986 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
904 | if (disp_opts & DISP_NOLIST) | 987 | if (disp_opts & DISP_NOLIST) |
905 | disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */ | 988 | disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */ |
906 | #endif | 989 | #endif |
907 | #if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES) | 990 | #if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES) |
908 | if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME; | 991 | if (time_fmt & TIME_CHANGE) |
909 | if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME; | 992 | sort_opts = SORT_CTIME; |
993 | if (time_fmt & TIME_ACCESS) | ||
994 | sort_opts = SORT_ATIME; | ||
910 | #endif | 995 | #endif |
911 | if (style_fmt != STYLE_LONG) | 996 | if (style_fmt != STYLE_LONG) |
912 | list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */ | 997 | list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */ |
913 | #ifdef CONFIG_FEATURE_LS_USERNAME | 998 | #ifdef CONFIG_FEATURE_LS_USERNAME |
914 | if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC)) | 999 | if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC)) |
915 | list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */ | 1000 | list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */ |
916 | #endif | 1001 | #endif |
917 | 1002 | ||
918 | /* choose a display format */ | 1003 | /* choose a display format */ |
@@ -926,42 +1011,42 @@ extern int ls_main(int argc, char **argv) | |||
926 | * just holds the pointers- we don't move the date the pointers | 1011 | * just holds the pointers- we don't move the date the pointers |
927 | * point to. | 1012 | * point to. |
928 | */ | 1013 | */ |
929 | ac= argc - optind; /* how many cmd line args are left */ | 1014 | ac = argc - optind; /* how many cmd line args are left */ |
930 | if (ac < 1) { | 1015 | if (ac < 1) { |
931 | av= (char **)xcalloc((size_t)1, (size_t)(sizeof(char *))); | 1016 | av = (char **) xcalloc((size_t) 1, (size_t) (sizeof(char *))); |
932 | av[0]= xstrdup("."); | 1017 | av[0] = xstrdup("."); |
933 | ac=1; | 1018 | ac = 1; |
934 | } else { | 1019 | } else { |
935 | av= (char **)xcalloc((size_t)ac, (size_t)(sizeof(char *))); | 1020 | av = (char **) xcalloc((size_t) ac, (size_t) (sizeof(char *))); |
936 | for (oi=0 ; oi < ac; oi++) { | 1021 | for (oi = 0; oi < ac; oi++) { |
937 | av[oi]= argv[optind++]; /* copy pointer to real cmd line arg */ | 1022 | av[oi] = argv[optind++]; /* copy pointer to real cmd line arg */ |
938 | } | 1023 | } |
939 | } | 1024 | } |
940 | 1025 | ||
941 | /* now, everything is in the av array */ | 1026 | /* now, everything is in the av array */ |
942 | if (ac > 1) | 1027 | if (ac > 1) |
943 | disp_opts |= DISP_DIRNAME; /* 2 or more items? label directories */ | 1028 | disp_opts |= DISP_DIRNAME; /* 2 or more items? label directories */ |
944 | 1029 | ||
945 | /* stuff the command line file names into an dnode array */ | 1030 | /* stuff the command line file names into an dnode array */ |
946 | dn=NULL; | 1031 | dn = NULL; |
947 | for (oi=0 ; oi < ac; oi++) { | 1032 | for (oi = 0; oi < ac; oi++) { |
948 | cur= (struct dnode *)xmalloc(sizeof(struct dnode)); | 1033 | cur = (struct dnode *) xmalloc(sizeof(struct dnode)); |
949 | cur->fullname= xstrdup(av[oi]); | 1034 | cur->fullname = xstrdup(av[oi]); |
950 | cur->name= cur->fullname; | 1035 | cur->name = cur->fullname; |
951 | if (my_stat(cur)) | 1036 | if (my_stat(cur)) |
952 | continue; | 1037 | continue; |
953 | cur->next= dn; | 1038 | cur->next = dn; |
954 | dn= cur; | 1039 | dn = cur; |
955 | nfiles++; | 1040 | nfiles++; |
956 | } | 1041 | } |
957 | 1042 | ||
958 | /* now that we know how many files there are | 1043 | /* now that we know how many files there are |
959 | ** allocate memory for an array to hold dnode pointers | 1044 | ** allocate memory for an array to hold dnode pointers |
960 | */ | 1045 | */ |
961 | dnp= dnalloc(nfiles); | 1046 | dnp = dnalloc(nfiles); |
962 | for (i=0, cur=dn; i<nfiles; i++) { | 1047 | for (i = 0, cur = dn; i < nfiles; i++) { |
963 | dnp[i]= cur; /* save pointer to node in array */ | 1048 | dnp[i] = cur; /* save pointer to node in array */ |
964 | cur= cur->next; | 1049 | cur = cur->next; |
965 | } | 1050 | } |
966 | 1051 | ||
967 | 1052 | ||
@@ -969,12 +1054,13 @@ extern int ls_main(int argc, char **argv) | |||
969 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 1054 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
970 | shellsort(dnp, nfiles); | 1055 | shellsort(dnp, nfiles); |
971 | #endif | 1056 | #endif |
972 | if (nfiles > 0) showfiles(dnp, nfiles); | 1057 | if (nfiles > 0) |
1058 | showfiles(dnp, nfiles); | ||
973 | } else { | 1059 | } else { |
974 | dnd= splitdnarray(dnp, nfiles, SPLIT_DIR); | 1060 | dnd = splitdnarray(dnp, nfiles, SPLIT_DIR); |
975 | dnf= splitdnarray(dnp, nfiles, SPLIT_FILE); | 1061 | dnf = splitdnarray(dnp, nfiles, SPLIT_FILE); |
976 | dndirs= countdirs(dnp, nfiles); | 1062 | dndirs = countdirs(dnp, nfiles); |
977 | dnfiles= nfiles - dndirs; | 1063 | dnfiles = nfiles - dndirs; |
978 | if (dnfiles > 0) { | 1064 | if (dnfiles > 0) { |
979 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 1065 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
980 | shellsort(dnf, dnfiles); | 1066 | shellsort(dnf, dnfiles); |
@@ -988,7 +1074,7 @@ extern int ls_main(int argc, char **argv) | |||
988 | showdirs(dnd, dndirs); | 1074 | showdirs(dnd, dndirs); |
989 | } | 1075 | } |
990 | } | 1076 | } |
991 | return(status); | 1077 | return (status); |
992 | 1078 | ||
993 | print_usage_message: | 1079 | print_usage_message: |
994 | show_usage(); | 1080 | show_usage(); |