1 /* CPP main program, using CPP Library.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Written by Per Bothner, 1994-95.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding! */
28 #endif /* not EMACS */
30 extern char *getenv ();
37 /* More 'friendly' abort that prints the line and file.
38 config.h can #define abort fancy_abort if you like that sort of thing. */
43 fatal ("Internal gcc abort.");
54 int argi
= 1; /* Next argument to handle. */
55 struct cpp_options
*opts
= &options
;
57 p
= argv
[0] + strlen (argv
[0]);
58 while (p
!= argv
[0] && p
[-1] != '/') --p
;
61 init_parse_file (&parse_in
);
64 init_parse_options (opts
);
66 argi
+= cpp_handle_options (&parse_in
, argc
- argi
, argv
+ argi
);
68 fatal ("Invalid option `%s'", argv
[argi
]);
69 parse_in
.show_column
= 1;
71 i
= push_parse_file (&parse_in
, opts
->in_fname
);
72 if (i
!= SUCCESS_EXIT_CODE
)
75 /* Now that we know the input file is valid, open the output. */
77 if (!opts
->out_fname
|| !strcmp (opts
->out_fname
, ""))
78 opts
->out_fname
= "stdout";
79 else if (! freopen (opts
->out_fname
, "w", stdout
))
80 cpp_pfatal_with_name (&parse_in
, opts
->out_fname
);
85 if (! opts
->no_output
)
87 fwrite (parse_in
.token_buffer
, 1, CPP_WRITTEN (&parse_in
), stdout
);
89 parse_in
.limit
= parse_in
.token_buffer
;
90 kind
= cpp_get_token (&parse_in
);
95 cpp_finish (&parse_in
);
98 exit (FATAL_EXIT_CODE
);
99 exit (SUCCESS_EXIT_CODE
);