]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cppinit.c (cpp_read_main_file): Split out source-independent initialization to separa...
authorPer Bothner <pbothner@apple.com>
Sat, 9 Aug 2003 22:14:07 +0000 (22:14 +0000)
committerPer Bothner <bothner@gcc.gnu.org>
Sat, 9 Aug 2003 22:14:07 +0000 (15:14 -0700)
        * cppinit.c (cpp_read_main_file):  Split out source-independent
        initialization to separate function ...
        (cpp_post_options):  New function.
        * cppfiles.c (cpp_stack_file):  Rename public name to ...
        (_cpp_stack_file):  New internal function name.
        * cpplib.h:  Update accordingly.
        * cppinit.c:  (cpp_create_reader):  Initialize cpp_readers line here.
        (cpp_read_main_file):  Don't initialize line here.
        * c-opts.c (c_common_post_options):  Call cpp_post_options.
        (c_common_parse_file):  Call cpp_read_main_file, not cpp_stack_file.
        * fix-header.c (read_scan_file):  Call cpp_post_options.

From-SVN: r70279

gcc/ChangeLog
gcc/c-opts.c
gcc/cppfiles.c
gcc/cppinit.c
gcc/cpplib.h
gcc/fix-header.c

index 6ebb836b2fe0db923eb9b91f8152ddefad1a34c9..dda02bbb06bde7d43f3404228a6753772c966b96 100644 (file)
@@ -1,3 +1,17 @@
+2003-08-09  Per Bothner  <pbothner@apple.com>
+
+        * cppinit.c (cpp_read_main_file):  Split out source-independent
+        initialization to separate function ...
+        (cpp_post_options):  New function.
+        * cppfiles.c (cpp_stack_file):  Rename public name to ...
+        (_cpp_stack_file):  New internal function name.
+        * cpplib.h:  Update accordingly.
+        * cppinit.c:  (cpp_create_reader):  Initialize cpp_readers line here.
+        (cpp_read_main_file):  Don't initialize line here.
+        * c-opts.c (c_common_post_options):  Call cpp_post_options.
+        (c_common_parse_file):  Call cpp_read_main_file, not cpp_stack_file.
+        * fix-header.c (read_scan_file):  Call cpp_post_options.
+       
 2003-08-09  Per Bothner  <per@bothner.com>
 
        * c-decl.c (SCOPE_LIST_APPEND):  Remove bogus line continuation.
index e2a30430997eeb05b5eccdfb48ccfcf42ca8c2e6..462ca240b79ce4669bc7a9a0f09cb2b91b251200 100644 (file)
@@ -1126,6 +1126,7 @@ c_common_post_options (const char **pfilename)
     }
 
   cpp_get_callbacks (parse_in)->file_change = cb_file_change;
+  cpp_post_options (parse_in);
 
   /* NOTE: we use in_fname here, not the one supplied.  */
   *pfilename = cpp_read_main_file (parse_in, in_fnames[0]);
@@ -1196,7 +1197,7 @@ c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 
          /* Reset cpplib's macros and start a new file.  */
          cpp_undef_all (parse_in);
-         cpp_stack_file (parse_in, in_fnames[file_index]);
+         cpp_read_main_file (parse_in, in_fnames[file_index]);
        }
 
       finish_options(in_fnames[file_index]);
index 4c3608b127c764e9b1efc7bb2f20762cd5634fd0..22e95248cc28e2d9921b3c79e6b13d698a206dcd 100644 (file)
@@ -696,7 +696,7 @@ dir_name_of_file (_cpp_file *file)
 /* Push an input buffer with the contents of FNAME, the empty string
    for standard input.  Return true if a buffer was stacked.  */
 bool
-cpp_stack_file (cpp_reader *pfile, const char *fname)
+_cpp_stack_file (cpp_reader *pfile, const char *fname)
 {
   struct cpp_dir *dir = &pfile->no_search_path;
 
index 4ef7e24998cd308e68a1cde1e6f1fc0bf07e5924..07abea8642071a4aefb989f930b59d8949c11faa 100644 (file)
@@ -170,6 +170,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table)
   /* Initialize the line map.  Start at logical line 1, so we can use
      a line number of zero for special states.  */
   linemap_init (&pfile->line_maps);
+  pfile->line = 1;
 
   /* Initialize lexer state.  */
   pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
@@ -434,11 +435,9 @@ cpp_add_dependency_target (cpp_reader *pfile, const char *target, int quote)
 }
 
 /* This is called after options have been parsed, and partially
-   processed.  Setup for processing input from the file named FNAME,
-   or stdin if it is the empty string.  Return the original filename
-   on success (e.g. foo.i->foo.c), or NULL on failure.  */
-const char *
-cpp_read_main_file (cpp_reader *pfile, const char *fname)
+   processed. */
+void
+cpp_post_options (cpp_reader *pfile)
 {
   sanity_checks (pfile);
 
@@ -447,7 +446,14 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname)
   /* Mark named operators before handling command line macros.  */
   if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
     mark_named_operators (pfile);
+}
 
+/* Setup for processing input from the file named FNAME,
+   or stdin if it is the empty string.  Return the original filename
+   on success (e.g. foo.i->foo.c), or NULL on failure.  */
+const char *
+cpp_read_main_file (cpp_reader *pfile, const char *fname)
+{
   if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
     {
       if (!pfile->deps)
@@ -457,8 +463,7 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname)
       deps_add_default_target (pfile->deps, fname);
     }
 
-  pfile->line = 1;
-  if (!cpp_stack_file (pfile, fname))
+  if (! _cpp_stack_file (pfile, fname))
     return NULL;
 
   /* Set this here so the client can change the option if it wishes,
index 57fc0b1308678a43ddc83a334f141ac8eb82dcc7..b6f58a95cc66f957e0dad8d466eafe5f91b997ef 100644 (file)
@@ -533,13 +533,13 @@ extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
    too.  If there was an error opening the file, it returns NULL.  */
 extern const char *cpp_read_main_file (cpp_reader *, const char *);
 
-/* Stacks a new file.  It will return false if there was an error
-   opening the file.  */
-extern bool cpp_stack_file (cpp_reader *, const char *);
-
 /* Set up built-ins like __FILE__.  */
 extern void cpp_init_builtins (cpp_reader *, int);
 
+/* This is called after options have been parsed, and partially
+   processed. */
+extern void cpp_post_options (cpp_reader *);
+
 /* Set up translation to the target character set.  */
 extern void cpp_init_iconv (cpp_reader *);
 
index 0c55481b4efa51abd72fba11cc26fd2bc4837fc2..0f5f8c0d423b2844ef69712e2ef72013d30a2208 100644 (file)
@@ -602,6 +602,7 @@ read_scan_file (char *in_fname, int argc, char **argv)
   options = cpp_get_options (scan_in);
   options->inhibit_warnings = 1;
   options->inhibit_errors = 1;
+  cpp_post_options (scan_in);
 
   if (! cpp_read_main_file (scan_in, in_fname))
     exit (FATAL_EXIT_CODE);