#include "mx.h"
#include "init.h"
-#include "mailbox.h"
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/wait.h>
+/* for synonym warning reports: synonym found during parsing */
+typedef struct {
+ char* f; /* file */
+ int l; /* line */
+ int n; /* new name (index) */
+ int o; /* old name (index) */
+} syn_t;
+
+/* for synonym warning reports: list of synonyms found */
+list2_t* Synonyms;
+/* for synonym warning reports: current rc file */
+char* CurRCFile = NULL;
+/* for synonym warning reports: current rc line */
+int CurRCLine = 0;
+
+/* for synonym warning reports: adds synonym to end of list */
+static void syn_add (int n, int o) {
+ syn_t* tmp = safe_malloc (sizeof (syn_t));
+ tmp->f = safe_strdup (CurRCFile);
+ tmp->l = CurRCLine;
+ tmp->n = n;
+ tmp->o = o;
+ list_push_back (&Synonyms, tmp);
+}
+
+/* for synonym warning reports: free single item (for list_del()) */
+static void syn_del (void** p) {
+ FREE(&(*(syn_t**) p)->f);
+ FREE(p);
+}
+
void toggle_quadoption (int opt)
{
int n = opt / 4;
int i;
for (i = 0; MuttVars[i].option; i++)
- if (safe_strcmp (s, MuttVars[i].option) == 0)
+ if (mutt_strcmp (s, MuttVars[i].option) == 0) {
+ if (MuttVars[i].type == DT_SYN)
+ syn_add (mutt_option_index ((char *) MuttVars[i].data), i);
return (MuttVars[i].type ==
DT_SYN ? mutt_option_index ((char *) MuttVars[i].data) : i);
+ }
return (-1);
}
}
} while (pc && *pc != '`');
if (!pc) {
- dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
+ debug_print (1, ("mismatched backtics\n"));
return (-1);
}
cmd = str_substrdup (tok->dptr, pc);
if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
- dprint (1,
- (debugfile, "mutt_get_token: unable to fork command: %s",
- cmd));
+ debug_print (1, ("unable to fork command: %s\n", cmd));
FREE (&cmd);
return (-1);
}
FREE (&expn.data);
}
else if (expn.data) {
- expnlen = safe_strlen (expn.data);
- tok->dsize = expnlen + safe_strlen (tok->dptr) + 1;
+ expnlen = mutt_strlen (expn.data);
+ tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
ptr = safe_malloc (tok->dsize);
memcpy (ptr, expn.data, expnlen);
strcpy (ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */
/* Being first is a special case. */
spam = *list;
- if (spam->rx && !safe_strcmp (spam->rx->pattern, pat)) {
+ if (spam->rx && !mutt_strcmp (spam->rx->pattern, pat)) {
*list = spam->next;
rx_free (&spam->rx);
FREE(&spam->template);
prev = spam;
for (spam = prev->next; spam;) {
- if (!safe_strcmp (spam->rx->pattern, pat)) {
+ if (!mutt_strcmp (spam->rx->pattern, pat)) {
prev->next = spam->next;
rx_free (&spam->rx);
FREE(spam->template);
{
LIST *p, *last = NULL;
- if (safe_strcmp ("*", str) == 0)
+ if (mutt_strcmp ("*", str) == 0)
mutt_free_list (l); /* ``unCMD *'' means delete all current entries */
else {
p = *l;
{
int i = 0;
- if (safe_strcmp ("*", str) == 0) {
+ if (mutt_strcmp ("*", str) == 0) {
list_del (l, rx_free);
return (0);
}
continue;
for (j = 0; b[j].name; j++)
- if (!ascii_strncasecmp (tmp->data, b[j].name, safe_strlen (tmp->data))
- && (safe_strlen (b[j].name) == safe_strlen (tmp->data))) {
+ if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
+ && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data))) {
res = 1;
break;
}
char *p = NULL;
i = 0;
- j = safe_strlen (tmp->data);
+ j = mutt_strlen (tmp->data);
/* need at least input of 'feature_X' */
if (j >= 7) {
p = tmp->data + 7;
j -= 7;
while (Features[i].name) {
- if (safe_strlen (Features[i].name) == j &&
+ if (mutt_strlen (Features[i].name) == j &&
ascii_strncasecmp (Features[i].name, p, j)) {
res = 1;
break;
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&Alternates, buf->data);
- if (safe_strcmp (buf->data, "*") &&
+ if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
return -1;
/* nospam only ever has one parameter. */
/* "*" is a special case. */
- if (!safe_strcmp (buf->data, "*")) {
+ if (!mutt_strcmp (buf->data, "*")) {
mutt_free_spam_list (&SpamList);
list_del (&NoSpamList, rx_free);
return 0;
/*
* Check for deletion of entire list
*/
- if (safe_strcmp (buf->data, "*") == 0) {
+ if (mutt_strcmp (buf->data, "*") == 0) {
mutt_free_list ((LIST **) data);
break;
}
remove_from_rx_list (&SubscribedLists, buf->data);
remove_from_rx_list (&MailLists, buf->data);
- if (safe_strcmp (buf->data, "*") &&
+ if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&SubscribedLists, buf->data);
- if (safe_strcmp (buf->data, "*") &&
+ if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
do {
mutt_extract_token (buf, s, 0);
- if (safe_strcmp ("*", buf->data) == 0) {
+ if (mutt_strcmp ("*", buf->data) == 0) {
if (CurrentMenu == MENU_ALIAS) {
for (tmp = Aliases; tmp; tmp = tmp->next)
tmp->del = 1;
mutt_extract_token (buf, s, 0);
- dprint (2, (debugfile, "parse_alias: First token is '%s'.\n", buf->data));
+ debug_print (2, ("first token is '%s'.\n", buf->data));
/* check to see if an alias with this name already exists */
for (; tmp; tmp = tmp->next) {
mutt_extract_token (buf, s,
M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
- dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n", buf->data));
+ debug_print (2, ("second token is '%s'.\n", buf->data));
tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data);
if (last)
last->next = tmp;
return -1;
}
#ifdef DEBUG
- if (debuglevel >= 2) {
+ if (DebugLevel >= 2) {
ADDRESS *a;
for (a = tmp->addr; a; a = a->next) {
if (!a->group)
- dprint (2, (debugfile, "parse_alias: %s\n", a->mailbox));
+ debug_print (2, ("%s\n", a->mailbox));
else
- dprint (2, (debugfile, "parse_alias: Group %s\n", a->mailbox));
+ debug_print (2, ("group %s\n", a->mailbox));
}
}
#endif
do {
mutt_extract_token (buf, s, 0);
- if (safe_strcmp ("*", buf->data) == 0)
+ if (mutt_strcmp ("*", buf->data) == 0)
mutt_free_list (&UserHeader);
else {
tmp = UserHeader;
last = NULL;
- l = safe_strlen (buf->data);
+ l = mutt_strlen (buf->data);
if (buf->data[l - 1] == ':')
l--;
char *s = (char *) p->init;
pp->rx = safe_calloc (1, sizeof (regex_t));
- if (safe_strcmp (p->option, "mask") != 0)
+ if (mutt_strcmp (p->option, "mask") != 0)
flags |= mutt_which_case ((const char *) p->init);
- if (safe_strcmp (p->option, "mask") == 0 && *s == '!') {
+ if (mutt_strcmp (p->option, "mask") == 0 && *s == '!') {
s++;
pp->not = 1;
}
mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
if ((idx = mutt_option_index (tmp->data)) == -1 &&
- !(reset && !safe_strcmp ("all", tmp->data))) {
+ !(reset && !mutt_strcmp ("all", tmp->data))) {
snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data);
return (-1);
}
return (-1);
}
- if (!safe_strcmp ("all", tmp->data)) {
+ if (!mutt_strcmp ("all", tmp->data)) {
for (idx = 0; MuttVars[idx].option; idx++)
mutt_restore_default (&MuttVars[idx]);
return 0;
}
else if (DTYPE (MuttVars[idx].type) == DT_STR) {
*((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
- if (safe_strcmp (MuttVars[idx].option, "charset") == 0)
+ if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
mutt_set_charset (Charset);
}
else {
}
if (option (OPTATTACHMSG)
- && !safe_strcmp (MuttVars[idx].option, "reply_regexp")) {
+ && !mutt_strcmp (MuttVars[idx].option, "reply_regexp")) {
snprintf (err->data, err->dsize,
"Operation not permitted when in attach-message mode.");
r = -1;
/* copy the value of the string */
mutt_extract_token (tmp, s, 0);
- if (!ptr->pattern || safe_strcmp (ptr->pattern, tmp->data) != 0) {
+ if (!ptr->pattern || mutt_strcmp (ptr->pattern, tmp->data) != 0) {
int not = 0;
/* $mask is case-sensitive */
- if (safe_strcmp (MuttVars[idx].option, "mask") != 0)
+ if (mutt_strcmp (MuttVars[idx].option, "mask") != 0)
flags |= mutt_which_case (tmp->data);
p = tmp->data;
- if (safe_strcmp (MuttVars[idx].option, "mask") == 0) {
+ if (mutt_strcmp (MuttVars[idx].option, "mask") == 0) {
if (*p == '!') {
not = 1;
p++;
/* $reply_regexp and $alterantes require special treatment */
if (Context && Context->msgcount &&
- safe_strcmp (MuttVars[idx].option, "reply_regexp") == 0) {
+ mutt_strcmp (MuttVars[idx].option, "reply_regexp") == 0) {
regmatch_t pmatch[1];
int i;
*ptr = (short) val;
/* these ones need a sanity check */
- if (safe_strcmp (MuttVars[idx].option, "history") == 0) {
+ if (mutt_strcmp (MuttVars[idx].option, "history") == 0) {
if (*ptr < 0)
*ptr = 0;
mutt_init_history ();
}
- else if (safe_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) {
+ else if (mutt_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) {
if (*ptr < 0)
*ptr = 0;
}
size_t buflen;
pid_t pid;
- dprint (2, (debugfile, "Reading configuration file '%s'.\n", rcfile));
+ debug_print (2, ("reading configuration file '%s'.\n", rcfile));
+ str_replace (&CurRCFile, rcfile);
+ CurRCLine = 0;
if ((f = mutt_open_read (rcfile, &pid)) == NULL) {
snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno));
memset (&token, 0, sizeof (token));
while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL) {
+ CurRCLine++;
conv = ConfigCharset && (*ConfigCharset) && Charset;
if (conv) {
currentline = safe_strdup (linebuf);
memset (&expn, 0, sizeof (expn));
expn.data = expn.dptr = line;
- expn.dsize = safe_strlen (line);
+ expn.dsize = mutt_strlen (line);
*err->data = 0;
}
mutt_extract_token (token, &expn, 0);
for (i = 0; Commands[i].name; i++) {
- if (!safe_strcmp (token->data, Commands[i].name)) {
+ if (!mutt_strcmp (token->data, Commands[i].name)) {
if (Commands[i].func (token, &expn, Commands[i].data, err) != 0)
goto finish;
break;
/* loop through all the possible prefixes (no, inv, ...) */
if (!safe_strncmp (buffer, "set", 3)) {
for (num = 0; prefixes[num]; num++) {
- if (!safe_strncmp (pt, prefixes[num], safe_strlen (prefixes[num]))) {
- pt += safe_strlen (prefixes[num]);
+ if (!safe_strncmp (pt, prefixes[num], mutt_strlen (prefixes[num]))) {
+ pt += mutt_strlen (prefixes[num]);
break;
}
}
strfcpy (var, pt, sizeof (var));
/* ignore the trailing '=' when comparing */
- var[safe_strlen (var) - 1] = 0;
+ var[mutt_strlen (var) - 1] = 0;
if ((idx = mutt_option_index (var)) == -1)
return 0; /* no such variable. */
else {
return (-1);
}
-#ifdef DEBUG
-static void start_debug (void)
-{
- time_t t;
- int i;
- char buf[_POSIX_PATH_MAX];
- char buf2[_POSIX_PATH_MAX];
-
- /* rotate the old debug logs */
- for (i = 3; i >= 0; i--) {
- snprintf (buf, sizeof (buf), "%s/.muttdebug%d", NONULL (Homedir), i);
- snprintf (buf2, sizeof (buf2), "%s/.muttdebug%d", NONULL (Homedir),
- i + 1);
- rename (buf, buf2);
- }
- if ((debugfile = safe_fopen (buf, "w")) != NULL) {
- t = time (0);
- setbuf (debugfile, NULL); /* don't buffer the debugging output! */
- fprintf (debugfile,
- "Mutt-ng %s started at %s.\nDebugging at level %d.\n\n",
- MUTT_VERSION, asctime (localtime (&t)), debuglevel);
- }
-}
-#endif
-
static int mutt_execute_commands (LIST * p)
{
BUFFER err, token;
Shell = safe_strdup ((p = getenv ("SHELL")) ? p : "/bin/sh");
}
-#ifdef DEBUG
- /* Start up debugging mode if requested */
- if (debuglevel > 0)
- start_debug ();
-#endif
+ debug_start(Homedir);
/* And about the host... */
uname (&utsname);
else
#endif /* DOMAIN */
if (*DOMAIN != '@') {
- Fqdn = safe_malloc (safe_strlen (DOMAIN) + safe_strlen (Hostname) + 2);
+ Fqdn = safe_malloc (mutt_strlen (DOMAIN) + mutt_strlen (Hostname) + 2);
sprintf (Fqdn, "%s.%s", NONULL (Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
}
else
memset (&buf, 0, sizeof (buf));
buf.data = buf.dptr = buffer;
- buf.dsize = safe_strlen (buffer);
+ buf.dsize = mutt_strlen (buffer);
memset (&token, 0, sizeof (token));
parse_my_hdr (&token, &buf, 0, &err);
if (mutt_execute_commands (commands) != 0)
need_pause = 1;
+ /* warn about synonym variables */
+ if (!list_empty(Synonyms)) {
+ int i = 0;
+ fprintf (stderr, _("Warning: the following synonym variables were found:\n"));
+ for (i = 0; i < Synonyms->length; i++)
+ fprintf (stderr, "$%s ($%s should be used) (%s:%d)\n",
+ MuttVars[((syn_t*) Synonyms->data[i])->o].option,
+ MuttVars[((syn_t*) Synonyms->data[i])->n].option,
+ NONULL(((syn_t*) Synonyms->data[i])->f),
+ ((syn_t*) Synonyms->data[i])->l);
+ fprintf (stderr, _("Warning: Synonym variables are scheduled for removal.\n"));
+ list_del (&Synonyms, syn_del);
+ need_pause = 1;
+ }
+ /* this is not needed during runtime */
+ FREE(&CurRCFile);
+
if (need_pause && !option (OPTNOCURSES)) {
if (mutt_any_key_to_continue (NULL) == -1)
mutt_exit (1);