summaryrefslogtreecommitdiff
path: root/gcc/read-md.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-10 18:28:10 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-10 18:28:10 +0000
commit3604118da2f0e62a75ebd6d206a8cd3ef2573b01 (patch)
tree4536dc681253ddda5e2965d30e5b73bfb1e4008a /gcc/read-md.c
parentffea1e28b0b44cf71c5cd4bfd157dae2179bd823 (diff)
downloadgcc-3604118da2f0e62a75ebd6d206a8cd3ef2573b01.tar.gz
Simplify read-md.c and read-rtl.c using require_char_ws
read-md.c and read-rtl.c repeatedly use this pattern: c = read_skip_spaces (); if (c != ')') fatal_expected_char (')', c); Simplify them by introduce a helper function to do this. gcc/ChangeLog: * read-md.c (require_char_ws): New function. (read_string): Simplify using require_char_ws. (handle_constants): Likewise. (handle_enum): Likewise. (handle_file): Likewise. * read-md.h (require_char_ws): New declaration. * read-rtl.c (read_conditions): Simplify using require_char_ws. (read_mapping): Likewise. (read_rtx_code): Likewise. (read_nested_rtx): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236101 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/read-md.c')
-rw-r--r--gcc/read-md.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c
index 6c588781978..b422d8dc75c 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -391,6 +391,17 @@ read_skip_spaces (void)
}
}
+/* Consume any whitespace, then consume the next non-whitespace
+ character, issuing a fatal error if it is not EXPECTED. */
+
+void
+require_char_ws (char expected)
+{
+ int ch = read_skip_spaces ();
+ if (ch != expected)
+ fatal_expected_char (expected, ch);
+}
+
/* Read an rtx code name into NAME. It is terminated by any of the
punctuation chars of rtx printed syntax. */
@@ -603,11 +614,7 @@ read_string (int star_if_braced)
fatal_with_file_and_line ("expected `\"' or `{', found `%c'", c);
if (saw_paren)
- {
- c = read_skip_spaces ();
- if (c != ')')
- fatal_expected_char (')', c);
- }
+ require_char_ws (')');
set_md_ptr_loc (stringbuf, read_md_filename, old_lineno);
return stringbuf;
@@ -764,9 +771,7 @@ handle_constants (void)
int c;
htab_t defs;
- c = read_skip_spaces ();
- if (c != '[')
- fatal_expected_char ('[', c);
+ require_char_ws ('[');
/* Disable constant expansion during definition processing. */
defs = md_constants;
@@ -782,9 +787,7 @@ handle_constants (void)
read_name (&value);
add_constant (defs, xstrdup (name.string), xstrdup (value.string), 0);
- c = read_skip_spaces ();
- if (c != ')')
- fatal_expected_char (')', c);
+ require_char_ws (')');
}
md_constants = defs;
}
@@ -846,9 +849,7 @@ handle_enum (file_location loc, bool md_p)
*slot = def;
}
- c = read_skip_spaces ();
- if (c != '[')
- fatal_expected_char ('[', c);
+ require_char_ws ('[');
while ((c = read_skip_spaces ()) != ']')
{
@@ -1007,9 +1008,7 @@ handle_file (directive_handler_t handle_directive)
else
read_skip_construct (1, loc);
- c = read_skip_spaces ();
- if (c != ')')
- fatal_expected_char (')', c);
+ require_char_ws (')');
}
fclose (read_md_file);
}