From f1735a53a63040cc4b4a735bf18a3f20d308e519 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 10 Sep 2017 14:19:19 -0600 Subject: Rename _const functions to use overloading instead This renames a few functions -- skip_spaces_const, skip_to_space_const, get_number_const, extract_arg_const -- to drop the "_const" suffix and instead rely on overloading. This makes future const fixes simpler by reducing the number of lines that must be changed. I think it is also not any less clear, as all these functions have the same interface as their non-const versions by design. Furthermore there's an example of using an overload in-tree already, namely check_for_argument. This patch was largely created using some perl one-liners; then a few fixes were applied by hand. ChangeLog 2017-09-11 Tom Tromey * common/common-utils.h (skip_to_space): Remove macro, redeclare as function. (skip_to_space): Rename from skip_to_space_const. * common/common-utils.c (skip_to_space): New function. (skip_to_space): Rename from skip_to_space_const. * cli/cli-utils.h (get_number): Rename from get_number_const. (extract_arg): Rename from extract_arg_const. * cli/cli-utils.c (get_number): Rename from get_number_const. (extract_arg): Rename from extract_arg_const. (number_or_range_parser::get_number): Use ::get_number. * aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c, break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c, cli/cli-script.c, cli/cli-setshow.c, compile/compile.c, completer.c, demangle.c, disasm.c, findcmd.c, linespec.c, linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c, minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c, python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c, stap-probe.c, tid-parse.c, tracepoint.c: Update all callers. --- gdb/linespec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gdb/linespec.c') diff --git a/gdb/linespec.c b/gdb/linespec.c index abe6615..b69ab62 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -474,7 +474,7 @@ linespec_lexer_lex_keyword (const char *p) if (i != IF_KEYWORD_INDEX) { p += len; - p = skip_spaces_const (p); + p = skip_spaces (p); for (j = 0; linespec_keywords[j] != NULL; ++j) { int nextlen = strlen (linespec_keywords[j]); @@ -709,7 +709,7 @@ linespec_lexer_lex_string (linespec_parser *parser) { if (isspace (*PARSER_STREAM (parser))) { - p = skip_spaces_const (PARSER_STREAM (parser)); + p = skip_spaces (PARSER_STREAM (parser)); /* When we get here we know we've found something followed by a space (we skip over parens and templates below). So if we find a keyword now, we know it is a keyword and not, @@ -856,7 +856,7 @@ linespec_lexer_lex_one (linespec_parser *parser) if (parser->lexer.current.type == LSTOKEN_CONSUMED) { /* Skip any whitespace. */ - PARSER_STREAM (parser) = skip_spaces_const (PARSER_STREAM (parser)); + PARSER_STREAM (parser) = skip_spaces (PARSER_STREAM (parser)); /* Check for a keyword, they end the linespec. */ keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser)); @@ -1770,7 +1770,7 @@ set_completion_after_number (linespec_parser *parser, { if (*PARSER_STREAM (parser) == ' ') { - parser->completion_word = skip_spaces_const (PARSER_STREAM (parser) + 1); + parser->completion_word = skip_spaces (PARSER_STREAM (parser) + 1); parser->complete_what = next; } else @@ -2000,7 +2000,7 @@ linespec_parse_basic (linespec_parser *parser) if (ptr[i] == ' ') { LS_TOKEN_STOKEN (token).length = i; - PARSER_STREAM (parser) = skip_spaces_const (ptr + i + 1); + PARSER_STREAM (parser) = skip_spaces (ptr + i + 1); break; } } @@ -2697,7 +2697,7 @@ parse_linespec (linespec_parser *parser, const char *arg) advances past a keyword automatically, so skip it manually. */ parser->completion_word - = skip_spaces_const (skip_to_space_const (PARSER_STREAM (parser))); + = skip_spaces (skip_to_space (PARSER_STREAM (parser))); parser->complete_what = linespec_complete_what::EXPRESSION; } -- cgit v1.1