exit strfcpy, only use m_strcpy.
[apps/madmutt.git] / browser.c
index 53bab1a..c46c89e 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -96,7 +96,7 @@ static int browser_compare_subject (const void *a, const void *b)
   struct folder_file *pa = (struct folder_file *) a;
   struct folder_file *pb = (struct folder_file *) b;
 
-  int r = str_coll (pa->name, pb->name);
+  int r = strcoll(NONULL(pa->name), NONULL(pb->name));
 
   return ((BrowserSort & SORT_REVERSE) ? -r : r);
 }
@@ -535,7 +535,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state,
         continue;               /* we don't need . */
 
       if (prefix && *prefix
-          && str_ncmp (prefix, de->d_name, m_strlen(prefix)) != 0)
+          && m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0)
         continue;
       if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
         continue;
@@ -623,7 +623,7 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state)
           (!S_ISLNK (s.st_mode)))
         continue;
 
-      strfcpy (buffer, NONULL (tmp->path), sizeof (buffer));
+      m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path));
       mutt_pretty_mailbox (buffer);
 
       add_folder (menu, state, buffer, &s, NULL, tmp->new);
@@ -688,9 +688,9 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu,
   else
 #endif
   if (buffy)
-    snprintf (title, titlelen, _("Mailboxes [%d]"), buffy_check (0));
+    snprintf(title, titlelen, _("Mailboxes [%d]"), buffy_check(0));
   else {
-    strfcpy (path, LastDir, sizeof (path));
+    m_strcpy(path, sizeof(path), LastDir);
     mutt_pretty_mailbox (path);
 #ifdef USE_IMAP
     if (state->imap_browse && option (OPTIMAPLSUB))
@@ -742,12 +742,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
   p_clear(&state, 1);
 
   if (!folder)
-    strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
+    m_strcpy(LastDirBackup, sizeof(LastDirBackup), LastDir);
 
 #ifdef USE_NNTP
   if (option (OPTNEWS)) {
     if (*f)
-      strfcpy (prefix, f, sizeof (prefix));
+      m_strcpy(prefix, sizeof(prefix), f);
     else {
       LIST *list;
 
@@ -772,7 +772,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       init_state (&state, NULL);
       state.imap_browse = 1;
       if (!imap_browse (f, &state))
-        strfcpy (LastDir, state.folder, sizeof (LastDir));
+        m_strcpy(LastDir, sizeof(LastDir), state.folder);
     }
     else {
 #endif
@@ -783,9 +783,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           m_strcpy(LastDir, sizeof(LastDir), f);
         }
         else {
-          getcwd (LastDir, sizeof (LastDir));
-          str_cat (LastDir, sizeof (LastDir), "/");
-          str_ncat (LastDir, sizeof (LastDir), f, i);
+          getcwd(LastDir, sizeof(LastDir));
+          m_strcat(LastDir, sizeof(LastDir), "/");
+          m_strncat(LastDir, sizeof(LastDir), f, i);
         }
       }
       else {
@@ -796,9 +796,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       }
 
       if (i <= 0 && f[0] != '/')
-        strfcpy (prefix, f, sizeof (prefix));
+        m_strcpy(prefix, sizeof(prefix), f);
       else
-        strfcpy (prefix, f + i + 1, sizeof (prefix));
+        m_strcpy(prefix, sizeof(prefix), f + i + 1);
       killPrefix = 1;
 #ifdef USE_IMAP
     }
@@ -808,7 +808,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
     if (!folder)
       getcwd (LastDir, sizeof (LastDir));
     else if (!LastDir[0])
-      strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir));
+      m_strcpy(LastDir, sizeof(LastDir), NONULL(Maildir));
 
 #ifdef USE_IMAP
     if (!buffy && imap_is_magic (LastDir, NULL) == M_IMAP) {
@@ -869,12 +869,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         ) {
         /* make sure this isn't a MH or maildir mailbox */
         if (buffy) {
-          strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+          m_strcpy(buf, sizeof(buf), state.entry[menu->current].name);
           mutt_expand_path (buf, sizeof (buf));
         }
 #ifdef USE_IMAP
         else if (state.imap_browse) {
-          strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+          m_strcpy(buf, sizeof(buf), state.entry[menu->current].name);
         }
 #endif
         else
@@ -889,7 +889,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           char OldLastDir[_POSIX_PATH_MAX];
 
           /* save the old directory */
-          strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
+          m_strcpy(OldLastDir, sizeof(OldLastDir), LastDir);
 
           if (m_strcmp(state.entry[menu->current].name, "..") == 0) {
             if (m_strcmp("..", LastDir + m_strlen(LastDir) - 2) == 0)
@@ -908,8 +908,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
             }
           }
           else if (buffy) {
-            strfcpy (LastDir, state.entry[menu->current].name,
-                     sizeof (LastDir));
+            m_strcpy(LastDir, sizeof(LastDir),
+                     state.entry[menu->current].name);
             mutt_expand_path (LastDir, sizeof (LastDir));
           }
 #ifdef USE_IMAP
