projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use signed size parameter in quote_entry()
[apps/madmutt.git]
/
complete.c
diff --git
a/complete.c
b/complete.c
index
491d897
..
5e66da8
100644
(file)
--- a/
complete.c
+++ b/
complete.c
@@
-12,15
+12,14
@@
#endif
#include "mutt.h"
#endif
#include "mutt.h"
-#ifdef USE_IMAP
#include "mx.h"
#include "mx.h"
-#include "imap.h"
-#endif
+#include <imap/imap.h>
#ifdef USE_NNTP
#include "nntp.h"
#endif
#include <lib-lib/str.h>
#ifdef USE_NNTP
#include "nntp.h"
#endif
#include <lib-lib/str.h>
+#include <lib-lib/file.h>
#include "lib/debug.h"
#include <dirent.h>
#include "lib/debug.h"
#include <dirent.h>
@@
-44,9
+43,7
@@
int mutt_complete (char *s, size_t slen)
char dirpart[_POSIX_PATH_MAX], exp_dirpart[_POSIX_PATH_MAX];
char filepart[_POSIX_PATH_MAX];
char dirpart[_POSIX_PATH_MAX], exp_dirpart[_POSIX_PATH_MAX];
char filepart[_POSIX_PATH_MAX];
-#ifdef USE_IMAP
char imap_path[LONG_STRING];
char imap_path[LONG_STRING];
-#endif
debug_print (2, ("completing %s\n", s));
debug_print (2, ("completing %s\n", s));
@@
-54,7
+51,7
@@
int mutt_complete (char *s, size_t slen)
if (option (OPTNEWS)) {
LIST *l = CurrentNewsSrv->list;
if (option (OPTNEWS)) {
LIST *l = CurrentNewsSrv->list;
-
strfcpy (filepart, s, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), s
);
/*
* special case to handle when there is no filepart yet.
/*
* special case to handle when there is no filepart yet.
@@
-65,7
+62,7
@@
int mutt_complete (char *s, size_t slen)
NNTP_DATA *data = (NNTP_DATA *) l->data;
if (data && data->subscribed) {
NNTP_DATA *data = (NNTP_DATA *) l->data;
if (data && data->subscribed) {
-
strfcpy (filepart, data->group, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), data->group
);
init++;
l = l->next;
break;
init++;
l = l->next;
break;
@@
-77,7
+74,7
@@
int mutt_complete (char *s, size_t slen)
NNTP_DATA *data = (NNTP_DATA *) l->data;
if (data && data->subscribed &&
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]) {
if (init) {
for (i = 0; filepart[i] && data->group[i]; i++) {
if (filepart[i] != data->group[i]) {
@@
-88,7
+85,7
@@
int mutt_complete (char *s, size_t slen)
filepart[i] = 0;
}
else {
filepart[i] = 0;
}
else {
-
strfcpy (filepart, data->group, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), data->group
);
init = 1;
}
}
init = 1;
}
}
@@
-100,57
+97,55
@@
int mutt_complete (char *s, size_t slen)
}
#endif
}
#endif
-#ifdef USE_IMAP
/* we can use '/' as a delimiter, imap_complete rewrites it */
if (*s == '=' || *s == '+' || *s == '!') {
const char *q = NONULL(*s == '!' ? Spoolfile : Maildir);
/* we can use '/' as a delimiter, imap_complete rewrites it */
if (*s == '=' || *s == '+' || *s == '!') {
const char *q = NONULL(*s == '!' ? Spoolfile : Maildir);
- mutt_concat_path
(imap_path, q, s + 1, sizeof (imap_path)
);
+ mutt_concat_path
(imap_path, sizeof(imap_path), q, s + 1
);
}
else
}
else
-
strfcpy (imap_path, s, sizeof (imap_path)
);
+
m_strcpy(imap_path, sizeof(imap_path), s
);
if (mx_get_magic (imap_path) == M_IMAP)
return imap_complete (s, slen, imap_path);
if (mx_get_magic (imap_path) == M_IMAP)
return imap_complete (s, slen, imap_path);
-#endif
if (*s == '=' || *s == '+' || *s == '!') {
dirpart[0] = *s;
dirpart[1] = 0;
if (*s == '!')
if (*s == '=' || *s == '+' || *s == '!') {
dirpart[0] = *s;
dirpart[1] = 0;
if (*s == '!')
-
strfcpy (exp_dirpart, NONULL (Spoolfile), sizeof (exp_dirpart
));
+
m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Spoolfile
));
else
else
-
strfcpy (exp_dirpart, NONULL (Maildir), sizeof (exp_dirpart
));
+
m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Maildir
));
if ((p = strrchr (s, '/'))) {
char buf[_POSIX_PATH_MAX];
*p++ = 0;
if ((p = strrchr (s, '/'))) {
char buf[_POSIX_PATH_MAX];
*p++ = 0;
- mutt_concat_path
(buf, exp_dirpart, s + 1, sizeof (buf)
);
-
strfcpy (exp_dirpart, buf, sizeof (exp_dirpart)
);
+ mutt_concat_path
(buf, sizeof(buf), exp_dirpart, s + 1
);
+
m_strcpy(exp_dirpart, sizeof(exp_dirpart), buf
);
snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1);
snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1);
-
strfcpy (dirpart, buf, sizeof (dirpart)
);
-
strfcpy (filepart, p, sizeof (filepart)
);
+
m_strcpy(dirpart, sizeof(dirpart), buf
);
+
m_strcpy(filepart, sizeof(filepart), p
);
}
else
}
else
-
strfcpy (filepart, s + 1, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), s + 1
);
dirp = opendir (exp_dirpart);
}
else {
if ((p = strrchr (s, '/'))) {
if (p == s) { /* absolute path */
p = s + 1;
dirp = opendir (exp_dirpart);
}
else {
if ((p = strrchr (s, '/'))) {
if (p == s) { /* absolute path */
p = s + 1;
-
strfcpy (dirpart, "/", sizeof (dirpart)
);
+
m_strcpy(dirpart, sizeof(dirpart), "/"
);
exp_dirpart[0] = 0;
exp_dirpart[0] = 0;
-
strfcpy (filepart, p, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), p
);
dirp = opendir (dirpart);
}
else {
*p = 0;
len = (size_t) (p - s);
dirp = opendir (dirpart);
}
else {
*p = 0;
len = (size_t) (p - s);
-
strncpy
(dirpart, s, len);
+
memcpy
(dirpart, s, len);
dirpart[len] = 0;
p++;
dirpart[len] = 0;
p++;
-
strfcpy (filepart, p, sizeof (filepart)
);
-
strfcpy (exp_dirpart, dirpart, sizeof (exp_dirpart)
);
+
m_strcpy(filepart, sizeof(filepart), p
);
+
m_strcpy(exp_dirpart, sizeof(exp_dirpart), dirpart
);
mutt_expand_path (exp_dirpart, sizeof (exp_dirpart));
dirp = opendir (exp_dirpart);
}
mutt_expand_path (exp_dirpart, sizeof (exp_dirpart));
dirp = opendir (exp_dirpart);
}
@@
-158,7
+153,7
@@
int mutt_complete (char *s, size_t slen)
else {
/* no directory name, so assume current directory. */
dirpart[0] = 0;
else {
/* no directory name, so assume current directory. */
dirpart[0] = 0;
-
strfcpy (filepart, s, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), s
);
dirp = opendir (".");
}
}
dirp = opendir (".");
}
}
@@
-176,7
+171,7
@@
int mutt_complete (char *s, size_t slen)
while ((de = readdir (dirp)) != NULL) {
if (m_strcmp(".", de->d_name) != 0
&& m_strcmp("..", de->d_name) != 0) {
while ((de = readdir (dirp)) != NULL) {
if (m_strcmp(".", de->d_name) != 0
&& m_strcmp("..", de->d_name) != 0) {
-
strfcpy (filepart, de->d_name, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), de->d_name
);
init++;
break;
}
init++;
break;
}
@@
-184,7
+179,7
@@
int mutt_complete (char *s, size_t slen)
}
while ((de = readdir (dirp)) != NULL) {
}
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]) {
if (init) {
for (i = 0; filepart[i] && de->d_name[i]; i++) {
if (filepart[i] != de->d_name[i]) {
@@
-198,19
+193,19
@@
int mutt_complete (char *s, size_t slen)
char buf[_POSIX_PATH_MAX];
struct stat st;
char buf[_POSIX_PATH_MAX];
struct stat st;
-
strfcpy (filepart, de->d_name, sizeof (filepart)
);
+
m_strcpy(filepart, sizeof(filepart), de->d_name
);
/* check to see if it is a directory */
if (dirpart[0]) {
/* check to see if it is a directory */
if (dirpart[0]) {
-
strfcpy (buf, exp_dirpart, sizeof (buf)
);
-
strfcpy (buf + m_strlen(buf), "/", sizeof (buf) - m_strlen(buf)
);
+
m_strcpy(buf, sizeof(buf), exp_dirpart
);
+
m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), "/"
);
}
else
buf[0] = 0;
}
else
buf[0] = 0;
-
strfcpy (buf + m_strlen(buf), filepart, sizeof (buf) - m_strlen(buf)
);
+
m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), filepart
);
if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
-
strfcpy (filepart + m_strlen(filepart), "/"
,
- sizeof
(filepart) - m_strlen(filepart)
);
+
m_strcpy(filepart + m_strlen(filepart)
,
+ sizeof
(filepart) - m_strlen(filepart), "/"
);
init = 1;
}
}
init = 1;
}
}
@@
-218,14
+213,14
@@
int mutt_complete (char *s, size_t slen)
closedir (dirp);
if (dirpart[0]) {
closedir (dirp);
if (dirpart[0]) {
-
strfcpy (s, dirpart, slen
);
+
m_strcpy(s, slen, dirpart
);
if (m_strcmp("/", dirpart) != 0 && dirpart[0] != '='
&& dirpart[0] != '+')
if (m_strcmp("/", dirpart) != 0 && dirpart[0] != '='
&& dirpart[0] != '+')
-
strfcpy (s + m_strlen(s), "/", slen - m_strlen(s)
);
-
strfcpy (s + m_strlen(s), filepart, slen - m_strlen(s)
);
+
m_strcpy(s + m_strlen(s), slen - m_strlen(s), "/"
);
+
m_strcpy(s + m_strlen(s), slen - m_strlen(s), filepart
);
}
else
}
else
-
strfcpy (s, filepart, slen
);
+
m_strcpy(s, slen, filepart
);
return (init ? 0 : -1);
}
return (init ? 0 : -1);
}