make m_dupstr return NULL if the string was empty.
[apps/madmutt.git] / complete.c
index 491d897..55df906 100644 (file)
@@ -21,6 +21,7 @@
 #endif
 
 #include <lib-lib/str.h>
+#include <lib-lib/file.h>
 #include "lib/debug.h"
 
 #include <dirent.h>
@@ -104,7 +105,7 @@ int mutt_complete (char *s, size_t slen)
   /* we can use '/' as a delimiter, imap_complete rewrites it */
   if (*s == '=' || *s == '+' || *s == '!') {
       const char *q = NONULL(*s == '!' ? Spoolfile : Maildir);
-      mutt_concat_path (imap_path, q, s + 1, sizeof (imap_path));
+      mutt_concat_path(imap_path, sizeof(imap_path), q, s + 1);
   }
   else
     strfcpy (imap_path, s, sizeof (imap_path));
@@ -124,7 +125,7 @@ int mutt_complete (char *s, size_t slen)
       char buf[_POSIX_PATH_MAX];
 
       *p++ = 0;
-      mutt_concat_path (buf, exp_dirpart, s + 1, sizeof (buf));
+      mutt_concat_path(buf, sizeof(buf), exp_dirpart, s + 1);
       strfcpy (exp_dirpart, buf, sizeof (exp_dirpart));
       snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1);
       strfcpy (dirpart, buf, sizeof (dirpart));
@@ -146,7 +147,7 @@ int mutt_complete (char *s, size_t slen)
       else {
         *p = 0;
         len = (size_t) (p - s);
-        strncpy (dirpart, s, len);
+        memcpy(dirpart, s, len);
         dirpart[len] = 0;
         p++;
         strfcpy (filepart, p, sizeof (filepart));