diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2010-06-10 20:21:44 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2010-06-10 20:21:44 +0000 |
commit | c5e88b399c526dbb7ab2bc6b4fdbc0e8100fa3d9 (patch) | |
tree | cf86a2e45130a51690d5994f074ff828e9d308ed /gcc/gensupport.c | |
parent | d2a3ce4e3374de54b231d98bd78613c8dc18d9a4 (diff) | |
download | gcc-c5e88b399c526dbb7ab2bc6b4fdbc0e8100fa3d9.zip gcc-c5e88b399c526dbb7ab2bc6b4fdbc0e8100fa3d9.tar.gz gcc-c5e88b399c526dbb7ab2bc6b4fdbc0e8100fa3d9.tar.bz2 |
read-md.h (read_md_file): Declare.
gcc/
* read-md.h (read_md_file): Declare.
(read_char, unread_char): New functions.
(fatal_with_file_and_line, fatal_expected_char, read_skip_spaces)
(read_quoted_string, read_string): Remove FILE * argument.
* read-md.c (read_md_file): New variable.
(read_md_filename, read_md_lineno): Update comments and remove
unnecessary initialization.
(fatal_with_file_and_line, fatal_expected_char, read_skip_spaces)
(read_escape, read_quoted_string, read_braced_string, read_string):
Remove FILE * argument. Update calls accordingly, using read_char
and unread_char instead of getc and ungetc.
* rtl.h (read_rtx): Remove FILE * argument.
* read-rtl.c (iterator_group): Remove FILE * argument from
"find_builtin".
(iterator_traverse_data): Remove "infile" field.
(find_mode, find_code, apply_mode_maps, apply_iterator_to_rtx)
(add_mapping, read_name, read_constants, read_conditions)
(validate_const_int, find_iterator, read_mapping, check_code_iterator)
(read_rtx, read_rtx_1, read_rtx_variadic): Remove FILE * argument.
Remove file arguments from all calls, using read_char and unread_char
instead of getc and ungetc.
* gensupport.c (process_include): Preserve read_md_file around
the include. Set read_md_file to the handle of the included file.
Update call to read_rtx.
(init_md_reader_args_cb): Set read_md_file to the handle of the file
and remove local FILE *. Update calls to read_rtx.
From-SVN: r160572
Diffstat (limited to 'gcc/gensupport.c')
-rw-r--r-- | gcc/gensupport.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 0905ca7..061376f 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -194,7 +194,7 @@ process_include (rtx desc, int lineno) const char *old_filename; int old_lineno; char *pathname; - FILE *input_file; + FILE *input_file, *old_file; /* If specified file name is absolute, skip the include stack. */ if (! IS_ABSOLUTE_PATH (filename)) @@ -231,8 +231,10 @@ process_include (rtx desc, int lineno) /* Save old cursor; setup new for the new file. Note that "lineno" the argument to this function is the beginning of the include statement, while read_md_lineno has already been advanced. */ + old_file = read_md_file; old_filename = read_md_filename; old_lineno = read_md_lineno; + read_md_file = input_file; read_md_filename = pathname; read_md_lineno = 1; @@ -240,12 +242,13 @@ process_include (rtx desc, int lineno) include_callback (pathname); /* Read the entire file. */ - while (read_rtx (input_file, &desc, &lineno)) + while (read_rtx (&desc, &lineno)) process_rtx (desc, lineno); /* Do not free pathname. It is attached to the various rtx queue elements. */ + read_md_file = old_file; read_md_filename = old_filename; read_md_lineno = old_lineno; @@ -902,7 +905,6 @@ save_string (const char *s, int len) int init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *)) { - FILE *input_file; int c, i, lineno; char *lastsl; rtx desc; @@ -988,14 +990,14 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *)) fatal ("cannot read standard input twice"); base_dir = NULL; + read_md_file = stdin; read_md_filename = in_fname = "<stdin>"; read_md_lineno = 1; - input_file = stdin; already_read_stdin = true; - while (read_rtx (input_file, &desc, &lineno)) + while (read_rtx (&desc, &lineno)) process_rtx (desc, lineno); - fclose (input_file); + fclose (read_md_file); continue; } else if (argv[i][1] == '-' && argv[i][2] == '\0') @@ -1018,18 +1020,18 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *)) else base_dir = NULL; - read_md_filename = in_fname; - read_md_lineno = 1; - input_file = fopen (in_fname, "r"); - if (input_file == 0) + read_md_file = fopen (in_fname, "r"); + if (read_md_file == 0) { perror (in_fname); return FATAL_EXIT_CODE; } + read_md_filename = in_fname; + read_md_lineno = 1; - while (read_rtx (input_file, &desc, &lineno)) + while (read_rtx (&desc, &lineno)) process_rtx (desc, lineno); - fclose (input_file); + fclose (read_md_file); } /* If we get to this point without having seen any files to process, @@ -1037,13 +1039,13 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *)) if (!in_fname) { base_dir = NULL; + read_md_file = stdin; read_md_filename = in_fname = "<stdin>"; read_md_lineno = 1; - input_file = stdin; - while (read_rtx (input_file, &desc, &lineno)) + while (read_rtx (&desc, &lineno)) process_rtx (desc, lineno); - fclose (input_file); + fclose (read_md_file); } /* Process define_cond_exec patterns. */ |