Commit Graph

260 Commits

Author SHA1 Message Date
Laurent Bercot
2599937c4e ls: fix support for long options when FEATURE_LS_COLOR is deselected
Declaration of ls_longopts and initialization of applet_long_options
were incorrectly guarded with ENABLE_FEATURE_LS_COLOR; that yielded a
"ls: NO_OPT: \xff" error message when long options were selected and
color support was not. This patch ensures long options are
initialized separately from color support.

Signed-off-by: Laurent Bercot <ska-dietlibc@skarnet.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-05-26 16:50:53 +02:00
Denys Vlasenko
b13b618335 ftpd/ls: show directories first
Old TODO finally done

function                                             old     new   delta
ls_main                                              548     568     +20
packed_usage                                       31116   31097     -19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-25 04:52:45 +01:00
Denys Vlasenko
9a64c3337c ls: convert DISP_DIRNAME to a bool variable
function                                             old     new   delta
ls_main                                              553     548      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 20:46:12 +01:00
Denys Vlasenko
ccc1699e3e ls: get rid of opt_flags[], handle -l1c through option_mask32
function                                             old     new   delta
display_single                                       885     888      +3
scan_and_display_dirs_recur                          496     486     -10
opt_flags                                             11       -     -11
ls_main                                              618     553     -65
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 3/-86)             Total: -83 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 20:43:06 +01:00
Denys Vlasenko
92c6898e10 ls: handle -x through option_mask32, remove default -C from --help
function                                             old     new   delta
packed_usage                                       31024   31002     -22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 20:21:14 +01:00
Denys Vlasenko
4cde4cca65 ls: handle -d and -R through option_mask32
function                                             old     new   delta
scan_and_display_dirs_recur                          545     550      +5
display_single                                      1039    1044      +5
append_char                                           67      68      +1
display_files                                        399     396      -3
ls_main                                              736     717     -19
opt_flags                                             68      11     -57
.rodata                                           168864  168784     -80
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/4 up/down: 11/-159)          Total: -148 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 20:08:22 +01:00
Denys Vlasenko
96d9c5bdbd ls: handle -p and -F through option_mask32
function                                             old     new   delta
display_single                                      1039    1044      +5
append_char                                           67      68      +1
display_files                                        399     396      -3
scan_and_display_dirs_recur                          545     541      -4
ls_main                                              736     722     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 6/-21)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 19:56:13 +01:00
Denys Vlasenko
51b01fda30 ls: LIST_ID_NAME/ID_NUMERIC/LOPT/LONG are the same, merge as LONG
Also, handle -n and --full-time using option_mask32

function                                             old     new   delta
scan_and_display_dirs_recur                          548     545      -3
display_single                                      1053    1039     -14
ls_main                                              777     736     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-58)             Total: -58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 19:42:12 +01:00
Denys Vlasenko
a1cbaca1ba ls: make -Z output compatible with GNU coreutils 8.25
This also makes it clear that LIST_MODEBITS == LIST_LOPT

function                                             old     new   delta
ls_main                                              752     777     +25
display_files                                        400     399      -1
display_single                                      1055    1053      -2
my_stat                                              320     317      -3
packed_usage                                       32311   32280     -31
.rodata                                           168895  168864     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 25/-68)            Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 19:30:14 +01:00
Denys Vlasenko
2c3131d88e ls: LIST_NLINKS/SIZE/DATE_TIME/SYMLINK are always the same, merge as LIST_LOPT
They are always set and cleared together

function                                             old     new   delta
append_char                                           69      68      -1
display_single                                       910     908      -2
ls_main                                              677     664     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16)             Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 19:05:11 +01:00
Denys Vlasenko
5d43ddc59b ls: handle -s through option_mask32
function                                             old     new   delta
scan_and_display_dirs_recur                          493     494      +1
sort_and_display_files                               424     423      -1
ls_main                                              682     677      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 18:43:43 +01:00
Denys Vlasenko
b60686cc2a ls: handle -i through option_mask32
function                                             old     new   delta
sort_and_display_files                               420     424      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 18:34:11 +01:00
Denys Vlasenko
f5bd6f631c ls: handle -a and -A through option_mask32
function                                             old     new   delta
ls_main                                              685     682      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 18:24:05 +01:00
Denys Vlasenko
11540a8da4 ls: handle all sort options through option_mask32
function                                             old     new   delta
packed_usage                                       31007   31024     +17
my_stat                                              318     324      +6
sort_and_display_files                               419     420      +1
print_name                                           216     217      +1
sortcmp                                              228     216     -12
opt_flags                                             96      64     -32
ls_main                                              732     685     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 25/-91)            Total: -66 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-23 18:01:48 +01:00
Denys Vlasenko
e1f90d13fa ls: -1 should be ignored by -l (and options which imply -l)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-22 22:02:19 +01:00
Denys Vlasenko
f580baf94a ls: more correct handling of -c, -u
function                                             old     new   delta
my_stat                                              302     318     +16
packed_usage                                       30977   30969      -8
display_single                                       928     910     -18
sortcmp                                              258     228     -30
ls_main                                              776     732     -44
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 16/-100)           Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-22 19:02:57 +01:00
Denys Vlasenko
194b2ebd2a ls: replace -e with --full-time, add --group-directories-first, delete -K
-K and -e were non-standard

