avoid any more editbot-related segfaults by removing the last of the

references to it, as in DB's patch


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1697 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-03-19 02:15:42 +00:00
parent aca5d04f42
commit b977515bd7
6 changed files with 8 additions and 44 deletions

View File

@ -38,6 +38,9 @@ CVS code -
pointing to a different memory block, there will be a segfault pointing to a different memory block, there will be a segfault
when the value of def is copied into it via strcpy(). (bort, when the value of def is copied into it via strcpy(). (bort,
Christian Weisgarber, David Benbennick, and DLR) Christian Weisgarber, David Benbennick, and DLR)
- Remove the last editbot references, to avoid any potential
segfaults related to them. Also remove fix_editbot(), as it's
no longer needed. (David Benbennick)
- files.c: - files.c:
do_insertfile() do_insertfile()
- Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef. - Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef.

View File

@ -75,7 +75,6 @@ void new_file(void)
fileage->data[0] = '\0'; fileage->data[0] = '\0';
filebot = fileage; filebot = fileage;
edittop = fileage; edittop = fileage;
editbot = fileage;
current = fileage; current = fileage;
current_x = 0; current_x = 0;
totlines = 1; totlines = 1;
@ -592,9 +591,6 @@ int do_insertfile(int loading_file)
#endif #endif
set_modified(); set_modified();
/* Here we want to rebuild the edit window */
fix_editbot();
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* If we've loaded another file, update the titlebar's contents */ /* If we've loaded another file, update the titlebar's contents */
if (loading_file) { if (loading_file) {
@ -618,10 +614,7 @@ int do_insertfile(int loading_file)
#endif #endif
/* If we've gone off the bottom, recenter; otherwise, just redraw */ /* If we've gone off the bottom, recenter; otherwise, just redraw */
if (current->lineno > editbot->lineno) edit_refresh();
edit_update(current, CENTER);
else
edit_refresh();
} else { } else {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));

View File

@ -59,7 +59,6 @@ filestruct *fileage = NULL; /* Our file buffer */
filestruct *edittop = NULL; /* Pointer to the top of the edit filestruct *edittop = NULL; /* Pointer to the top of the edit
buffer with respect to the buffer with respect to the
file struct */ file struct */
filestruct *editbot = NULL; /* Same for the bottom */
filestruct *filebot = NULL; /* Last node in the file struct */ filestruct *filebot = NULL; /* Last node in the file struct */
filestruct *cutbuffer = NULL; /* A place to store cut text */ filestruct *cutbuffer = NULL; /* A place to store cut text */

View File

