From: Chris Allegretta Date: Mon, 22 Oct 2001 23:22:19 +0000 (+0000) Subject: Fixed null_at to ACTUALLY DO SOMETHING with its arg. Again, this was causing nasty... X-Git-Tag: v1.1.3~11 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=fa0c6963cef19a364b3c7f74ab963292813b6190;p=nano.git Fixed null_at to ACTUALLY DO SOMETHING with its arg. Again, this was causing nasty errors if the call to nrealloc moved where the data was located git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@866 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 52bf278f..26021829 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ CVS code - currshortcut and currslen #ifdefs to depend on both DISABLE_HELP and DISABLE_MOUSE being defined to not include. Changed all the shortcuts and lengths. + - Fixed null_at to ACTUALLY DO SOMETHING with its arg. Again, + this was causing nasty errors if the call to nrealloc moved + where the data was located. - cut.c: do_cut_text() - Check to see whether marked text is contained within edit diff --git a/cut.c b/cut.c index c74aa521..aab6d44f 100644 --- a/cut.c +++ b/cut.c @@ -157,7 +157,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, screwed somewhere. Not doing this causes update_line to annihilate the last line copied into the cutbuffer when the mark is set ?!?!? */ botcopy = copy_node(bot); - null_at(botcopy->data, bot_x); + null_at(&botcopy->data, bot_x); next = botcopy->next; add_to_cutbuffer(botcopy); @@ -451,7 +451,7 @@ int do_uncut_text(void) tmp->data = charalloc(strlen(¤t->data[current_x]) + 1); strcpy(tmp->data, ¤t->data[current_x]); splice_node(current, tmp, current->next); - null_at(current->data, current_x); + null_at(¤t->data, current_x); current = current->next; current_x = 0; placewewant = 0; diff --git a/files.c b/files.c index 966860f0..d6313258 100644 --- a/files.c +++ b/files.c @@ -495,8 +495,8 @@ int add_open_file(int update, int dup_fix) open_files = open_files->next; /* if open_files->file is NULL at the nrealloc() below, we get a - segfault */ - open_files->file = open_files; + segfault + open_files->file = open_files; */ } /* save current filename */ @@ -524,7 +524,7 @@ int add_open_file(int update, int dup_fix) open_files->lineno = current->lineno; /* save current filestruct */ - open_files->file = nrealloc(open_files->file, sizeof(filestruct)); + open_files->file = nmalloc(sizeof(filestruct)); while (current->prev) current = current->prev; open_files->file = copy_filestruct(current); @@ -912,7 +912,7 @@ char *get_full_path(char *origpath) /* otherwise, remove all non-path elements from d_there (i. e. everything after the last slash) */ last_slash_index = strlen(d_there) - strlen(last_slash); - null_at(d_there, last_slash_index + 1); + null_at(&d_there, last_slash_index + 1); /* and remove all non-file elements from d_there_file (i. e. everything before and including the last slash); if we diff --git a/nano.c b/nano.c index b7d550bf..f709bd9f 100644 --- a/nano.c +++ b/nano.c @@ -393,10 +393,12 @@ void align(char **strp) } /* Null a string at a certain index and align it */ -void null_at(char *data, int index) +void null_at(char **data, int index) { - data[index] = 0; - align(&data); + + /* Ahh! Damn dereferencing */ + (*data)[index] = 0; + align(data); } void usage(void) @@ -1024,7 +1026,7 @@ void do_wrap(filestruct * inptr, char input_char) down = 1; } - null_at(inptr->data, current_x); + null_at(&inptr->data, current_x); if (ISSET(MARK_ISSET) && (mark_beginbuf == inptr)) { mark_beginbuf = temp; @@ -1085,7 +1087,7 @@ void do_wrap(filestruct * inptr, char input_char) i = current_word_start - 1; current_x = current_word_start; - null_at(inptr->data, current_word_start); + null_at(&inptr->data, current_word_start); /* Increment totsize to account for the new line that will be added below, so that it won't end up being diff --git a/proto.h b/proto.h index a8ccf824..6c4e4a43 100644 --- a/proto.h +++ b/proto.h @@ -165,7 +165,7 @@ void die_save_file(char *die_filename); void new_file(void); void new_magicline(void); void splice_node(filestruct *begin, filestruct *newnode, filestruct *end); -void null_at(char *data, int index); +void null_at(char **data, int index); void page_up(void); void blank_edit(void); void search_init_globals(void);