@@ -917,8 +917,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
             int n;
             ciss_url_t url;
 
-            strfcpy (LastDir, state.entry[menu->current].name,
-                     sizeof (LastDir));
+            m_strcpy(LastDir, sizeof(LastDir),
+                     state.entry[menu->current].name);
             /* tack on delimiter here */
             n = m_strlen(LastDir) + 1;
 
@@ -937,7 +937,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 
             mutt_concat_path(tmp, sizeof(tmp), LastDir,
                              state.entry[menu->current].name);
-            strfcpy (LastDir, tmp, sizeof (LastDir));
+            m_strcpy(LastDir, sizeof(LastDir), tmp);
           }
 
           destroy_state (&state);
@@ -958,9 +958,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 #endif
           if (examine_directory (menu, &state, LastDir, prefix) == -1) {
             /* try to restore the old values */
-            strfcpy (LastDir, OldLastDir, sizeof (LastDir));
+            m_strcpy(LastDir, sizeof(LastDir), OldLastDir);
             if (examine_directory (menu, &state, LastDir, prefix) == -1) {
-              strfcpy (LastDir, NONULL (Homedir), sizeof (LastDir));
+              m_strcpy(LastDir, sizeof(LastDir), NONULL(Homedir));
               goto bail;
             }
           }
@@ -977,12 +977,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       if (buffy)
 #endif
       {
-        strfcpy (f, state.entry[menu->current].name, flen);
+        m_strcpy(f, flen, state.entry[menu->current].name);
         mutt_expand_path (f, flen);
       }
 #ifdef USE_IMAP
       else if (state.imap_browse)
-        strfcpy (f, state.entry[menu->current].name, flen);
+        m_strcpy(f, flen, state.entry[menu->current].name);
 #endif
       else
         mutt_concat_path(f, flen, LastDir, state.entry[menu->current].name);
@@ -1122,7 +1122,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         break;
 #endif
 
-      strfcpy (buf, LastDir, sizeof (buf));
+      m_strcpy(buf, sizeof(buf), LastDir);
 #ifdef USE_IMAP
       if (!state.imap_browse)
 #endif
@@ -1140,7 +1140,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         mutt_expand_path (buf, sizeof (buf));
 #ifdef USE_IMAP
         if (imap_is_magic (buf, NULL) == M_IMAP) {
-          strfcpy (LastDir, buf, sizeof (LastDir));
+          m_strcpy(LastDir, sizeof(LastDir), buf);
           destroy_state (&state);
           init_state (&state, NULL);
           state.imap_browse = 1;
@@ -1157,7 +1157,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           if (S_ISDIR (st.st_mode)) {
             destroy_state (&state);
             if (examine_directory (menu, &state, buf, prefix) == 0)
-              strfcpy (LastDir, buf, sizeof (LastDir));
+              m_strcpy(LastDir, sizeof(LastDir), buf);
             else {
               mutt_error _("Error scanning directory.");
 
@@ -1181,7 +1181,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 
     case OP_ENTER_MASK:
 
-      strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
+      m_strcpy(buf, sizeof(buf), NONULL(Mask.pattern));
       if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
         regex_t *rx = p_new(regex_t, 1);
         char *s = buf;
@@ -1190,7 +1190,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         buffy = 0;
         /* assume that the user wants to see everything */
         if (!buf[0])
-          strfcpy (buf, ".", sizeof (buf));
+          m_strcpy(buf, sizeof(buf), ".");
         SKIPWS (s);
         if (*s == '!') {
           s++;
@@ -1322,7 +1322,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       snprintf (buf, sizeof (buf), "%s/", LastDir);
       if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) ==
           0) {
-        strfcpy (f, buf, flen);
+        m_strcpy(f, flen, buf);
         destroy_state (&state);
         mutt_menuDestroy (&menu);
         goto bail;
@@ -1339,7 +1339,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 
 #ifdef USE_IMAP
       if (state.entry[menu->current].selectable) {
-        strfcpy (f, state.entry[menu->current].name, flen);
+        m_strcpy(f, flen, state.entry[menu->current].name);
         destroy_state (&state);
         mutt_menuDestroy (&menu);
         goto bail;
@@ -1544,6 +1544,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 bail:
 
   if (!folder)
-    strfcpy (LastDir, LastDirBackup, sizeof (LastDir));
+    m_strcpy(LastDir, sizeof(LastDir), LastDirBackup);
 
 }