aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/test/tac.test3
-rw-r--r--toys/other/tac.c5
2 files changed, 4 insertions, 4 deletions
diff --git a/scripts/test/tac.test b/scripts/test/tac.test
index a70c3c1e..96f25310 100644
--- a/scripts/test/tac.test
+++ b/scripts/test/tac.test
@@ -17,8 +17,7 @@ testing "tac file1 notfound file2" \
"tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \
"one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" ""
-# echo -ne "abc\ndef" | tac actually gives "defabc\n"
-testing "tac no trailing newline" "tac -" "def\nabc\n" "" "abc\ndef"
+testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef"
# xputs used by tac does not propagate this error condition properly.
#testing "tac > /dev/full" \
diff --git a/toys/other/tac.c b/toys/other/tac.c
index 9ebc7f69..538d1b0b 100644
--- a/toys/other/tac.c
+++ b/toys/other/tac.c
@@ -23,8 +23,9 @@ void do_tac(int fd, char *name)
// Read in lines
for (;;) {
struct arg_list *temp;
+ long len;
- if (!(c = get_line(fd))) break;
+ if (!(c = get_rawline(fd, &len, '\n'))) break;
temp = xmalloc(sizeof(struct arg_list));
temp->next = list;
@@ -35,7 +36,7 @@ void do_tac(int fd, char *name)
// Play them back.
while (list) {
struct arg_list *temp = list->next;
- xputs(list->arg);
+ xprintf("%s", list->arg);
free(list->arg);
free(list);
list = temp;