Use stdin by default as before

This commit is contained in:
Loic Le Loarer 2015-07-16 01:15:08 +02:00
parent 972d061e90
commit 1c89a2f8ff

View File

@ -122,11 +122,16 @@ int main(int argc, char ** argv)
} }
} }
FILE * f = NULL; FILE * f = stdin;
int error_seen = 0; int error_seen = 0;
if (argc < 2)
{
// No file arg, use stdin by default
detect(f);
}
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
char *filename = argv[i]; const char *filename = argv[i];
f = fopen(filename, "r"); f = fopen(filename, "r");
if (f == NULL) if (f == NULL)
{ {
@ -134,11 +139,11 @@ int main(int argc, char ** argv)
error_seen = 1; error_seen = 1;
continue; continue;
} }
if (argc > 2) { if (argc > 2)
{
printf("%s: ", filename); printf("%s: ", filename);
} }
detect(f); detect(f);
fclose(f);
} }
return error_seen; return error_seen;