make code a bit more readable.
[apps/madmutt.git] / browser.c
index 763a5be..d91d0ef 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -15,6 +15,7 @@
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
@@ -22,7 +23,6 @@
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "buffy.h"
-#include "mapping.h"
 #include "sort.h"
 #include "browser.h"
 #include "attach.h"
@@ -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
@@ -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,11 +1190,10 @@ 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));
-        SKIPWS (s);
+          m_strcpy(buf, sizeof(buf), ".");
+        s = vskipspaces(s);
         if (*s == '!') {
-          s++;
-          SKIPWS (s);
+          s = vskipspaces(s + 1);
           not = 1;
         }
 
@@ -1205,7 +1204,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           mutt_error ("%s", buf);
         }
         else {
-          str_replace (&Mask.pattern, buf);
+          m_strreplace(&Mask.pattern, buf);
           regfree (Mask.rx);
           p_delete(&Mask.rx);
           Mask.rx = rx;
@@ -1322,7 +1321,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 +1338,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 +1543,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);
 
 }