aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorDave Brolley <brolley@cygnus.com>1998-04-08 23:29:09 +0000
committerJeff Law <law@gcc.gnu.org>1998-04-08 17:29:09 -0600
commite56e519de8211b657741d6e7bd5fae0db71405c9 (patch)
tree095aa1b478270aae0c9b79838f76864799d3f0a3 /gcc/c-lex.c
parent62db76ee5fc19a98d765c1954387373e3d4fee04 (diff)
downloadgcc-e56e519de8211b657741d6e7bd5fae0db71405c9.zip
gcc-e56e519de8211b657741d6e7bd5fae0db71405c9.tar.gz
gcc-e56e519de8211b657741d6e7bd5fae0db71405c9.tar.bz2
c-lex.c (finput): New global.
* c-lex.c (finput): New global. (init_parse): Always included. Handle !USE_CPPLIB using code originally in compile_file. (finish_parse): Update for CPPLIB. * toplev.c (init_parse, finish_parse): Declare. (finput): Delete variable. Now in front-ends. (compile_file): Remove code which is now handled by init_parse which is unconditionally called. Similarly for finish_parse. From-SVN: r19063
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 8e9e10c..3a2eb0a 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -47,6 +47,9 @@ Boston, MA 02111-1307, USA. */
cpp_reader parse_in;
cpp_options parse_options;
static enum cpp_token cpp_token;
+#else
+/* Stream for reading from the input file. */
+FILE *finput;
#endif
/* The elements of `ridpointers' are identifier nodes
@@ -182,12 +185,30 @@ remember_protocol_qualifiers ()
wordlist[i].name = "oneway";
}
-#if USE_CPPLIB
void
init_parse (filename)
char *filename;
{
+#if !USE_CPPLIB
+ /* Open input file. */
+ if (filename == 0 || !strcmp (filename, "-"))
+ {
+ finput = stdin;
+ filename = "stdin";
+ }
+ else
+ finput = fopen (filename, "r");
+ if (finput == 0)
+ pfatal_with_name (filename);
+
+#ifdef IO_BUFFER_SIZE
+ setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
+#endif
+#endif /* !USE_CPPLIB */
+
init_lex ();
+
+#if USE_CPPLIB
yy_cur = "\n";
yy_lim = yy_cur+1;
@@ -198,14 +219,18 @@ init_parse (filename)
parse_in.show_column = 1;
if (! cpp_start_read (&parse_in, filename))
abort ();
+#endif
}
void
finish_parse ()
{
+#if USE_CPPLIB
cpp_finish (&parse_in);
-}
+#else
+ fclose (finput);
#endif
+}
void
init_lex ()