nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 59bbc0b85831cfbb115fbe8a18cc0e899984f790
parent 731fd935ff7d555b462f25b9390f159350deb784
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat,  1 Aug 2020 11:49:28 +0200

tweaks: print error message directly instead of passing it to the caller

This will allow a simplification in the next commit.

Diffstat:
Msrc/text.c | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -2335,8 +2335,10 @@ const char *do_int_speller(const char *tempfile_name) int spell_status, sort_status, uniq_status; /* Create all three pipes up front. */ - if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) - return _("Could not create pipe"); + if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) { + statusline(ALERT, _("Could not create pipe")); + return NULL; + } /* Fork a process to run spell in. */ if ((pid_spell = fork()) == 0) { @@ -2422,7 +2424,8 @@ const char *do_int_speller(const char *tempfile_name) if (pipesize < 1) { close(uniq_fd[0]); - return _("Could not get size of pipe buffer"); + statusline(ALERT, _("Could not get size of pipe buffer")); + return NULL; } /* Leave curses mode so that error messages go to the original screen. */ @@ -2488,16 +2491,14 @@ const char *do_int_speller(const char *tempfile_name) waitpid(pid_uniq, &uniq_status, 0); if (WIFEXITED(uniq_status) == 0 || WEXITSTATUS(uniq_status)) - return _("Error invoking \"uniq\""); - - if (WIFEXITED(sort_status) == 0 || WEXITSTATUS(sort_status)) - return _("Error invoking \"sort\""); - - if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status)) - return _("Error invoking \"spell\""); + statusline(ALERT, _("Error invoking \"uniq\"")); + else if (WIFEXITED(sort_status) == 0 || WEXITSTATUS(sort_status)) + statusline(ALERT, _("Error invoking \"sort\"")); + else if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status)) + statusline(ALERT, _("Error invoking \"spell\"")); + else + statusbar(_("Finished checking spelling")); - /* When all went okay. */ - statusbar(_("Finished checking spelling")); return NULL; }