in do_alt_speller(), move the code that replaces the text of the current

file with the text of the spell-checked file into its own function,
replace_buffer()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3109 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-08 19:15:58 +00:00
parent 1e0e235cbb
commit 9c984e8e63
4 changed files with 44 additions and 12 deletions

View File

@ -94,6 +94,11 @@ CVS code -
- rcfile.c:
do_rcfile()
- Remove unneeded assert. (DLR)
- text.c:
do_alt_speller()
- Move the code that replaces the text of the current file with
the text of the spell-checked file into its own function,
replace_buffer(). (DLR)
- winio.c:
nanoget_repaint()
- Rename parameter inputbuf to buf, for consistency. (DLR)

View File

@ -168,6 +168,39 @@ void open_buffer(const char *filename)
#endif
}
#ifndef DISABLE_SPELLER
/* If it's not "", filename is a file to open. We blow away the text of
* the current buffer, and then open and read the file, if
* applicable. Note that we skip the operating directory test when
* doing this. */
void replace_buffer(const char *filename)
{
FILE *f;
int rc;
/* rc == -2 means that we have a new file. -1 means that the
* open() failed. 0 means that the open() succeeded. */
assert(filename != NULL);
/* If the filename isn't blank, open the file. Otherwise, treat it
* as a new file. */
rc = (filename[0] != '\0') ? open_file(filename, TRUE, &f) : -2;
/* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage);
initialize_buffer_text();
/* If we have a non-new file, read it in. */
if (rc == 0)
read_file(f, filename);
/* Move back to the beginning of the first line of the buffer. */
openfile->current = openfile->fileage;
openfile->current_x = 0;
openfile->placewewant = 0;
}
#endif /* !DISABLE_SPELLER */
/* Update the screen to account for the current buffer. */
void display_buffer(void)
{

View File

@ -235,6 +235,9 @@ void make_new_buffer(void);
void initialize_buffer(void);
void initialize_buffer_text(void);
void open_buffer(const char *filename);
#ifndef DISABLE_SPELLER
void replace_buffer(const char *filename);
#endif
void display_buffer(void);
#ifdef ENABLE_MULTIBUFFER
void switch_to_prevnext_buffer(bool next);

View File

@ -1836,7 +1836,6 @@ const char *do_alt_speller(char *tempfile_name)
char *ptr;
static int arglen = 3;
static char **spellargs = NULL;
FILE *f;
#ifndef NANO_SMALL
bool old_mark_set = openfile->mark_set;
bool added_magicline = FALSE;
@ -1951,17 +1950,9 @@ const char *do_alt_speller(char *tempfile_name)
}
#endif
/* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage);
initialize_buffer_text();
/* Reload the temp file. Open it, read it into the current buffer,
* and move back to the beginning of the first line of the
* buffer. */
open_file(tempfile_name, FALSE, &f);
read_file(f, tempfile_name);
openfile->current = openfile->fileage;
openfile->current_x = 0;
/* Replace the text of the current buffer with the spell-checked
* text. */
replace_buffer(tempfile_name);
#ifndef NANO_SMALL
if (old_mark_set) {