From 0af5788a945bddc428b31a15f27fcb9d9a5c60e5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 1 Mar 2017 09:56:38 +0100 Subject: [PATCH] tweaks: reduce the scope of five variables, and frob some comments --- src/text.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/text.c b/src/text.c index f5189b65..af71d1f1 100644 --- a/src/text.c +++ b/src/text.c @@ -2869,11 +2869,6 @@ const char *do_alt_speller(char *tempfile_name) char *ptr; static int arglen = 3; static char **spellargs = NULL; -#ifndef NANO_TINY - filestruct *top, *bot; - size_t top_x, bot_x; - bool right_side_up = FALSE; -#endif /* Get the timestamp and the size of the temporary file. */ stat(tempfile_name, &spellfileinfo); @@ -2886,7 +2881,7 @@ const char *do_alt_speller(char *tempfile_name) /* Exit from curses mode. */ endwin(); - /* Set up an argument list to pass to execvp(). */ + /* Set up the argument list to pass to execvp(). */ if (spellargs == NULL) { spellargs = (char **)nmalloc(arglen * sizeof(char *)); @@ -2901,17 +2896,13 @@ const char *do_alt_speller(char *tempfile_name) } spellargs[arglen - 2] = tempfile_name; - /* Start a new process for the alternate speller. */ + /* Fork a child process and run the alternate spell program in it. */ if ((pid_spell = fork()) == 0) { - /* Start alternate spell program; we are using $PATH. */ execvp(spellargs[0], spellargs); - /* Should not be reached, if alternate speller is found!!! */ + /* Terminate the child process if no alternate speller is found. */ exit(1); - } - - /* If we couldn't fork, get out. */ - if (pid_spell < 0) + } else if (pid_spell < 0) return _("Could not fork"); #ifndef NANO_TINY @@ -2935,6 +2926,9 @@ const char *do_alt_speller(char *tempfile_name) /* Replace the marked text (or the entire text) of the current buffer * with the spell-checked text. */ if (openfile->mark_set) { + filestruct *top, *bot; + size_t top_x, bot_x; + bool right_side_up; ssize_t was_mark_lineno = openfile->mark_begin->lineno; openfile->mark_set = FALSE; @@ -2951,14 +2945,13 @@ const char *do_alt_speller(char *tempfile_name) else openfile->mark_begin_x = openfile->current_x; - /* Restore the mark's position and turn it on. */ + /* Restore the mark's position and turn it back on. */ openfile->mark_begin = fsfromline(was_mark_lineno); openfile->mark_set = TRUE; } else #endif replace_buffer(tempfile_name); - /* Go back to the old position. */ goto_line_posx(lineno_save, current_x_save); if (was_at_eol || openfile->current_x > strlen(openfile->current->data)) @@ -2977,6 +2970,7 @@ const char *do_alt_speller(char *tempfile_name) discard_until(NULL, openfile); #endif } + #ifndef NANO_TINY /* Unblock SIGWINCHes again. */ allow_sigwinch(TRUE);