Commit e8c7cf20 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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

This fixes https://savannah.gnu.org/bugs/?50028.
No related merge requests found
Showing with 8 additions and 6 deletions
+8 -6
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment