mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-26 15:03:22 +00:00
diff: don’t backspace before first column
* src/util.c (output_1_line): When expanding tabs, treat backspace before column 1 as no-op, since that’s what most devices do. * tests/expand-tabs: New test. * tests/Makefile.am (TESTS): Add it.
This commit is contained in:
parent
43b7a667e5
commit
6e091776f8
@ -1397,12 +1397,15 @@ output_1_line (char const *base, char const *limit, char const *flag_format,
|
||||
break;
|
||||
|
||||
case '\b':
|
||||
column--;
|
||||
if (column < 0)
|
||||
if (0 < column)
|
||||
column--;
|
||||
else if (0 < tab)
|
||||
{
|
||||
tab--;
|
||||
column = tab_size - 1;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
putc (c, out);
|
||||
break;
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ TESTS = \
|
||||
colliding-file-names \
|
||||
diff3 \
|
||||
excess-slash \
|
||||
expand-tabs \
|
||||
help-version \
|
||||
ifdef \
|
||||
invalid-re \
|
||||
|
||||
19
tests/expand-tabs
Executable file
19
tests/expand-tabs
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# Test tab expansion.
|
||||
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
|
||||
fail=0
|
||||
|
||||
cat >exp <<'EOF' || framework_failure_
|
||||
0a1
|
||||
> x
|
||||
EOF
|
||||
|
||||
for p in '\b\tx\n' '\b x\n' '\b \tx\n'; do
|
||||
printf "$p" | returns_ 1 diff -t /dev/null - >out || fail=1
|
||||
done
|
||||
|
||||
compare exp out || fail=1
|
||||
|
||||
Exit $fail
|
||||
Loading…
x
Reference in New Issue
Block a user