From: Thomas Roessler Date: Tue, 29 Aug 2000 11:36:25 +0000 (+0000) Subject: The next version of Byrial Jensen's yesorno patch, this time without X-Git-Tag: mutt-1-3-8-rel~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d21346185d44ecb00971130c9519b10e7bb0777f;p=mutt The next version of Byrial Jensen's yesorno patch, this time without a memory leak. --- diff --git a/curs_lib.c b/curs_lib.c index 68db3d12..6cec1087 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -147,8 +147,8 @@ void mutt_edit_file (const char *editor, const char *data) int mutt_yesorno (const char *msg, int def) { event_t ch; - unsigned char *yes = (unsigned char *) _("yes"); - unsigned char *no = (unsigned char *) _("no"); + char *yes = _("yes"); + char *no = _("no"); #ifdef HAVE_LANGINFO_YESEXPR regex_t reyes; @@ -166,10 +166,13 @@ int mutt_yesorno (const char *msg, int def) { mutt_refresh (); ch = mutt_getch (); - if (ch.ch == -1) - return (-1); if (CI_is_return (ch.ch)) break; + if (ch.ch == -1) + { + def = -1; + break; + } #ifdef HAVE_LANGINFO_YESEXPR answer[0] = ch.ch; @@ -199,8 +202,6 @@ int mutt_yesorno (const char *msg, int def) } } - addstr ((char *) (def ? yes : no)); - mutt_refresh (); #ifdef HAVE_LANGINFO_YESEXPR if (reyes_ok) regfree (& reyes); @@ -208,6 +209,11 @@ int mutt_yesorno (const char *msg, int def) regfree (& reno); #endif + if (def >= 0) + { + addstr ((char *) (def ? yes : no)); + mutt_refresh (); + } return (def); }