unpartition_filestruct() should take a partition** instead of a
partition*, so that the partition it refers to is properly set to NULL git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2117 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
e56d936bd4
Коммит
74d87073f0
@ -637,7 +637,7 @@ void do_insertfile(
|
||||
* again. Note that we've replaced the non-text
|
||||
* originally in the partition with the text in the
|
||||
* inserted file/executed command output. */
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
/* Renumber starting with the beginning line of the old
|
||||
* partition. */
|
||||
@ -1802,7 +1802,7 @@ int write_marked(const char *name, bool tmp, int append)
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text
|
||||
* again. */
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
if (old_modified)
|
||||
set_modified();
|
||||
|
36
src/nano.c
36
src/nano.c
@ -672,7 +672,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
|
||||
|
||||
/* Unpartition a filestruct so it begins at (fileage, 0) and ends at
|
||||
* (filebot, strlen(filebot)) again. */
|
||||
void unpartition_filestruct(partition *p)
|
||||
void unpartition_filestruct(partition **p)
|
||||
{
|
||||
char *tmp;
|
||||
assert(p != NULL && fileage != NULL && filebot != NULL);
|
||||
@ -681,37 +681,37 @@ void unpartition_filestruct(partition *p)
|
||||
* text before top_x from top_data. Free top_data when we're done
|
||||
* with it. */
|
||||
tmp = mallocstrcpy(NULL, fileage->data);
|
||||
fileage->prev = p->top_prev;
|
||||
fileage->prev = (*p)->top_prev;
|
||||
if (fileage->prev != NULL)
|
||||
fileage->prev->next = fileage;
|
||||
fileage->data = charealloc(fileage->data, strlen(p->top_data) +
|
||||
fileage->data = charealloc(fileage->data, strlen((*p)->top_data) +
|
||||
strlen(fileage->data) + 1);
|
||||
strcpy(fileage->data, p->top_data);
|
||||
free(p->top_data);
|
||||
strcpy(fileage->data, (*p)->top_data);
|
||||
free((*p)->top_data);
|
||||
strcat(fileage->data, tmp);
|
||||
free(tmp);
|
||||
|
||||
/* Reattach the line below the bottom of the partition, and restore
|
||||
* the text after bot_x from bot_data. Free bot_data when we're
|
||||
* done with it. */
|
||||
filebot->next = p->bot_next;
|
||||
filebot->next = (*p)->bot_next;
|
||||
if (filebot->next != NULL)
|
||||
filebot->next->prev = filebot;
|
||||
filebot->data = charealloc(filebot->data, strlen(filebot->data) +
|
||||
strlen(p->bot_data) + 1);
|
||||
strcat(filebot->data, p->bot_data);
|
||||
free(p->bot_data);
|
||||
strlen((*p)->bot_data) + 1);
|
||||
strcat(filebot->data, (*p)->bot_data);
|
||||
free((*p)->bot_data);
|
||||
|
||||
/* Restore the top and bottom of the filestruct, if they were
|
||||
* different from the top and bottom of the partition. */
|
||||
if (p->fileage != NULL)
|
||||
fileage = p->fileage;
|
||||
if (p->filebot != NULL)
|
||||
filebot = p->filebot;
|
||||
if ((*p)->fileage != NULL)
|
||||
fileage = (*p)->fileage;
|
||||
if ((*p)->filebot != NULL)
|
||||
filebot = (*p)->filebot;
|
||||
|
||||
/* Uninitialize the partition. */
|
||||
free(p);
|
||||
p = NULL;
|
||||
free(*p);
|
||||
*p = NULL;
|
||||
}
|
||||
|
||||
void renumber_all(void)
|
||||
@ -1638,7 +1638,7 @@ bool do_int_spell_fix(const char *word)
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text
|
||||
* again, and turn the mark back on. */
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
SET(MARK_ISSET);
|
||||
}
|
||||
#endif
|
||||
@ -2006,7 +2006,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
* again. Note that we've replaced the marked text originally
|
||||
* in the partition with the spell-checked marked text in the
|
||||
* temp file. */
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
/* Renumber starting with the beginning line of the old
|
||||
* partition. Also add the number of lines and characters in
|
||||
@ -3063,7 +3063,7 @@ void handle_sigwinch(int s)
|
||||
|
||||
/* If we've partitioned the filestruct, unpartition it now. */
|
||||
if (filepart != NULL)
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang curses emulation brain damage, part 1: If we just do what
|
||||
|
@ -307,7 +307,7 @@ filestruct *copy_filestruct(const filestruct *src);
|
||||
void free_filestruct(filestruct *src);
|
||||
partition *partition_filestruct(filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x);
|
||||
void unpartition_filestruct(partition *p);
|
||||
void unpartition_filestruct(partition **p);
|
||||
void renumber_all(void);
|
||||
void renumber(filestruct *fileptr);
|
||||
void print1opt(const char *shortflag, const char *longflag, const char
|
||||
|
@ -848,7 +848,7 @@ ssize_t do_replace_loop(const char *needle, const filestruct
|
||||
/* If the mark was on, unpartition the filestruct so that it
|
||||
* contains all the text again, set edittop back to what it was
|
||||
* before, turn the mark back on, and refresh the screen. */
|
||||
unpartition_filestruct(filepart);
|
||||
unpartition_filestruct(&filepart);
|
||||
edittop = edittop_save;
|
||||
SET(MARK_ISSET);
|
||||
edit_refresh();
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user