diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2015-11-16 09:30:35 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2015-12-11 23:04:25 +0000 |
commit | 1a48ce76774633e9e27dd245ba275a714b2b339f (patch) | |
tree | 8087c5e80bec67d6a29649e8c2e7c19b3934301c | |
parent | 8c05462adbc01f0aba946c42422146ccca2ae4db (diff) | |
download | gdb-1a48ce76774633e9e27dd245ba275a714b2b339f.zip gdb-1a48ce76774633e9e27dd245ba275a714b2b339f.tar.gz gdb-1a48ce76774633e9e27dd245ba275a714b2b339f.tar.bz2 |
gdb: Small code restructure for list_command.
Move handling of special +/- arguments to the list_command function
inside a single if block, this helps group all related functionality
together. There should be no user visible changes after this commit.
gdb/ChangeLog:
* cli/cli-cmds.c (list_command): Move all handling of +/-
arguments into a single if block.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 28 |
2 files changed, 16 insertions, 17 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7b155d3..17db0c3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com> + * cli/cli-cmds.c (list_command): Move all handling of +/- + arguments into a single if block. + +2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com> + * cli/cli-cmds.c (list_command): Use NULL instead of 0 when checking pointers. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 841fc55..872c844 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -930,27 +930,21 @@ list_command (char *arg, int from_tty) print_source_lines (cursal.symtab, first, first + get_lines_to_list (), 0); - return; } - } - /* "l" or "l +" lists next ten lines. */ + /* "l" or "l +" lists next ten lines. */ + else if (arg == NULL || strcmp (arg, "+") == 0) + print_source_lines (cursal.symtab, cursal.line, + cursal.line + get_lines_to_list (), 0); - if (arg == NULL || strcmp (arg, "+") == 0) - { - print_source_lines (cursal.symtab, cursal.line, - cursal.line + get_lines_to_list (), 0); - return; - } + /* "l -" lists previous ten lines, the ones before the ten just + listed. */ + else if (strcmp (arg, "-") == 0) + print_source_lines (cursal.symtab, + max (get_first_line_listed () + - get_lines_to_list (), 1), + get_first_line_listed (), 0); - /* "l -" lists previous ten lines, the ones before the ten just - listed. */ - if (strcmp (arg, "-") == 0) - { - print_source_lines (cursal.symtab, - max (get_first_line_listed () - - get_lines_to_list (), 1), - get_first_line_listed (), 0); return; } |