Condensing the exit code of do_linter().

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5531 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2016-01-04 10:05:52 +00:00
parent dd29c56993
commit 0dd351a5c1
2 changed files with 12 additions and 24 deletions

View File

@ -2,6 +2,7 @@
* src/global.c (shortcut_init): Nowadays the functions are defined * src/global.c (shortcut_init): Nowadays the functions are defined
only once, so there is no longer any need to free existing ones. only once, so there is no longer any need to free existing ones.
* src/global.c (sctofunc): Rewrite the loop, and constify the input. * src/global.c (sctofunc): Rewrite the loop, and constify the input.
* src/text.c (do_linter): Condense the exit code.
2016-01-04 Mike Frysinger <vapier@gentoo.org> 2016-01-04 Mike Frysinger <vapier@gentoo.org>
* src/global.c (strtosc, strtomenu): Constify the input parameter. * src/global.c (strtosc, strtomenu): Constify the input parameter.

View File

@ -2899,13 +2899,7 @@ void do_spell(void)
#endif /* !DISABLE_SPELLER */ #endif /* !DISABLE_SPELLER */
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
/* Cleanup things to do after leaving the linter. */ /* Run a linting program on the current buffer. Return NULL for normal
void lint_cleanup(void)
{
display_main_list();
}
/* Run linter. Based on alt-speller code. Return NULL for normal
* termination, and the error string otherwise. */ * termination, and the error string otherwise. */
void do_linter(void) void do_linter(void)
{ {
@ -2935,13 +2929,10 @@ void do_linter(void)
int i = do_yesno_prompt(FALSE, _("Save modified buffer before linting?")); int i = do_yesno_prompt(FALSE, _("Save modified buffer before linting?"));
if (i == -1) { if (i == -1) {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
lint_cleanup(); goto exit_from_lint;
return;
} else if (i == 1) { } else if (i == 1) {
if (do_writeout(FALSE) != TRUE) { if (do_writeout(FALSE) != TRUE)
lint_cleanup(); goto exit_from_lint;
return;
}
} }
} }
@ -2949,8 +2940,7 @@ void do_linter(void)
/* Create pipe up front. */ /* Create pipe up front. */
if (pipe(lint_fd) == -1) { if (pipe(lint_fd) == -1) {
statusbar(_("Could not create pipe")); statusbar(_("Could not create pipe"));
lint_cleanup(); goto exit_from_lint;
return;
} }
blank_bottombars(); blank_bottombars();
@ -3000,16 +2990,14 @@ void do_linter(void)
if (pid_lint < 0) { if (pid_lint < 0) {
close(lint_fd[0]); close(lint_fd[0]);
statusbar(_("Could not fork")); statusbar(_("Could not fork"));
lint_cleanup(); goto exit_from_lint;
return;
} }
/* Get the system pipe buffer size. */ /* Get the system pipe buffer size. */
if ((pipe_buff_size = fpathconf(lint_fd[0], _PC_PIPE_BUF)) < 1) { if ((pipe_buff_size = fpathconf(lint_fd[0], _PC_PIPE_BUF)) < 1) {
close(lint_fd[0]); close(lint_fd[0]);
statusbar(_("Could not get size of pipe buffer")); statusbar(_("Could not get size of pipe buffer"));
lint_cleanup(); goto exit_from_lint;
return;
} }
/* Read in the returned syntax errors. */ /* Read in the returned syntax errors. */
@ -3109,16 +3097,14 @@ void do_linter(void)
if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) { if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) {
statusbar(invocation_error(openfile->syntax->linter)); statusbar(invocation_error(openfile->syntax->linter));
lint_cleanup(); goto exit_from_lint;
return;
} }
free(read_buff); free(read_buff);
if (parsesuccess == 0) { if (parsesuccess == 0) {
statusbar(_("Got 0 parsable lines from command: %s"), openfile->syntax->linter); statusbar(_("Got 0 parsable lines from command: %s"), openfile->syntax->linter);
lint_cleanup(); goto exit_from_lint;
return;
} }
bottombars(MLINTER); bottombars(MLINTER);
@ -3218,7 +3204,8 @@ void do_linter(void)
free(tmplint->filename); free(tmplint->filename);
free(tmplint); free(tmplint);
} }
lint_cleanup(); exit_from_lint:
display_main_list();
} }
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER