]> granicus.if.org Git - neomutt/commitdiff
The next version of Byrial Jensen's yesorno patch, this time without
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 29 Aug 2000 11:36:25 +0000 (11:36 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 29 Aug 2000 11:36:25 +0000 (11:36 +0000)
a memory leak.

curs_lib.c

index 68db3d12924bee3c2642580f4bda8aa461cdd33b..6cec10875eb5113a1c10bc6415d4ba9696f441f8 100644 (file)
@@ -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);
 }