nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit e8c7cf207113d0a21485a2ba69fe872f3266cb51
parent 605f0318338ca43df3a1a57c116619eab7d5124d
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Tue, 17 Jan 2017 14:17:42 +0100

startup: report an error when the given line or column number is invalid

This fixes https://savannah.gnu.org/bugs/?50028.

Diffstat:
Msrc/nano.c | 10++++++----
Msrc/search.c | 2+-
Msrc/utils.c | 2+-
3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -2557,7 +2557,8 @@ int main(int argc, char **argv) * non-option argument, and it is followed by at least one other * argument, the filename it applies to. */ if (0 < optind && optind < argc - 1 && argv[optind][0] == '+') { - parse_line_column(&argv[optind][1], &startline, &startcol); + if (!parse_line_column(&argv[optind][1], &startline, &startcol)) + statusline(ALERT, _("Invalid line or column number")); optind++; } @@ -2581,9 +2582,10 @@ int main(int argc, char **argv) for (; i < argc; i++) { /* If there's a +LINE or +LINE,COLUMN flag here, it is followed * by at least one other argument: the filename it applies to. */ - if (i < argc - 1 && argv[i][0] == '+') - parse_line_column(&argv[i][1], &iline, &icol); - else { + if (i < argc - 1 && argv[i][0] == '+') { + if (!parse_line_column(&argv[i][1], &iline, &icol)) + statusline(ALERT, _("Invalid line or column number")); + } else { /* If opening fails, don't try to position the cursor. */ if (!open_buffer(argv[i], FALSE)) continue; diff --git a/src/search.c b/src/search.c @@ -894,7 +894,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, /* Try to extract one or two numbers from the user's response. */ if (!parse_line_column(answer, &line, &column)) { - statusbar(_("Invalid line or column number")); + statusline(ALERT, _("Invalid line or column number")); return; } } else { diff --git a/src/utils.c b/src/utils.c @@ -129,7 +129,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) firstpart = mallocstrcpy(NULL, str); firstpart[comma - str] = '\0'; - retval = parse_num(firstpart, line); + retval = parse_num(firstpart, line) && retval; free(firstpart);