From: Robert Siemborski Date: Fri, 9 Jun 2000 00:52:26 +0000 (+0000) Subject: fix for the totsize / cut bug X-Git-Tag: v0.9.11~29 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ea19c7369f895ac2904a06dd09eff7e49dfb0d46;p=nano.git fix for the totsize / cut bug git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@16 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/BUGS b/BUGS index 9a4fcd61..fc43cf2f 100644 --- a/BUGS +++ b/BUGS @@ -32,3 +32,8 @@ until a pageup/down occurs (22). - edit_refresh() and update_line() (and related functions), have trouble when a tab is the character that is the boundry at COLS (23) +- there is an off-by-one error in keeping track of totsize. It is caused + by the fact that we count the newline at the end when we read in a file + but we do not, in fact, display this newline. This should go away + implicitly when the "Magic Line" returns, but it is noted here for + documentation's sake. (24) diff --git a/cut.c b/cut.c index 24b0b32a..3a3cf653 100644 --- a/cut.c +++ b/cut.c @@ -44,7 +44,7 @@ void add_to_cutbuffer(filestruct * inptr) inptr->data); #endif - totsize -= strlen(inptr->data) + 1; + totsize -= strlen(inptr->data); tmp = cutbuffer; if (cutbuffer == NULL) { cutbuffer = inptr; @@ -82,6 +82,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, next = tmp->next; add_to_cutbuffer(tmp); totlines--; + totsize--; /* newline (add_to_cutbuffer doesn't count newlines) */ tmp = next; } while (next != bot && next != NULL); @@ -101,7 +102,8 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, next = bot->next; /* We explicitly don't decrement totlines here because we don't snarf - * up a newline when we're grabbing the last line of the mark */ + * up a newline when we're grabbing the last line of the mark. For + * the same reason we don't do an extra totsize decrement */ add_to_cutbuffer(bot); top->next = next; @@ -183,7 +185,7 @@ int do_cut_text(void) UNSET(MARK_ISSET); marked_cut = 1; set_modified(); - edit_update_top(edittop); + edit_update(current); return 1; #else if (0) { @@ -201,10 +203,9 @@ int do_cut_text(void) current = fileptr; } else { add_to_cutbuffer(fileptr); - totlines--; fileage = make_new_node(NULL); fileage->data = nmalloc(1); - strcpy(fileage->data, ""); + fileage->data[0] = '\0'; current = fileage; } } else { diff --git a/winio.c b/winio.c index 784b9734..96a1e0e1 100644 --- a/winio.c +++ b/winio.c @@ -1066,11 +1066,6 @@ int do_cursorpos(void) for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next) tot += strlen(fileptr->data) + 1; - /* FIXME - This is gardly elegant */ -/* if (current == fileage && strlen(current->data) == 0) - i = 0; -*/ - if (totlines > 0) linepct = 100 * current->lineno / totlines; else