mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-10-24 02:08:57 +03:00
fold: fix backspace handling with multi-cell characters
* src/fold.c (adjust_column): Clamp the column decrement to 0. * tests/fold/fold-characters.sh: Add a test case. * NEWS: Mention the bug fix.
This commit is contained in:
4
NEWS
4
NEWS
@@ -13,6 +13,10 @@ GNU coreutils NEWS -*- outline -*-
|
||||
the \u0085 (next line) character as a separator on non-GLIBC platforms.
|
||||
[bug introduced in coreutils-9.11]
|
||||
|
||||
'fold' no longer prematurely wraps lines with a wide character towards
|
||||
the start of a line, followed by multiple backspaces.
|
||||
[bug introduced in coreutils-9.8]
|
||||
|
||||
'realpath' without -s, or 'readlink' with -e,-f,-m no longer
|
||||
loop infinitely when resolving a symbolic link which
|
||||
resolves to a path beginning with the symbolic link itself.
|
||||
|
||||
@@ -117,10 +117,7 @@ adjust_column (size_t column, mcel_t g)
|
||||
if (counting_mode != COUNT_BYTES)
|
||||
{
|
||||
if (g.ch == '\b')
|
||||
{
|
||||
if (column > 0)
|
||||
column -= last_character_width;
|
||||
}
|
||||
column -= MIN (last_character_width, column);
|
||||
else if (g.ch == '\r')
|
||||
column = 0;
|
||||
else if (g.ch == '\t')
|
||||
|
||||
@@ -92,4 +92,9 @@ compare exp4 out4 || fail=1
|
||||
# Check bad character at EOF
|
||||
test $(env printf '\xC3' | fold | wc -c) = 1 || fail=1
|
||||
|
||||
# Ensure backspace clamps at position 0
|
||||
# From v9.8 to v9.12 inclusive, an internal unsigned could wrap,
|
||||
# causing premature line wrapping.
|
||||
test $(env printf 'A\uB250\b\bB\n' | fold -w80 | wc -l) = 1 || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Reference in New Issue
Block a user