make m_dupstr return NULL if the string was empty.
[apps/madmutt.git] / curs_main.c
index 1217c5e..81d59c2 100644 (file)
@@ -15,6 +15,8 @@
 #endif
 
 #include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
 
 #include "mutt.h"
 #include "mutt_curses.h"
@@ -47,8 +49,6 @@
 #include "mutt_sasl.h"
 #endif
 
-#include "lib/intl.h"
-#include "lib/str.h"
 #include "lib/debug.h"
 
 #include <ctype.h>
@@ -445,7 +445,7 @@ int mutt_index_menu (void)
       sidebar_set_current (Context->path);
   }
 
-  FOREVER {
+  for (;;) {
     tag = 0;                    /* clear the tag-prefix */
 
     menu->max = Context ? Context->vcount : 0;
@@ -966,7 +966,7 @@ int mutt_index_menu (void)
           unset_option (OPTHIDEREAD);
         }
         p_delete(&Context->pattern);
-        Context->pattern = str_dup (buf);
+        Context->pattern = m_strdup(buf);
       }
       if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
           mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
@@ -1202,13 +1202,13 @@ int mutt_index_menu (void)
 #endif
       {
         if (Context && Context->path)
-          strncpy (buf, Context->path, sizeof (buf));
+          m_strcpy(buf, sizeof(buf), Context->path);
         if (op != OP_SIDEBAR_OPEN)
           buffy_next (buf, sizeof (buf));
       }
 
       if (op == OP_SIDEBAR_OPEN) {
-        strncpy (buf, NONULL(sidebar_get_current ()), sizeof (buf));
+        m_strcpy(buf, sizeof(buf), sidebar_get_current());
       }
       else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) {
         if (menu->menu == MENU_PAGER) {