Cut and renumber fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2000-12-10 05:44:02 +00:00
parent ef12311948
commit 5146fec04c
3 changed files with 21 additions and 4 deletions

View File

@ -1,8 +1,16 @@
CVS code - CVS code -
- cut.c:
do_uncut_text()
- Fix renumbering bug when uncutting marked test at filebot.
- Fix screen not being displayed when we are uncutting marked
text at editbot (Bug discovered by Ken Tyler).
- files.c: - files.c:
write_file() write_file()
- Change open call flags, basically copy joe's way of doing it so - Change open call flags, basically copy joe's way of doing it so
a more recent version will actually be included in (un)stable. a more recent version will actually be included in (un)stable.
- nano.c:
renumber()
- Dont stupidly assign the value of prev->lineno if prev == NULL!
nano 0.9.23 - 12/08/2000 nano 0.9.23 - 12/08/2000
General General

12
cut.c
View File

@ -271,7 +271,7 @@ int do_cut_text(void)
int do_uncut_text(void) int do_uncut_text(void)
{ {
filestruct *tmp = current, *fileptr = current, *newbuf, *newend; filestruct *tmp = current, *hold = current, *fileptr = current, *newbuf, *newend;
#ifndef NANO_SMALL #ifndef NANO_SMALL
char *tmpstr, *tmpstr2; char *tmpstr, *tmpstr2;
#endif #endif
@ -339,8 +339,12 @@ int do_uncut_text(void)
if (tmp != NULL) if (tmp != NULL)
tmp->prev = newend; tmp->prev = newend;
else else {
/* Fix the editbot pointer too */
if (editbot == filebot)
editbot = newend;
filebot = newend; filebot = newend;
}
/* Now why don't we update the totsize also */ /* Now why don't we update the totsize also */
for (tmp = current->next; tmp != newend; tmp = tmp->next) for (tmp = current->next; tmp != newend; tmp = tmp->next)
@ -368,7 +372,9 @@ int do_uncut_text(void)
current_x = 0; current_x = 0;
placewewant = 0; placewewant = 0;
} }
renumber(current->prev); /* Renumber from BEFORE where we pasted ;) */
renumber(hold);
dump_buffer(fileage); dump_buffer(fileage);
dump_buffer(cutbuffer); dump_buffer(cutbuffer);
set_modified(); set_modified();

5
nano.c
View File

@ -315,7 +315,10 @@ int renumber(filestruct * fileptr)
return 0; return 0;
} }
for (temp = fileptr; temp != NULL; temp = temp->next) { for (temp = fileptr; temp != NULL; temp = temp->next) {
temp->lineno = temp->prev->lineno + 1; if (temp->prev != NULL)
temp->lineno = temp->prev->lineno + 1;
else
temp->lineno = 1;
} }
return 0; return 0;