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
master
Chris Allegretta 2001-10-22 23:22:19 +00:00
parent 878ced39bf
commit fa0c6963ce
5 changed files with 17 additions and 12 deletions

View File

@ -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

4
cut.c
View File

@ -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(&current->data[current_x]) + 1);
strcpy(tmp->data, &current->data[current_x]);
splice_node(current, tmp, current->next);
null_at(current->data, current_x);
null_at(&current->data, current_x);
current = current->next;
current_x = 0;
placewewant = 0;

View File

@ -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

12
nano.c
View File

@ -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

View File

@ -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);