X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=complete.c;h=679a839bcc6a6a714c5ef9bc8a49c3d9adf6cbc5;hp=c909486b3be5ec53abdebabef2a674280c3acc66;hb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c;hpb=a8477ebaa09990b3688164cbe5cf661c4189541d diff --git a/complete.c b/complete.c index c909486..679a839 100644 --- a/complete.c +++ b/complete.c @@ -20,7 +20,8 @@ #include "nntp.h" #endif -#include "lib/str.h" +#include +#include #include "lib/debug.h" #include @@ -60,7 +61,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 = str_len (filepart)) == 0) { + if ((len = m_strlen(filepart)) == 0) { for (; l; l = l->next) { NNTP_DATA *data = (NNTP_DATA *) l->data; @@ -77,7 +78,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed && - str_ncmp (data->group, filepart, len) == 0) { + m_strncmp(data->group, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && data->group[i]; i++) { if (filepart[i] != data->group[i]) { @@ -103,12 +104,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, sizeof(imap_path), q, s + 1); } else strfcpy (imap_path, s, sizeof (imap_path)); @@ -128,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)); @@ -150,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)); @@ -176,10 +173,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 = str_len (filepart)) == 0) { + if ((len = m_strlen(filepart)) == 0) { while ((de = readdir (dirp)) != NULL) { - if (str_cmp (".", de->d_name) != 0 - && str_cmp ("..", de->d_name) != 0) { + if (m_strcmp(".", de->d_name) != 0 + && m_strcmp("..", de->d_name) != 0) { strfcpy (filepart, de->d_name, sizeof (filepart)); init++; break; @@ -188,7 +185,7 @@ int mutt_complete (char *s, size_t slen) } while ((de = readdir (dirp)) != NULL) { - if (str_ncmp (de->d_name, filepart, len) == 0) { + if (m_strncmp(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]) { @@ -207,14 +204,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 + str_len (buf), "/", sizeof (buf) - str_len (buf)); + strfcpy (buf + m_strlen(buf), "/", sizeof (buf) - m_strlen(buf)); } else buf[0] = 0; - strfcpy (buf + str_len (buf), filepart, sizeof (buf) - str_len (buf)); + strfcpy (buf + m_strlen(buf), filepart, sizeof (buf) - m_strlen(buf)); if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy (filepart + str_len (filepart), "/", - sizeof (filepart) - str_len (filepart)); + strfcpy (filepart + m_strlen(filepart), "/", + sizeof (filepart) - m_strlen(filepart)); init = 1; } } @@ -223,10 +220,10 @@ int mutt_complete (char *s, size_t slen) if (dirpart[0]) { strfcpy (s, dirpart, slen); - if (str_cmp ("/", dirpart) != 0 && dirpart[0] != '=' + if (m_strcmp("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + str_len (s), "/", slen - str_len (s)); - strfcpy (s + str_len (s), filepart, slen - str_len (s)); + strfcpy (s + m_strlen(s), "/", slen - m_strlen(s)); + strfcpy (s + m_strlen(s), filepart, slen - m_strlen(s)); } else strfcpy (s, filepart, slen);