FreeBSD Bugzilla – Attachment 190812 Details for
Bug 222671
tail(1): tail -r fails on certain piped input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix "tail -r" for pipes that begin with a newline
pr222671.diff (text/plain), 2.12 KB, created by
Alan Somers
on 2018-02-19 17:43:01 UTC
(
hide
)
Description:
Fix "tail -r" for pipes that begin with a newline
Filename:
MIME Type:
Creator:
Alan Somers
Created:
2018-02-19 17:43:01 UTC
Size:
2.12 KB
patch
obsolete
>Index: usr.bin/tail/reverse.c >=================================================================== >--- usr.bin/tail/reverse.c (revision 329580) >+++ usr.bin/tail/reverse.c (working copy) >@@ -257,10 +257,13 @@ > if ((*p == '\n') || start) { > struct bfelem *tr; > >- if (start && llen) >+ if (llen && start && *p != '\n') > WR(p, llen + 1); >- else if (llen) >+ else if (llen) { > WR(p + 1, llen); >+ if (start && *p == '\n') >+ WR(p, 1); >+ } > tr = TAILQ_NEXT(tl, entries); > llen = 0; > if (tr != NULL) { >Index: usr.bin/tail/tests/tail_test.sh >=================================================================== >--- usr.bin/tail/tests/tail_test.sh (revision 329580) >+++ usr.bin/tail/tests/tail_test.sh (working copy) >@@ -83,6 +83,27 @@ > atf_check cmp expectfile outpipe > } > >+# Regression test for PR 222671 >+# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222671 >+atf_test_case pipe_leading_newline_r >+pipe_leading_newline_r_head() >+{ >+ atf_set "descr" "Reverse a pipe whose first character is a newline" >+} >+pipe_leading_newline_r_body() >+{ >+ cat > expectfile << HERE >+3 >+2 >+1 >+ >+HERE >+ printf '\n1\n2\n3\n' | tail -r > outfile >+ printf '\n1\n2\n3\n' | tail -r > outpipe >+ atf_check cmp expectfile outfile >+ atf_check cmp expectfile outpipe >+} >+ > atf_test_case file_rc28 > file_rc28_head() > { >@@ -105,6 +126,28 @@ > atf_check cmp expectfile outpipe > } > >+atf_test_case file_rc28 >+file_rc28_head() >+{ >+ atf_set "descr" "Reverse a file and display the last 28 characters" >+} >+file_rc28_body() >+{ >+ cat > infile <<HERE >+This is the first line >+This is the second line >+This is the third line >+HERE >+ cat > expectfile << HERE >+This is the third line >+line >+HERE >+ tail -rc28 infile > outfile >+ tail -rc28 < infile > outpipe >+ atf_check cmp expectfile outfile >+ atf_check cmp expectfile outpipe >+} >+ > atf_test_case longfile_r > longfile_r_head() > { >@@ -235,6 +278,7 @@ > atf_add_test_case file_r > atf_add_test_case file_rc28 > atf_add_test_case file_rn2 >+ atf_add_test_case pipe_leading_newline_r > # The longfile tests are designed to exercise behavior in r_buf(), > # which operates on 128KB blocks > atf_add_test_case longfile_r
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222671
: 190812