Mercurial > hg > toybox
comparison 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 |
comparison
equal
deleted
inserted
replaced
757:4094f14c47a2 | 758:54d248b907ed |
---|---|
21 char *c; | 21 char *c; |
22 | 22 |
23 // Read in lines | 23 // Read in lines |
24 for (;;) { | 24 for (;;) { |
25 struct arg_list *temp; | 25 struct arg_list *temp; |
26 long len; | |
26 | 27 |
27 if (!(c = get_line(fd))) break; | 28 if (!(c = get_rawline(fd, &len, '\n'))) break; |
28 | 29 |
29 temp = xmalloc(sizeof(struct arg_list)); | 30 temp = xmalloc(sizeof(struct arg_list)); |
30 temp->next = list; | 31 temp->next = list; |
31 temp->arg = c; | 32 temp->arg = c; |
32 list = temp; | 33 list = temp; |
33 } | 34 } |
34 | 35 |
35 // Play them back. | 36 // Play them back. |
36 while (list) { | 37 while (list) { |
37 struct arg_list *temp = list->next; | 38 struct arg_list *temp = list->next; |
38 xputs(list->arg); | 39 xprintf("%s", list->arg); |
39 free(list->arg); | 40 free(list->arg); |
40 free(list); | 41 free(list); |
41 list = temp; | 42 list = temp; |
42 } | 43 } |
43 } | 44 } |