when (un)partitioning, don't save or restore fileage or filebot if
they're the same as top or bot; also add a few comment fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2058 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
8cbd4cb67f
Коммит
f978f040bd
36
src/nano.c
36
src/nano.c
@ -627,13 +627,19 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
|
|||||||
/* Initialize the partition. */
|
/* Initialize the partition. */
|
||||||
p = (partition *)nmalloc(sizeof(partition));
|
p = (partition *)nmalloc(sizeof(partition));
|
||||||
|
|
||||||
/* Save the top and bottom of the filestruct. */
|
/* If the top and bottom of the partition are different from the top
|
||||||
p->fileage = fileage;
|
* and bottom of the filestruct, save the latter and then set them
|
||||||
p->filebot = filebot;
|
* to top and bot. */
|
||||||
|
if (top != fileage) {
|
||||||
/* Set the top and bottom of the partition to top and bot. */
|
p->fileage = fileage;
|
||||||
fileage = top;
|
fileage = top;
|
||||||
filebot = bot;
|
} else
|
||||||
|
p->fileage = NULL;
|
||||||
|
if (bot != filebot) {
|
||||||
|
p->filebot = filebot;
|
||||||
|
filebot = bot;
|
||||||
|
} else
|
||||||
|
p->filebot = NULL;
|
||||||
|
|
||||||
/* Save the line above the top of the partition, detach the top of
|
/* Save the line above the top of the partition, detach the top of
|
||||||
* the partition from it, and save the text before top_x in
|
* the partition from it, and save the text before top_x in
|
||||||
@ -694,9 +700,12 @@ void unpartition_filestruct(partition *p)
|
|||||||
strcat(filebot->data, p->bot_data);
|
strcat(filebot->data, p->bot_data);
|
||||||
free(p->bot_data);
|
free(p->bot_data);
|
||||||
|
|
||||||
/* Restore the top and bottom of the filestruct. */
|
/* Restore the top and bottom of the filestruct, if they were
|
||||||
fileage = p->fileage;
|
* different from the top and bottom of the partition. */
|
||||||
filebot = p->filebot;
|
if (p->fileage != NULL)
|
||||||
|
fileage = p->fileage;
|
||||||
|
if (p->filebot != NULL)
|
||||||
|
filebot = p->filebot;
|
||||||
|
|
||||||
/* Uninitialize the partition. */
|
/* Uninitialize the partition. */
|
||||||
free(p);
|
free(p);
|
||||||
@ -1557,6 +1566,9 @@ bool do_int_spell_fix(const char *word)
|
|||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (old_mark_set) {
|
if (old_mark_set) {
|
||||||
|
/* If the mark is on, partition the filestruct so that it
|
||||||
|
* contains only the marked text, set edittop to the top of the
|
||||||
|
* marked text, and turn the mark off. */
|
||||||
mark_order((const filestruct **)&top, &top_x,
|
mark_order((const filestruct **)&top, &top_x,
|
||||||
(const filestruct **)&bot, &bot_x);
|
(const filestruct **)&bot, &bot_x);
|
||||||
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
||||||
@ -1613,9 +1625,9 @@ bool do_int_spell_fix(const char *word)
|
|||||||
last_replace = save_replace;
|
last_replace = save_replace;
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* If the mark was on, unpartition the filestruct so that it
|
|
||||||
* contains all the text again, and turn the mark back on. */
|
|
||||||
if (old_mark_set) {
|
if (old_mark_set) {
|
||||||
|
/* If the mark was on, 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);
|
SET(MARK_ISSET);
|
||||||
}
|
}
|
||||||
|
@ -845,10 +845,10 @@ ssize_t do_replace_loop(const char *needle, const filestruct
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* 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. */
|
|
||||||
if (old_mark_set) {
|
if (old_mark_set) {
|
||||||
|
/* 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;
|
edittop = edittop_save;
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user