X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=complete.c;h=f451e1a0fea0abd246fbebd6f234d2b426f305b8;hp=b0c96cfa68e383ca1cf7e50603fd18b49f999043;hb=c25bc063f35aaad6938c2022dae7a283346c2769;hpb=25bf57d598476b329536fa3f748cc0c529fef6bd diff --git a/complete.c b/complete.c index b0c96cf..f451e1a 100644 --- a/complete.c +++ b/complete.c @@ -21,6 +21,7 @@ #endif #include "lib/str.h" +#include "lib/debug.h" #include #include @@ -47,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)) { @@ -59,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 = safe_strlen (filepart)) == 0) { + if ((len = str_len (filepart)) == 0) { for (; l; l = l->next) { NNTP_DATA *data = (NNTP_DATA *) l->data; @@ -76,7 +77,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed && - safe_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]) { @@ -102,12 +103,8 @@ 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)); @@ -167,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); } @@ -177,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 = safe_strlen (filepart)) == 0) { + if ((len = str_len (filepart)) == 0) { while ((de = readdir (dirp)) != NULL) { - if (safe_strcmp (".", de->d_name) != 0 - && safe_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; @@ -189,7 +184,7 @@ int mutt_complete (char *s, size_t slen) } while ((de = readdir (dirp)) != NULL) { - if (safe_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]) { @@ -208,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 + safe_strlen (buf), "/", sizeof (buf) - safe_strlen (buf)); + strfcpy (buf + str_len (buf), "/", sizeof (buf) - str_len (buf)); } else buf[0] = 0; - strfcpy (buf + safe_strlen (buf), filepart, sizeof (buf) - safe_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 + safe_strlen (filepart), "/", - sizeof (filepart) - safe_strlen (filepart)); + strfcpy (filepart + str_len (filepart), "/", + sizeof (filepart) - str_len (filepart)); init = 1; } } @@ -224,10 +219,10 @@ int mutt_complete (char *s, size_t slen) if (dirpart[0]) { strfcpy (s, dirpart, slen); - if (safe_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' + if (str_cmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + safe_strlen (s), "/", slen - safe_strlen (s)); - strfcpy (s + safe_strlen (s), filepart, slen - safe_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);