From de5137a9b6b41a40f3a04577402fbeaa59e84a6f Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 7 Apr 2016 07:20:11 -0400 Subject: [PATCH 30/91] FIXME: more read_char/unread_char into rtx_reader --- gcc/read-md.c | 35 +++++++++++++++++++++++++++++++++++ gcc/read-md.h | 26 +++++--------------------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/gcc/read-md.c b/gcc/read-md.c index 3ea1849..5262cad 100644 --- a/gcc/read-md.c +++ b/gcc/read-md.c @@ -428,6 +428,41 @@ rtx_reader::make_location (file_location caret, file_location start, return combined_loc; } +/* FIXME. */ + +int +rtx_reader::read_char (void) +{ + int ch; + + ch = getc (read_md_file); + if (ch == '\n') + { + read_md_lineno++; + read_md_colno = 0; + } + else + read_md_colno++; + + update_location (true); + + return ch; +} + +/* FIXME. */ + +void +rtx_reader::unread_char (int ch) +{ + /* FIXME: what about colno when unreading a '\n'? */ + if (ch == '\n') + read_md_lineno--; + else + read_md_colno--; + update_location (false); + ungetc (ch, read_md_file); +} + /* Read an rtx code name into NAME. It is terminated by any of the punctuation chars of rtx printed syntax. */ diff --git a/gcc/read-md.h b/gcc/read-md.h index 026719f..46bfda1 100644 --- a/gcc/read-md.h +++ b/gcc/read-md.h @@ -103,6 +103,9 @@ class rtx_reader make_location (file_location caret, file_location start, file_location finish) const; + int read_char (void); + void unread_char (int ch); + private: void handle_file (); void handle_toplevel_file (); @@ -138,20 +141,7 @@ extern void (*include_callback) (const char *); static inline int read_char (void) { - int ch; - - ch = getc (read_md_file); - if (ch == '\n') - { - read_md_lineno++; - read_md_colno = 0; - } - else - read_md_colno++; - - rtx_reader_ptr->update_location (true); - - return ch; + return rtx_reader_ptr->read_char (); } /* Put back CH, which was the last character read from the MD file. */ @@ -159,13 +149,7 @@ read_char (void) static inline void unread_char (int ch) { - /* FIXME: what about colno when unreading a '\n'? */ - if (ch == '\n') - read_md_lineno--; - else - read_md_colno--; - rtx_reader_ptr->update_location (false); - ungetc (ch, read_md_file); + rtx_reader_ptr->unread_char (ch); } extern hashval_t leading_string_hash (const void *); -- 1.8.5.3