@ -202,7 +202,6 @@ void global_init(int save_cutbuffer)
cutbuffer = NULL; cutbuffer = NULL;
current = NULL; current = NULL;
edittop = NULL; edittop = NULL;
editbot = NULL;
totlines = 0; totlines = 0;
totsize = 0; totsize = 0;
placewewant = 0; placewewant = 0;
@ -961,10 +960,8 @@ void do_char(char ch)
/* When a character is inserted on the current magicline, it means /* When a character is inserted on the current magicline, it means
* we need a new one! */ * we need a new one! */
if (filebot == current) { if (filebot == current)
new_magicline(); new_magicline();
fix_editbot();
}
/* More dangerousness fun =) */ /* More dangerousness fun =) */
current->data = charealloc(current->data, current_len + 2); current->data = charealloc(current->data, current_len + 2);
@ -1064,10 +1061,8 @@ int do_delete(void)
strcat(current->data, current->next->data); strcat(current->data, current->next->data);
foo = current->next; foo = current->next;
if (filebot == foo) { if (filebot == foo)
filebot = current; filebot = current;
editbot = current;
}
unlink_node(foo); unlink_node(foo);
delete_node(foo); delete_node(foo);
@ -1132,10 +1127,8 @@ int do_enter(void)
} }
*tmp = '\0'; *tmp = '\0';
if (current->next == NULL) { if (current->next == NULL)
filebot = newnode; filebot = newnode;
editbot = newnode;
}
splice_node(current, newnode, current->next); splice_node(current, newnode, current->next);
totsize++; totsize++;
@ -2444,7 +2437,6 @@ int do_justify(void)
int flags_save = flags; int flags_save = flags;
long totsize_save = totsize; long totsize_save = totsize;
filestruct *edittop_save = edittop; filestruct *edittop_save = edittop;
filestruct *editbot_save = editbot;
#ifndef NANO_SMALL #ifndef NANO_SMALL
filestruct *mark_beginbuf_save = mark_beginbuf; filestruct *mark_beginbuf_save = mark_beginbuf;
int mark_beginx_save = mark_beginx; int mark_beginx_save = mark_beginx;
@ -2675,7 +2667,6 @@ int do_justify(void)
current_x = current_x_save; current_x = current_x_save;
current_y = current_y_save; current_y = current_y_save;
edittop = edittop_save; edittop = edittop_save;
editbot = editbot_save;
if (first_mod_line != NULL) { if (first_mod_line != NULL) {
filestruct *cutbottom = get_cutbottom(); filestruct *cutbottom = get_cutbottom();
@ -2940,16 +2931,6 @@ void handle_sigwinch(int s)
#endif /* HAVE_WRESIZE */ #endif /* HAVE_WRESIZE */
#endif /* HAVE_RESIZETERM */ #endif /* HAVE_RESIZETERM */
fix_editbot();
if (current_y > editwinrows - 1)
edit_update(editbot, CENTER);
erase();
/* Do these because width may have changed. */
refresh();
titlebar(NULL);
edit_refresh();
display_main_list(); display_main_list();
blank_statusbar(); blank_statusbar();
total_refresh(); total_refresh();
@ -3014,7 +2995,6 @@ void do_toggle(const toggle *which)
wclear(bottomwin); wclear(bottomwin);
wrefresh(bottomwin); wrefresh(bottomwin);
window_init(); window_init();
fix_editbot();
edit_refresh(); edit_refresh();
display_main_list(); display_main_list();
break; break;

View File

@ -74,7 +74,7 @@ extern char *alt_speller;
extern int resetstatuspos; extern int resetstatuspos;
extern struct stat fileinfo; extern struct stat fileinfo;
extern filestruct *current, *fileage, *edittop, *editbot, *filebot; extern filestruct *current, *fileage, *edittop, *filebot;
extern filestruct *cutbuffer; extern filestruct *cutbuffer;
#ifndef NANO_SMALL #ifndef NANO_SMALL
extern filestruct *mark_beginbuf; extern filestruct *mark_beginbuf;
@ -517,7 +517,6 @@ int do_cursorpos_void(void);
int line_len(const char *ptr); int line_len(const char *ptr);
int do_help(void); int do_help(void);
void do_replace_highlight(int highlight_flag, const char *word); void do_replace_highlight(int highlight_flag, const char *word);
void fix_editbot(void);
#ifdef DEBUG #ifdef DEBUG
void dump_buffer(const filestruct *inptr); void dump_buffer(const filestruct *inptr);
void dump_buffer_reverse(void); void dump_buffer_reverse(void);

View File

@ -2491,16 +2491,6 @@ void do_replace_highlight(int highlight_flag, const char *word)
wattroff(edit, A_REVERSE); wattroff(edit, A_REVERSE);
} }
/* Fix editbot, based on the assumption that edittop is correct. */
void fix_editbot(void)
{
int i;
editbot = edittop;
for (i = 0; i < editwinrows && editbot->next != NULL; i++)
editbot = editbot->next;
}
#ifdef DEBUG #ifdef DEBUG
/* Dump the passed-in file structure to stderr. */ /* Dump the passed-in file structure to stderr. */
void dump_buffer(const filestruct *inptr) void dump_buffer(const filestruct *inptr)