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/read-md.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/read-md.c')
-rw-r--r-- | gcc/read-md.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c index 105b3bc..a8c0d5c 100644 --- a/gcc/read-md.c +++ b/gcc/read-md.c @@ -52,11 +52,14 @@ static htab_t joined_conditions; /* An obstack for allocating joined_conditions entries. */ static struct obstack joined_conditions_obstack; -/* The current line number for the file. */ -int read_md_lineno = 1; +/* The file we are reading. */ +FILE *read_md_file; -/* The filename for error reporting. */ -const char *read_md_filename = "<unknown>"; +/* The filename of READ_MD_FILE. */ +const char *read_md_filename; + +/* The current line number in READ_MD_FILE. */ +int read_md_lineno; /* Return a hash value for the pointer pointed to by DEF. */ @@ -189,10 +192,10 @@ message_with_line (int lineno, const char *msg, ...) } /* A printf-like function for reporting an error against the current - position in the MD file, which is associated with INFILE. */ + position in the MD file. */ void -fatal_with_file_and_line (FILE *infile, const char *msg, ...) +fatal_with_file_and_line (const char *msg, ...) { char context[64]; size_t i; @@ -208,7 +211,7 @@ fatal_with_file_and_line (FILE *infile, const char *msg, ...) /* Gather some following context. */ for (i = 0; i < sizeof (context)-1; ++i) { - c = getc (infile); + c = read_char (); if (c == EOF) break; if (c == '\r' || c == '\n') @@ -225,31 +228,30 @@ fatal_with_file_and_line (FILE *infile, const char *msg, ...) } /* Report that we found character ACTUAL when we expected to find - character EXPECTED. INFILE is the file handle associated - with the current file. */ + character EXPECTED. */ void -fatal_expected_char (FILE *infile, int expected, int actual) +fatal_expected_char (int expected, int actual) { if (actual == EOF) - fatal_with_file_and_line (infile, "expected character `%c', found EOF", + fatal_with_file_and_line ("expected character `%c', found EOF", expected); else - fatal_with_file_and_line (infile, "expected character `%c', found `%c'", + fatal_with_file_and_line ("expected character `%c', found `%c'", expected, actual); } -/* Read chars from INFILE until a non-whitespace char and return that. +/* Read chars from the MD file until a non-whitespace char and return that. Comments, both Lisp style and C style, are treated as whitespace. */ int -read_skip_spaces (FILE *infile) +read_skip_spaces (void) { int c; while (1) { - c = getc (infile); + c = read_char (); switch (c) { case '\n': @@ -261,7 +263,7 @@ read_skip_spaces (FILE *infile) case ';': do - c = getc (infile); + c = read_char (); while (c != '\n' && c != EOF); read_md_lineno++; break; @@ -269,12 +271,12 @@ read_skip_spaces (FILE *infile) case '/': { int prevc; - c = getc (infile); + c = read_char (); if (c != '*') - fatal_expected_char (infile, '*', c); + fatal_expected_char ('*', c); prevc = 0; - while ((c = getc (infile)) && c != EOF) + while ((c = read_char ()) && c != EOF) { if (c == '\n') read_md_lineno++; @@ -295,9 +297,9 @@ read_skip_spaces (FILE *infile) Caller has read the backslash, but not placed it into the obstack. */ static void -read_escape (FILE *infile) +read_escape (void) { - int c = getc (infile); + int c = read_char (); switch (c) { @@ -348,18 +350,18 @@ read_escape (FILE *infile) the leading quote. */ char * -read_quoted_string (FILE *infile) +read_quoted_string (void) { int c; while (1) { - c = getc (infile); /* Read the string */ + c = read_char (); /* Read the string */ if (c == '\n') read_md_lineno++; else if (c == '\\') { - read_escape (infile); + read_escape (); continue; } else if (c == '"' || c == EOF) @@ -377,7 +379,7 @@ read_quoted_string (FILE *infile) the outermost braces _are_ included in the string constant. */ static char * -read_braced_string (FILE *infile) +read_braced_string (void) { int c; int brace_depth = 1; /* caller-processed */ @@ -386,7 +388,7 @@ read_braced_string (FILE *infile) obstack_1grow (&string_obstack, '{'); while (brace_depth) { - c = getc (infile); /* Read the string */ + c = read_char (); /* Read the string */ if (c == '\n') read_md_lineno++; @@ -396,12 +398,12 @@ read_braced_string (FILE *infile) brace_depth--; else if (c == '\\') { - read_escape (infile); + read_escape (); continue; } else if (c == EOF) fatal_with_file_and_line - (infile, "missing closing } for opening brace on line %lu", + ("missing closing } for opening brace on line %lu", starting_read_md_lineno); obstack_1grow (&string_obstack, c); @@ -416,36 +418,36 @@ read_braced_string (FILE *infile) and dispatch to the appropriate string constant reader. */ char * -read_string (FILE *infile, int star_if_braced) +read_string (int star_if_braced) { char *stringbuf; int saw_paren = 0; int c, old_lineno; - c = read_skip_spaces (infile); + c = read_skip_spaces (); if (c == '(') { saw_paren = 1; - c = read_skip_spaces (infile); + c = read_skip_spaces (); } old_lineno = read_md_lineno; if (c == '"') - stringbuf = read_quoted_string (infile); + stringbuf = read_quoted_string (); else if (c == '{') { if (star_if_braced) obstack_1grow (&string_obstack, '*'); - stringbuf = read_braced_string (infile); + stringbuf = read_braced_string (); } else - fatal_with_file_and_line (infile, "expected `\"' or `{', found `%c'", c); + fatal_with_file_and_line ("expected `\"' or `{', found `%c'", c); if (saw_paren) { - c = read_skip_spaces (infile); + c = read_skip_spaces (); if (c != ')') - fatal_expected_char (infile, ')', c); + fatal_expected_char (')', c); } set_md_ptr_loc (stringbuf, read_md_filename, old_lineno); |