startup: report an error when the given line or column number is invalid
This fixes https://savannah.gnu.org/bugs/?50028.master
parent
605f031833
commit
e8c7cf2071
10
src/nano.c
10
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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue