commit f83e5e2b136f576f23207816c38a7a1b2158ad4a
parent 650b39c43d5971537e4bf55baa85a5692aad01a6
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 17 May 2005 18:29:05 +0000
fix off-by-one problems with COLUMN; it should be zero-based
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2524 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -4496,7 +4496,7 @@ int main(int argc, char **argv)
display_main_list();
if (startline > 1 || startcol > 1)
- do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE);
+ do_gotolinecolumn(startline, startcol - 1, FALSE, FALSE, FALSE);
#ifndef NANO_SMALL
/* Return here after a SIGWINCH. */
diff --git a/src/search.c b/src/search.c
@@ -255,7 +255,7 @@ int search_init(bool replacing, bool use_answer)
#ifndef NANO_SMALL
search_history.current = search_history.next;
#endif
- do_gotolinecolumn(1, 1, TRUE, TRUE, FALSE);
+ do_gotolinecolumn(1, 0, TRUE, TRUE, FALSE);
/* Put answer up on the statusbar and
* fall through. */
default:
@@ -998,9 +998,11 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
}
/* Do a bounds check. Display a warning on an out-of-bounds
- * line number only if we hit Enter at the statusbar prompt. */
+ * line number (which is one-based) or an out-of-bounds column
+ * number (which is zero-based) only if we hit Enter at the
+ * statusbar prompt. */
if (!parse_line_column(answer, &line, &column) || line < 1 ||
- column < 1) {
+ column < 0) {
if (i == 0)
statusbar(_("Come on, be reasonable"));
display_main_list();
@@ -1010,8 +1012,8 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
if (line < 1)
line = 1;
- if (column < 1)
- column = 1;
+ if (column < 0)
+ column = 0;
}
if (current->lineno > line) {
@@ -1024,8 +1026,8 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
;
}
- current_x = actual_x(current->data, column - 1);
- placewewant = column - 1;
+ current_x = actual_x(current->data, column);
+ placewewant = column;
/* If save_pos is TRUE, don't change the cursor position when
* updating the edit window. */