Commit 746474c9 authored by Natanael Copa's avatar Natanael Copa

main/busybox: backport fix for cat -e and cat -v

parent 1723be1d
From d80eecb86812c1fbda652f9b995060c26ba0b155 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Sun, 29 Apr 2018 14:05:43 +0200
Subject: [PATCH] cat: fix cat -e and cat -v erroneously numbering 1st line
function old new delta
cat_main 418 421 +3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
coreutils/cat.c | 6 +++---
testsuite/cat.tests | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
create mode 100755 testsuite/cat.tests
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 5f02233ca..fb735f994 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -112,10 +112,10 @@ static int catv(unsigned opts, char **argv)
int retval = EXIT_SUCCESS;
int fd;
#if ENABLE_FEATURE_CATN
- unsigned lineno = 0;
- unsigned eol_char = (opts & (CAT_OPT_n|CAT_OPT_b)) ? '\n' : 0x100;
+ bool eol_seen = (opts & (CAT_OPT_n|CAT_OPT_b));
+ unsigned eol_char = (eol_seen ? '\n' : 0x100);
unsigned skip_num_on = (opts & CAT_OPT_b) ? '\n' : 0x100;
- bool eol_seen = 1;
+ unsigned lineno = 0;
#endif
BUILD_BUG_ON(CAT_OPT_e != VISIBLE_ENDLINE);
diff --git a/testsuite/cat.tests b/testsuite/cat.tests
new file mode 100755
index 000000000..404ebedeb
--- /dev/null
+++ b/testsuite/cat.tests
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Copyright 2018 by Denys Vlasenko <vda.linux@googlemail.com>
+# Licensed under GPLv2, see file LICENSE in this source tree.
+
+. ./testing.sh
+
+# testing "description" "command" "result" "infile" "stdin"
+testing 'cat -e' \
+ 'cat -e' \
+ 'foo$\n' \
+ '' \
+ 'foo\n'
+
+testing 'cat -v' \
+ 'cat -v' \
+ 'foo\n' \
+ '' \
+ 'foo\n'
+
+exit $FAILCOUNT
--
2.17.0
......@@ -3,7 +3,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.28.2
pkgrel=4
pkgrel=5
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
......@@ -39,6 +39,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
fix-cpio-symlinks.patch
0001-grep-fix-echo-aa-busybox-grep-F-w-a-should-not-match.patch
0001-cat-fix-cat-e-and-cat-v-erroneously-numbering-1st-li.patch
0001-nsenter-Rename-network-option-to-net.patch
0002-nsenter-fix-parsing-of-t-S-and-G-options.patch
......@@ -205,6 +206,7 @@ a96aa81d2f0104b5c28f02e80b3f77dbce77af93c174c09015a34850474d69e42c160fc8061c62f0
d90d6b3406760fe3df6dbed46a0f4d1c02a69d5184ebc86d8c1692bc4576532127283ba3ff9a81e64f3660c279b8ee324dac7a426350873c45957067648651c6 0017-ifupdown-do-not-fail-if-interface-disappears-during-.patch
65c11538056b6bd782b6195252a2a49f3b374e285a04f3296f708bb7da02b87435c34d43eaf80f1961167f55106fc2e4d5843d0c27cf06e6156ff8fabe642ac8 fix-cpio-symlinks.patch
bc16f8ee0369274aa145d050cf45d7b0f7e9cd569b40e327b634f442851fff23a7decee0ba7822535bb6e195a0f8ab8a29fe5899cd909abda8d60e4247b462d9 0001-grep-fix-echo-aa-busybox-grep-F-w-a-should-not-match.patch
0dbe3ee424c0a6e4aba4f551f6b6b9ee087655a03747a40906961b141d40b1cbb2345438f17887a1b78d880cb3a7ad0116936dd7c05e95160febfd299423e83b 0001-cat-fix-cat-e-and-cat-v-erroneously-numbering-1st-li.patch
d2364e20b12c5215c4baecc3c6faf903e6e1e2bee95d697af047d680e9d57e7aeea54c8584d062d92daa0ea64898b502fbae010b22ab236ec4018966b74deeec 0001-nsenter-Rename-network-option-to-net.patch
0dbffae82b62317fc4144a01940ebc601e58b0e14eb8338bc42db79407d0b74dbe9f0f44758b9a5baa399eb90f8e8ee8f9c344bebd1b03bdd2ce520cb2b28d5e 0002-nsenter-fix-parsing-of-t-S-and-G-options.patch
a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c acpid.logrotate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment