diff toys/other/tac.c @ 758:54d248b907ed

Fix tac to handle the "abc\ndef" case properly
author Elie De Brauwer <eliedebrauwer@gmail.com>
date Sat, 22 Dec 2012 11:50:11 +0100
parents f7eaff0c8d0c
children
line wrap: on
line diff
--- a/toys/other/tac.c	Sun Dec 23 00:37:42 2012 -0600
+++ b/toys/other/tac.c	Sat Dec 22 11:50:11 2012 +0100
@@ -23,8 +23,9 @@
   // 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 @@
   // 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;