Skip to content

Commit

Permalink
Added option to have combinator read the first file from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
singe committed Jul 21, 2020
1 parent f2a86c7 commit c209cf1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/combinator.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main (int argc, char *argv[])
{
if (argc != 3)
{
fprintf (stderr, "usage: %s file1 file2\n", argv[0]);
fprintf (stderr, "usage: %s file1 file2\nfile1 can be \"-\" for stdin.", argv[0]);

return (-1);
}
Expand All @@ -104,15 +104,22 @@ int main (int argc, char *argv[])
FILE *fd1;
FILE *fd2;

if ((fd1 = fopen (argv[1], "rb")) == NULL)
if (!strcmp (argv[1], "-"))
{
fprintf (stderr, "%s: %s\n", argv[1], strerror (errno));
fd1 = stdin;
}
else
{
if ((fd1 = fopen (argv[1], "rb")) == NULL)
{
fprintf (stderr, "%s: %s\n", argv[1], strerror (errno));

free (buf_in1);
free (buf_in2);
free (buf_out);
free (buf_in1);
free (buf_in2);
free (buf_out);

return (-1);
return (-1);
}
}

if ((fd2 = fopen (argv[2], "rb")) == NULL)
Expand Down

0 comments on commit c209cf1

Please sign in to comment.