- 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)
#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)
{
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);
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;
}
#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) {