From 0dd351a5c1bfc0112934015f7064e8b889cee130 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 4 Jan 2016 10:05:52 +0000 Subject: [PATCH] Condensing the exit code of do_linter(). git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5531 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/text.c | 35 +++++++++++------------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8dcf2325..3330c6ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * src/global.c (shortcut_init): Nowadays the functions are defined 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/text.c (do_linter): Condense the exit code. 2016-01-04 Mike Frysinger * src/global.c (strtosc, strtomenu): Constify the input parameter. diff --git a/src/text.c b/src/text.c index 75a4f016..e0c10c8f 100644 --- a/src/text.c +++ b/src/text.c @@ -2899,13 +2899,7 @@ void do_spell(void) #endif /* !DISABLE_SPELLER */ #ifndef DISABLE_COLOR -/* Cleanup things to do after leaving the linter. */ -void lint_cleanup(void) -{ - display_main_list(); -} - -/* Run linter. Based on alt-speller code. Return NULL for normal +/* Run a linting program on the current buffer. Return NULL for normal * termination, and the error string otherwise. */ void do_linter(void) { @@ -2935,13 +2929,10 @@ void do_linter(void) int i = do_yesno_prompt(FALSE, _("Save modified buffer before linting?")); if (i == -1) { statusbar(_("Cancelled")); - lint_cleanup(); - return; + goto exit_from_lint; } else if (i == 1) { - if (do_writeout(FALSE) != TRUE) { - lint_cleanup(); - return; - } + if (do_writeout(FALSE) != TRUE) + goto exit_from_lint; } } @@ -2949,8 +2940,7 @@ void do_linter(void) /* Create pipe up front. */ if (pipe(lint_fd) == -1) { statusbar(_("Could not create pipe")); - lint_cleanup(); - return; + goto exit_from_lint; } blank_bottombars(); @@ -3000,16 +2990,14 @@ void do_linter(void) if (pid_lint < 0) { close(lint_fd[0]); statusbar(_("Could not fork")); - lint_cleanup(); - return; + goto exit_from_lint; } /* Get the system pipe buffer size. */ if ((pipe_buff_size = fpathconf(lint_fd[0], _PC_PIPE_BUF)) < 1) { close(lint_fd[0]); statusbar(_("Could not get size of pipe buffer")); - lint_cleanup(); - return; + goto exit_from_lint; } /* Read in the returned syntax errors. */ @@ -3109,16 +3097,14 @@ void do_linter(void) if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) { statusbar(invocation_error(openfile->syntax->linter)); - lint_cleanup(); - return; + goto exit_from_lint; } free(read_buff); if (parsesuccess == 0) { statusbar(_("Got 0 parsable lines from command: %s"), openfile->syntax->linter); - lint_cleanup(); - return; + goto exit_from_lint; } bottombars(MLINTER); @@ -3218,7 +3204,8 @@ void do_linter(void) free(tmplint->filename); free(tmplint); } - lint_cleanup(); + exit_from_lint: + display_main_list(); } #ifndef DISABLE_SPELLER -- 2.39.5