summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-02-05 19:52:31 +0000
committerPádraig Brady <P@draigBrady.com>2023-04-08 12:19:40 +0100
commitce630dfc7ef32ff7e35c627bd061a45ce9053d9d (patch)
treee198bd7070f7ce510498c61af2243096e4913104 /tests
parentf6c21f6d3addb6461c41af612e73fbb15d21545f (diff)
downloadcoreutils-ce630dfc7ef32ff7e35c627bd061a45ce9053d9d.tar.gz
wc: ensure we update file offset
* src/wc.c (wc): Update the offset when not reading, and do read if we can't update the offset. * tests/misc/wc-proc.sh: Add a test case. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/61300
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/wc-proc.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/misc/wc-proc.sh b/tests/misc/wc-proc.sh
index 5eb43b982..2307f2c38 100755
--- a/tests/misc/wc-proc.sh
+++ b/tests/misc/wc-proc.sh
@@ -42,6 +42,18 @@ cat <<\EOF > exp
EOF
compare exp out || fail=1
+# Ensure we update the offset even when not reading,
+# which wasn't the case from coreutils-8.27 to coreutils-9.2
+{ wc -c; wc -c; } < no_read > out || fail=1
+{ wc -c; wc -c; } < do_read >> out || fail=1
+cat <<\EOF > exp
+2
+0
+1048576
+0
+EOF
+compare exp out || fail=1
+
# Ensure we don't read too much when reading,
# as was the case on 32 bit systems
# from coreutils-8.24 to coreutils-9.1