X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=complete.c;h=f451e1a0fea0abd246fbebd6f234d2b426f305b8;hp=8ff2dcece655e2201a2ab7aa9b14fdd303636f71;hb=ef7b80006ebb47372d69c64e8b2b2f0764333d55;hpb=c3e57678c8be193fc137854020f3a90887be97c9 diff --git a/complete.c b/complete.c index 8ff2dce..f451e1a 100644 --- a/complete.c +++ b/complete.c @@ -13,13 +13,16 @@ #include "mutt.h" #ifdef USE_IMAP -#include "mailbox.h" +#include "mx.h" #include "imap.h" #endif #ifdef USE_NNTP #include "nntp.h" #endif +#include "lib/str.h" +#include "lib/debug.h" + #include #include #include @@ -45,7 +48,7 @@ int mutt_complete (char *s, size_t slen) char imap_path[LONG_STRING]; #endif - dprint (2, (debugfile, "mutt_complete: completing %s\n", s)); + debug_print (2, ("completing %s\n", s)); #ifdef USE_NNTP if (option (OPTNEWS)) { @@ -57,7 +60,7 @@ int mutt_complete (char *s, size_t slen) * special case to handle when there is no filepart yet. * find the first subscribed newsgroup */ - if ((len = mutt_strlen (filepart)) == 0) { + if ((len = str_len (filepart)) == 0) { for (; l; l = l->next) { NNTP_DATA *data = (NNTP_DATA *) l->data; @@ -74,7 +77,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed && - mutt_strncmp (data->group, filepart, len) == 0) { + str_ncmp (data->group, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && data->group[i]; i++) { if (filepart[i] != data->group[i]) { @@ -100,17 +103,13 @@ int mutt_complete (char *s, size_t slen) #ifdef USE_IMAP /* we can use '/' as a delimiter, imap_complete rewrites it */ if (*s == '=' || *s == '+' || *s == '!') { - if (*s == '!') - p = NONULL (Spoolfile); - else - p = NONULL (Maildir); - - mutt_concat_path (imap_path, p, s + 1, sizeof (imap_path)); + const char *q = NONULL(*s == '!' ? Spoolfile : Maildir); + mutt_concat_path (imap_path, q, s + 1, sizeof (imap_path)); } else strfcpy (imap_path, s, sizeof (imap_path)); - if (mx_is_imap (imap_path)) + if (mx_get_magic (imap_path) == M_IMAP) return imap_complete (s, slen, imap_path); #endif @@ -165,9 +164,7 @@ int mutt_complete (char *s, size_t slen) } if (dirp == NULL) { - dprint (1, - (debugfile, "mutt_complete(): %s: %s (errno %d).\n", exp_dirpart, - strerror (errno), errno)); + debug_print (1, ("%s: %s (errno %d).\n", exp_dirpart, strerror (errno), errno)); return (-1); } @@ -175,10 +172,10 @@ int mutt_complete (char *s, size_t slen) * special case to handle when there is no filepart yet. find the first * file/directory which is not ``.'' or ``..'' */ - if ((len = mutt_strlen (filepart)) == 0) { + if ((len = str_len (filepart)) == 0) { while ((de = readdir (dirp)) != NULL) { - if (mutt_strcmp (".", de->d_name) != 0 - && mutt_strcmp ("..", de->d_name) != 0) { + if (str_cmp (".", de->d_name) != 0 + && str_cmp ("..", de->d_name) != 0) { strfcpy (filepart, de->d_name, sizeof (filepart)); init++; break; @@ -187,7 +184,7 @@ int mutt_complete (char *s, size_t slen) } while ((de = readdir (dirp)) != NULL) { - if (mutt_strncmp (de->d_name, filepart, len) == 0) { + if (str_ncmp (de->d_name, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && de->d_name[i]; i++) { if (filepart[i] != de->d_name[i]) { @@ -206,14 +203,14 @@ int mutt_complete (char *s, size_t slen) /* check to see if it is a directory */ if (dirpart[0]) { strfcpy (buf, exp_dirpart, sizeof (buf)); - strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf)); + strfcpy (buf + str_len (buf), "/", sizeof (buf) - str_len (buf)); } else buf[0] = 0; - strfcpy (buf + strlen (buf), filepart, sizeof (buf) - strlen (buf)); + strfcpy (buf + str_len (buf), filepart, sizeof (buf) - str_len (buf)); if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy (filepart + strlen (filepart), "/", - sizeof (filepart) - strlen (filepart)); + strfcpy (filepart + str_len (filepart), "/", + sizeof (filepart) - str_len (filepart)); init = 1; } } @@ -222,10 +219,10 @@ int mutt_complete (char *s, size_t slen) if (dirpart[0]) { strfcpy (s, dirpart, slen); - if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' + if (str_cmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + strlen (s), "/", slen - strlen (s)); - strfcpy (s + strlen (s), filepart, slen - strlen (s)); + strfcpy (s + str_len (s), "/", slen - str_len (s)); + strfcpy (s + str_len (s), filepart, slen - str_len (s)); } else strfcpy (s, filepart, slen);