1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Open the input file in main.cc, not in class Options.

This commit is contained in:
Bruno Haible
2003-01-21 12:00:44 +00:00
parent 0a3597e6c2
commit d3a9c2f7ad
5 changed files with 41 additions and 9 deletions

View File

@@ -21,6 +21,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include "options.h"
#include "input.h"
#include "search.h"
@@ -51,6 +52,15 @@ main (int argc, char *argv[])
/* Set the Options. Open the input file and assign stdin to it. */
option.parse_options (argc, argv);
/* Open the input file. */
if (option.get_input_file_name ())
if (!freopen (option.get_input_file_name (), "r", stdin))
{
fprintf (stderr, "Cannot open input file '%s'\n",
option.get_input_file_name ());
exit (1);
}
/* Initialize the keyword list. */
KeywordExt_Factory factory;
Input inputter (stdin, &factory);
@@ -82,7 +92,10 @@ main (int argc, char *argv[])
/* Check for write error on stdout. */
int status = 0;
if (fflush (stdout) || ferror (stdout))
status = 1;
{
fprintf (stderr, "error while writing output file\n");
status = 1;
}
/* Don't use exit() here, it skips the destructors. */
return status;