1 e46639b3 2024-02-20 benni #include <string.h>
2 e46639b3 2024-02-20 benni #include <stdio.h>
3 e46639b3 2024-02-20 benni #include <err.h>
5 e46639b3 2024-02-20 benni static void cat (FILE* file) {
7 e46639b3 2024-02-20 benni while ((ch = fgetc(file)) != EOF)
8 e46639b3 2024-02-20 benni putchar(ch);
11 e46639b3 2024-02-20 benni int main (int argc, char* argv[]) {
12 e46639b3 2024-02-20 benni FILE *file;
13 e46639b3 2024-02-20 benni int ec = 0;
16 e46639b3 2024-02-20 benni if (argc == 1) {
17 e46639b3 2024-02-20 benni cat (stdin);
21 e46639b3 2024-02-20 benni for (int i = 1; i < argc; ++i) {
22 e46639b3 2024-02-20 benni if (strcmp (argv[i], "-") == 0) {
23 e46639b3 2024-02-20 benni file = stdin;
25 e46639b3 2024-02-20 benni file = fopen (argv[i], "r");
28 e46639b3 2024-02-20 benni if (file == NULL) {
29 e46639b3 2024-02-20 benni warn ("%s", argv[i]);
34 e46639b3 2024-02-20 benni cat (file);
36 cc17802d 2024-06-10 benni if (file != stdin)
37 cc17802d 2024-06-10 benni fclose (file);