summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2017-03-23 17:58:32 +0100
committerDenys Vlasenko2017-03-23 17:58:32 +0100
commitf4a670a9110426e9153e7d5f6e7b7d1f1eac6195 (patch)
tree23087c739dfae9c35fdfb8f51e84a08d404b4d90 /coreutils
parentf1db95abfbe3621241d1f797d312d7b0981fbac9 (diff)
downloadbusybox-f4a670a9110426e9153e7d5f6e7b7d1f1eac6195.zip
busybox-f4a670a9110426e9153e7d5f6e7b7d1f1eac6195.tar.gz
paste: delimiter list use should restart for each new output line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/paste.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/coreutils/paste.c b/coreutils/paste.c
index 54e15c9..d929d6a 100644
--- a/coreutils/paste.c
+++ b/coreutils/paste.c
@@ -36,11 +36,12 @@ static void paste_files(FILE** files, int file_cnt, char* delims, int del_cnt)
{
char *line;
char delim;
- int del_idx = 0;
int active_files = file_cnt;
int i;
while (active_files > 0) {
+ int del_idx = 0;
+
for (i = 0; i < file_cnt; ++i) {
if (files[i] == NULL)
continue;
@@ -70,10 +71,11 @@ static void paste_files_separate(FILE** files, char* delims, int del_cnt)
{
char *line, *next_line;
char delim;
- int del_idx = 0;
int i;
for (i = 0; files[i]; ++i) {
+ int del_idx = 0;
+
line = NULL;
while ((next_line = xmalloc_fgetline(files[i])) != NULL) {
if (line) {