tweaks: move a variable that doesn't need to be global

master
Benno Schulenberg 2016-10-12 19:59:26 +02:00
parent d9148e7b3f
commit 3264d0c5be
3 changed files with 13 additions and 24 deletions

View File

@ -90,10 +90,6 @@ filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */ /* The buffer where we store cut text. */
filestruct *cutbottom = NULL; filestruct *cutbottom = NULL;
/* The last line in the cutbuffer. */ /* The last line in the cutbuffer. */
#ifndef DISABLE_JUSTIFY
filestruct *jusbuffer = NULL;
/* The buffer where we store unjustified text. */
#endif
partition *filepart = NULL; partition *filepart = NULL;
/* The "partition" where we store a portion of the current file. */ /* The "partition" where we store a portion of the current file. */
openfilestruct *openfile = NULL; openfilestruct *openfile = NULL;
@ -1691,9 +1687,6 @@ void thanks_for_all_the_fish(void)
free(alt_speller); free(alt_speller);
#endif #endif
free_filestruct(cutbuffer); free_filestruct(cutbuffer);
#ifndef DISABLE_JUSTIFY
free_filestruct(jusbuffer);
#endif
/* Free the memory associated with each open file buffer. */ /* Free the memory associated with each open file buffer. */
while (openfile != openfile->next) { while (openfile != openfile->next) {
openfile = openfile->next; openfile = openfile->next;

View File

@ -73,9 +73,6 @@ extern int maxrows;
extern filestruct *cutbuffer; extern filestruct *cutbuffer;
extern filestruct *cutbottom; extern filestruct *cutbottom;
#ifndef DISABLE_JUSTIFY
extern filestruct *jusbuffer;
#endif
extern partition *filepart; extern partition *filepart;
extern openfilestruct *openfile; extern openfilestruct *openfile;

View File

@ -42,8 +42,10 @@ static bool prepend_wrap = FALSE;
/* Should we prepend wrapped text to the next line? */ /* Should we prepend wrapped text to the next line? */
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
static filestruct *jusbuffer = NULL;
/* The buffer where we store unjustified text. */
static filestruct *jusbottom = NULL; static filestruct *jusbottom = NULL;
/* Pointer to the end of the justify buffer. */ /* A pointer to the end of the buffer with unjustified text. */
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
@ -2513,8 +2515,8 @@ void do_justify(bool full_justify)
|| func == do_undo || func == do_undo
#endif #endif
) { ) {
/* Splice the justify buffer back into the file, but only if we /* If we actually justified something, then splice the preserved
* actually justified something. */ * unjustified text back into the file, */
if (first_par_line != NULL) { if (first_par_line != NULL) {
/* Partition the filestruct so that it contains only the /* Partition the filestruct so that it contains only the
* text of the justified paragraph. */ * text of the justified paragraph. */
@ -2522,24 +2524,19 @@ void do_justify(bool full_justify)
last_par_line, filebot_inpar ? last_par_line, filebot_inpar ?
strlen(last_par_line->data) : 0); strlen(last_par_line->data) : 0);
/* Remove the text of the justified paragraph, and /* Throw away the justified paragraph, and replace it with
* replace it with the text in the justify buffer. */ * the preserved unjustified text. */
free_filestruct(openfile->fileage); free_filestruct(openfile->fileage);
openfile->fileage = jusbuffer; openfile->fileage = jusbuffer;
openfile->filebot = jusbottom; openfile->filebot = jusbottom;
/* Unpartition the filestruct so that it contains all the /* Unpartition the filestruct, to contain the entire text again. */
* text again. Note that the justified paragraph has been
* replaced with the unjustified paragraph. */
unpartition_filestruct(&filepart); unpartition_filestruct(&filepart);
/* Renumber, from the beginning of the unjustified part. */ /* Renumber, from the beginning of the unjustified part. */
renumber(jusbuffer); renumber(jusbuffer);
/* Mark the justify buffer as empty, as it's been swallowed. */ /* Restore the old position, the size, and the mark. */
jusbuffer = NULL;
/* Restore the justify we just did (ungrateful user!). */
openfile->edittop = edittop_save; openfile->edittop = edittop_save;
openfile->current = current_save; openfile->current = current_save;
openfile->current_x = current_x_save; openfile->current_x = current_x_save;
@ -2569,11 +2566,13 @@ void do_justify(bool full_justify)
discard_until(NULL, openfile); discard_until(NULL, openfile);
openfile->current_undo = NULL; openfile->current_undo = NULL;
#endif #endif
/* Blow away the text in the justify buffer. */ /* Blow away the unjustified text. */
free_filestruct(jusbuffer); free_filestruct(jusbuffer);
jusbuffer = NULL;
} }
/* Mark the buffer for unjustified text as empty. */
jusbuffer = NULL;
blank_statusbar(); blank_statusbar();
/* Display the shortcut list with UnCut. */ /* Display the shortcut list with UnCut. */