| 19 | #endif |
| 20 | |
| 21 | int main(int argc UNUSED, char *argv[] UNUSED) |
| 22 | { |
| 23 | int stop = 0, trouble = 0; |
| 24 | char buf[2]; |
| 25 | char *cp = &buf[0], *prev = &buf[1]; |
| 26 | |
| 27 | *prev = 0; |
| 28 | while (!stop) { |
| 29 | if ((fread(buf, 1, 1, stdin)) > 0) { |
| 30 | if (*cp == 8) { |
| 31 | *prev = 0; |
| 32 | } else { |
| 33 | if (*prev) |
| 34 | fputc(*prev, stdout); |
| 35 | *prev = *cp; |
| 36 | } |
| 37 | } else { |
| 38 | if (errno != EOF) |
| 39 | trouble = 1; |
| 40 | if (*prev) |
| 41 | fputc(*prev, stdout); |
| 42 | stop = 1; |
| 43 | } |
| 44 | } |
| 45 | fflush(stdout); |
| 46 | fclose(stdout); |
| 47 | return trouble ? EXIT_FAILURE : EXIT_SUCCESS; |
| 48 | } |