Commit 549deab caused this sequence of commands:
mkdir foo
cd foo
touch a b
echo "./"*
to return './*' instead of the expected './a ./b'. The problem
was caused by the backport of commit 880d952 from dash. In dash
the issue was fixed by two further commits by Herbert Xu:
<d6d06ff> [EXPAND] Fixed non-leading slash treatment in expmeta
<36f0fa8> [EXPAND] Fix slash treatment in expmeta
(See git://git.kernel.org/pub/scm/utils/dash/dash.git)
Apply these fixes to BusyBox ash, thus causing the new test
glob3.tests to succeed.
function old new delta
expmeta 469 528 +59
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Test corner cases too like looking for an empty prefix etc.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Similar to the "big" util-linux version. For !DMESG_PRETTY, the option is accepted
(but ignored) as well, for compatibility reasons.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
When a static interface with explicit gateway and metric in /etc/network/interfaces
is enabled using 'ifup', and further, the BusyBox 'ip' applet is enabled, the
following error message appears at the console (and no default route is added):
ip: either "to" is duplicate, or "prio" is garbage
Tracing ifup reveals that it is attempting to run the following shell command:
ip route add default via <GW> dev <DEVICE> prio <METRIC>
'ip' does not understand the 'prio' argument, causing this error. With 'metric',
it works fine.
Signed-off-by: Alex Dowad <alexinbeijing@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Static build with CONFIG_PAM fails on Debian Jessie due to undefined
references to libdl and libaudit.
Static build without pam, but with libcrypt required fails as well due
to undefined references to libpthread.
Fix these two cases by adding the missing libraries to LDLIBS when
appropriate.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Since there is no interest in merging a config option for WANT_TIMING,
remove the parts of code depending on it altogether.
While we're at it: add some newlines to improve readability.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
In the initial submission struct bbunit_listelem was manipulated by
custom list functions implemented in bbunit.c. Since the tests are now
added to the list by llist_add_to_end(), which allocates the llist_t
objects behind the scenes, there's no need for the *next field.
function old new delta
unit_main 142 141 -1
bbunit_strrstr_elem 24 16 -8
bbunit_obscure_weak_pass_elem 24 16 -8
bbunit_obscure_strong_pass_elem 24 16 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-25) Total: -25 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Commit 1ecb996 attempted to make read_lines() use the last column of
the terminal (as re_wrap() did). There were two problems with this:
- The size of the buffer allocated for lines wasn't increased to allow
for the extra character.
- The test for width overflow was moved after the point where the
next character was added to the buffer. This caused a buffer overflow
in certain circumstances.
For example, if the line beyond the end of the display was wider than
the display read_lines() would initially read the partial line into a
buffer. When the user moved down read_lines() would be called again
to ensure the rest of the line was read. This would place the next
character in the partial line before checking for overflow.
This can be fixed by moving the test for overflow back to where it was
before commit 1ecb996 and changing the comparison to `>` rather than
`>=`.
There are two other places where buffers are created without allowing
for width+1 characters.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
A mailing list thread in September 2013 discussed changing the string
returned by the non-POSIX 'uname -o' option. Nothing ever came of this
because there was no agreement as to what the string should be.
Make the string configurable so that people can decide for themselves.
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Test explicitly for REOPEN flags: update_num_lines is called
unconditionally so (num_lines != NOT_REGULAR_FILE) is also true when
num_lines contains a valid number of lines.
The call to fstat doesn't need to be in #if ENABLE_FEATURE_LESS_FLAGS:
the whole function is already in such a test.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add testcases for -B and single line changes.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Fix -B with single line changes. They were always ignored regardless
if they were blank or not.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
When read_lines tests whether a character will fit on the current
line it checks the *next* character but in case of overflow doesn't
display the *current* one. This results in the last column of the
terminal never being used.
The test in re_wrap (used when the terminal width changes or line
numbers are enabled/disabled) is different: it does allow the use
of the final column.
function old new delta
read_lines 764 770 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0) Total: 6 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Much of the code refers to lines using indices into the flines
array (which splits lines into portions that fit on the terminal).
In some cases this is wrong and actual line numbers should be
used:
- when lines are being truncated rather than wrapped (-S flag)
- when line numbers have been entered by the user
Also fix a bug in numeric input and improve the display at EOF.
function old new delta
goto_lineno - 111 +111
cap_cur_fline - 101 +101
buffer_to_line - 56 +56
buffer_up 35 66 +31
less_main 2606 2615 +9
goto_match 125 127 +2
buffer_down 81 56 -25
buffer_line 64 - -64
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 3/1 up/down: 310/-89) Total: 221 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add a function to package the test that detects whether enough has
been read from the file to allow a screenful to be displayed.
Also use this to determine when to display '(END)' in the status
line. The previous code was incomplete and didn't handle truncated
lines (-S flag) properly.
function old new delta
at_end - 63 +63
status_print 111 109 -2
read_lines 819 764 -55
getch_nowait 319 264 -55
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 63/-112) Total: -49 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Move the code to detect non-regular files to the point where the
file is being opened. If num_lines == READING_FILE guarantees
that the file is regular.
Detect when a file becomes unreadable between it first being opened
and the call to update_num_lines. Mark the file as being non-regular
so we don't try that again.
function old new delta
reinitialize 197 245 +48
update_num_lines 159 127 -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32) Total: 16 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Currently when you disable fancy echo, escape sequences are hardcoded
enabled (e.g. as if you used `echo -e` all the time). The opposite
behavior is more desirable (always disable -e support) because:
* This seems to contradict the spirit of the kconfig help text (where
it says enable support for -n/-e flags), although you could say that
we aren't supporting the -e flag directly as `echo -e` will show the
-e flag.
* POSIX makes escape sequences optional, and even says they are there
only on XSI-conformant systems.
* It saves space (~100 bytes on x86_64).
* It makes things faster!
* It makes it behave more like bash where you need an explicit -e flag
in order for escape sequences to be interpreted.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
In commit b5c7220e7b
"fbset: respect rgba configuration lines in fb.modes"
I somehow managed to swap the offset/length markers around.
The man page for fb.modes says it should be offset/length
not length/offset as I was accidentally parsing it.
As my fb.modes file was also reversed I didn't notice
until I tried someone elses fb.modes file. Mea culpa.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
While RFC1035 recommends a label not to start with a number, there is
actually no such limitation in dns. One may buy a domain name like
0x1.net and use it.
This commit remove this check and allow a user to use such domains.
Signed-off-by: Arthur Gautier <baloo@gandi.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Make verbose status messages (-m/-M flags) behave more like the
real `less` command:
- fix display of line numbers so they're correct whether lines are
being truncated (-S flag) or wrapped.
- don't display total lines or percentage when lines are read from
stdin: we don't have that information until we reach EOF. When
we do reach EOF the additional information is displayed.
- when lines are read from a file count the total number of lines
so that we can display percentages. Counting lines is avoided
until the information is actually needed. If the user pages to
EOF the separate read pass can be avoided entirely.
Fixes Bug 7586
function old new delta
m_status_print 195 382 +187
safe_lineno - 35 +35
reinitialize 172 182 +10
read_lines 675 685 +10
buffer_fill_and_print 178 169 -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 242/-9) Total: 233 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Based on the patch by Ari Sundholm <ari@tuxera.com>
function old new delta
sync_main 20 163 +143
packed_usage 30653 30673 +20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 163/0) Total: 163 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Introduce a library routine to package the idiom:
p = xmalloc(b, n);
memcpy(p, b, n);
and use it where possible. The example in traceroute used xzalloc
but it didn't need to.
function old new delta
xmemdup - 32 +32
last_main 834 826 -8
make_device 2321 2311 -10
common_traceroute_main 3698 3685 -13
readtoken1 3182 3168 -14
procps_scan 1222 1206 -16
forkchild 655 638 -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Lines are rewrapped when the terminal width changes or line numbers
are enabled/disabled. The current calculation always adds eight to
the line length for a tab whereas it should only add enough to move
to the next tab stop.
This doesn't affect the display of lines, which is handled elsewhere
and gets tab stops right, but it does cause lines to be wrapped at
the wrong position.
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Line numbers are displayed incorrectly on lines that have a search
pattern highlighted. The problem can be fixed by moving the call to
lineno_str in print_found above the while loop that alters the value
of the line pointer. However, a more substantial rewrite results in
savings.
function old new delta
buffer_print 688 697 +9
.rodata 156077 156045 -32
lineno_str 85 - -85
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117) Total: -108 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The -S flag, to cause long lines to be truncated, was enabled by
FEATURE_LESS_DASHCMD. This is non-obvious and -S is useful even
if the '-' command isn't enabled.
function old new delta
.rodata 156045 156077 +32
packed_usage 30223 30244 +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0) Total: 53 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Now that the only thing protected by setjmp/longjmp is the saved string,
we can allocate it on the stack to get rid of the jump.
Based on commit bd35d8e from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.
function old new delta
readtoken1 3182 3116 -66
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-66) Total: -66 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>