#ifndef EMACS
#include "config.h"
#include "system.h"
#else
#include <stdio.h>
extern char *getenv ();
#endif
#include "cpplib.h"
#include "intl.h"
char *progname;
cpp_reader parse_in;
cpp_options options;
int
main (argc, argv)
int argc;
char **argv;
{
char *p;
int argi = 1;
struct cpp_options *opts = &options;
enum cpp_token kind;
p = argv[0] + strlen (argv[0]);
while (p != argv[0] && p[-1] != '/') --p;
progname = p;
#ifdef HAVE_LC_MESSAGES
setlocale (LC_MESSAGES, "");
#endif
(void) bindtextdomain (PACKAGE, localedir);
(void) textdomain (PACKAGE);
cpp_reader_init (&parse_in);
parse_in.opts = opts;
cpp_options_init (opts);
argi += cpp_handle_options (&parse_in, argc - argi , argv + argi);
if (argi < argc && ! CPP_FATAL_ERRORS (&parse_in))
cpp_fatal (&parse_in, "Invalid option `%s'", argv[argi]);
if (CPP_FATAL_ERRORS (&parse_in))
exit (FATAL_EXIT_CODE);
parse_in.show_column = 1;
if (! cpp_start_read (&parse_in, opts->in_fname))
exit (FATAL_EXIT_CODE);
if (!opts->out_fname || !strcmp (opts->out_fname, ""))
opts->out_fname = "stdout";
else if (! freopen (opts->out_fname, "w", stdout))
cpp_pfatal_with_name (&parse_in, opts->out_fname);
do
{
kind = cpp_get_token (&parse_in);
if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF)
{
if (! opts->no_output)
{
size_t rem, count = CPP_WRITTEN (&parse_in);
rem = fwrite (parse_in.token_buffer, 1, count, stdout);
if (rem < count)
cpp_pfatal_with_name (&parse_in, opts->out_fname);
}
CPP_SET_WRITTEN (&parse_in, 0);
}
}
while (kind != CPP_EOF);
cpp_finish (&parse_in);
if (fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout)
< CPP_WRITTEN (&parse_in))
cpp_pfatal_with_name (&parse_in, opts->out_fname);
if (parse_in.errors)
exit (FATAL_EXIT_CODE);
exit (SUCCESS_EXIT_CODE);
}