- if (arg == 0 || strcmp (arg, "+") == 0)
- {
- print_source_lines (cursal.symtab, cursal.line,
- cursal.line + get_lines_to_list (), 0);
- return;
- }
+ first = std::max (cursal.line - get_lines_to_list () / 2, 1);
+
+ /* A small special case --- if listing backwards, and we
+ should list only one line, list the preceding line,
+ instead of the exact line we've just shown after e.g.,
+ stopping for a breakpoint. */
+ if (arg != NULL && arg[0] == '-'
+ && get_lines_to_list () == 1 && first > 1)
+ first -= 1;
+
+ print_source_lines (cursal.symtab, first,
+ first + get_lines_to_list (), 0);
+ }
+
+ /* "l" or "l +" lists next ten lines. */
+ else if (arg == NULL || arg[0] == '+')
+ print_source_lines (cursal.symtab, cursal.line,
+ cursal.line + get_lines_to_list (), 0);
+
+ /* "l -" lists previous ten lines, the ones before the ten just
+ listed. */
+ else if (arg[0] == '-')
+ {
+ if (get_first_line_listed () == 1)
+ error (_("Already at the start of %s."),
+ symtab_to_filename_for_display (cursal.symtab));
+ print_source_lines (cursal.symtab,
+ std::max (get_first_line_listed ()
+ - get_lines_to_list (), 1),
+ get_first_line_listed (), 0);
+ }