MCPcopy Create free account
hub / github.com/NetHack/NetHack / main

Function main

util/stripbs.c:21–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#endif
20
21int 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}

Callers

nothing calls this directly

Calls 3

freadFunction · 0.85
fflushFunction · 0.85
fcloseFunction · 0.85

Tested by

no test coverage detected