function                                             old     new   delta
static.ls_longopts                                     9      47     +38
ls_main                                              748     776     +28
display_single                                       901     928     +27
sortcmp                                              254     258      +4
ls_options                                            32      31      -1
opt_flags                                            100      96      -4
packed_usage                                       31032   30977     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 97/-60)             Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-22 17:32:20 +01:00
Denys Vlasenko
ed15dde60a Move FEATURE_AUTOWIDTH config option to two applets which use it
No code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 16:35:52 +01:00
Denys Vlasenko
f560422fa0 Big cleanup in config help and description
Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
af3f420116 Convert all coreutils/* applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 14:46:56 +01:00
Denys Vlasenko
47cfbf32fd *: add most of the required setup_common_bufsiz() calls
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:18:48 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Denys Vlasenko
ea351b9742 ls: fix columnar output. Closes 8731
In coreutils/ls.c, 1.19 introduced commit
2f7d9e8903, removing the variable tabstops and
hard coding the column separation to 2 characters, but was not done correctly.
The column_width assumes a gap of 1 character, so the computed number of
columns exceeds the terminal width when many small files are encountered.

A minor problem but surprisingly annoying.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-06 17:53:11 +01:00
Denys Vlasenko
641caaec3d libbb: factor out code which queries screen width
function                                             old     new   delta
get_terminal_width                                     -      17     +17
stty_main                                           1196    1197      +1
pstree_main                                          321     319      -2
ls_main                                              735     731      -4
watch_main                                           232     225      -7
bb_progress_update                                   714     706      -8
ps_main                                              555     543     -12
run_applet_and_exit                                  708     695     -13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/6 up/down: 18/-46)            Total: -28 byte

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 01:44:22 +02:00
Denys Vlasenko
c5beaa08eb ls: heed compiler warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-23 15:25:58 +01:00
Denys Vlasenko
0cb981c5e2 ls: trivial code shrink
function                                             old     new   delta
display_single                                       914     893     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-18 11:29:07 +01:00
Denys Vlasenko
8e92df15b5 ls: fix year 9999 bug :)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-16 15:36:25 +01:00
Denys Vlasenko
fca0ee5959 ls: make "ls -s DIR" show total too. Clases 4946
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27 15:40:26 +01:00
Denys Vlasenko
6967578728 whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 01:34:48 +01:00
Denys Vlasenko
b47b3ce1bd randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-10 00:51:29 +02:00
Denys Vlasenko
1e18a01fa2 ls: fix HAVE_STRVERSCMP check; add check for older uclibc versions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-21 17:12:52 +02:00
Denys Vlasenko
561f9c8585 Add HAVE_STRVERSCMP, guard the only usage of strverscmp with #ifdef
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-21 16:38:29 +02:00
Denys Vlasenko
8ea683d5df ls: fix comment about -p (it's compatible now)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-13 02:24:18 +02:00
Denys Vlasenko
f194cc1f33 ls: make -v and -X actually work as intended
function                                             old     new   delta
strverscmp                                             -     236    +236
sortcmp                                              186     254     +68
static.result_type                                     -      60     +60
static.next_state                                     12      16      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-13 02:13:42 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Denys Vlasenko
8dd29da2c6 ls: code shrink
function                                             old     new   delta
sort_and_display_files                                 -     427    +427
scan_and_display_dirs_recur                          497     488      -9
ls_main                                              765     735     -30
display_files                                        422       -    -422
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 427/-461)          Total: -34 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 17:55:08 +02:00
Denys Vlasenko
4029e21b37 ls: reorder and rename functions. No code changes
function                                             old     new   delta
display_single                                         -     931    +931
scan_and_display_dirs_recur                            -     497    +497
display_files                                          -     422    +422
showfiles                                            422       -    -422
showdirs                                             497       -    -497
list_single                                          931       -    -931
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 0/0 up/down: 1850/-1850)          Total: 0 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 17:28:46 +02:00
Denys Vlasenko
2a81639534 ls: reduce memory consumption and speed up (don't do redundant [l]stat)
function                                             old     new   delta
my_stat                                              110     278    +168
splitdnarray                                         120     118      -2
ls_main                                              769     765      -4
list_single                                          961     931     -30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 168/-36)           Total: 132 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 17:28:09 +02:00
Denys Vlasenko
66ca241dca ls: avoid forward declaration. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 17:27:36 +02:00
Denys Vlasenko
d27ac299eb ls: code shrink
function                                             old     new   delta
list_single                                          990     961     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 17:27:15 +02:00
Denys Vlasenko
279a7ac04e ls: fix help text: -w N is optional
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 18:44:51 +02:00
Denys Vlasenko
4ad95e6b0e ls: fix -p help text, improve comments and define names
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 18:40:59 +02:00
Denys Vlasenko
fa9126e689 ls: better help text for -a and -A
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-03 01:27:49 +02:00
Denys Vlasenko
ea684c6aaf ls: fix handling of symlinks by option -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-12 03:12:36 +01:00
Denys Vlasenko
3b28dae17d ls: widen -s (1k blocks) column from 4 to 6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-01 05:37:41 +01:00
Denys Vlasenko
26d11b8133 ls: -g implies -l
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-28 12:38:08 +01:00
Denys Vlasenko
9f368e38fb ls: fix bits for -T, -w and --color; make -n imply -l; fix comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-28 12:16:10 +01:00
Denys Vlasenko
cd387f2554 ls: fix one-bit-off which caused -H to behave as -h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-27 04:10:00 +01:00
James Youngman
a4bc10cec7 ls: remove redundant constants LIST_FILENAME and LIST_SHORT
LIST_FILENAME is always true and LIST_SHORT affects nothing.

Signed-off-by: James Youngman <jay@gnu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-20 01:36:16 +01:00
Denys Vlasenko
982aa263a0 ls: add support for -H
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-19 21:54:39 +01:00