2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
23 #include <sys/types.h>
29 #include <lib-lib/lib-lib.h>
31 #include <lib-mime/mime.h>
33 #include <lib-ui/curses.h>
34 #include <lib-ui/enter.h>
43 #include <imap/imap.h>
44 #include <imap/mx_imap.h>
46 #include <lib-crypt/crypt.h>
48 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
50 /* Modified by blong to accept a "suggestion" for file name. If
51 * that file exists, then construct one with unique name but
52 * keep any extension. This might fail, I guess.
53 * Renamed to mutt_adv_mktemp so I only have to change where it's
54 * called, and not all possible cases.
56 void mutt_adv_mktemp (const char* dir, char *s, ssize_t l)
58 char buf[_POSIX_PATH_MAX];
59 char tmp[_POSIX_PATH_MAX];
64 m_strcpy(buf, sizeof(buf), m_strisempty(dir) ? NONULL(Tempdir) : dir);
65 mutt_expand_path (buf, sizeof (buf));
67 snprintf (s, l, "%s/muttXXXXXX", buf);
71 m_strcpy(tmp, sizeof(tmp), s);
72 mutt_sanitize_filename (tmp, 1);
73 snprintf (s, l, "%s/%s", buf, tmp);
74 if (lstat (s, &sb) == -1 && errno == ENOENT)
76 if ((period = strrchr (tmp, '.')) != NULL)
78 snprintf (s, l, "%s/%s.XXXXXX", buf, tmp);
83 m_strcpy(s + sl, l - sl, period);
88 /* create a send-mode duplicate from a receive-mode body */
90 int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
92 char tmp[_POSIX_PATH_MAX];
95 parameter_t *par, **ppar;
101 m_strcpy(tmp, sizeof(tmp), src->filename);
108 mutt_adv_mktemp (NULL, tmp, sizeof (tmp));
109 if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
115 memcpy (b, src, sizeof (BODY));
119 b->filename = m_strdup(tmp);
120 b->use_disp = use_disp;
123 if (mutt_is_text_part (b))
126 b->xtype = m_strdup(b->xtype);
127 b->subtype = m_strdup(b->subtype);
128 b->form_name = m_strdup(b->form_name);
129 b->filename = m_strdup(b->filename);
130 b->d_filename = m_strdup(b->d_filename);
131 b->description = m_strdup(b->description);
134 * we don't seem to need the HEADER structure currently.
135 * XXX - this may change in the future
141 /* copy parameters */
142 for (par = b->parameter, ppar = &b->parameter; par;
143 ppar = &(*ppar)->next, par = par->next) {
144 *ppar = parameter_new();
145 (*ppar)->attribute = m_strdup(par->attribute);
146 (*ppar)->value = m_strdup(par->value);
149 mutt_stamp_attachment (b);
154 /* returns true if the header contained in "s" is in list "t" */
155 int mutt_matches_ignore (const char *s, string_list_t * t)
157 for (; t; t = t->next) {
158 if (!ascii_strncasecmp (s, t->data, m_strlen(t->data))
165 /* prepend the path part of *path to *lnk */
166 void mutt_expand_link (char *newpath, const char *path, const char *lnk)
168 const char *lb = NULL;
171 /* lnk is full path */
173 m_strcpy(newpath, _POSIX_PATH_MAX, lnk);
177 if ((lb = strrchr (path, '/')) == NULL) {
179 m_strcpy(newpath, _POSIX_PATH_MAX, lnk);
184 memcpy (newpath, path, len);
185 m_strcpy(newpath + len, _POSIX_PATH_MAX - len, lnk);
188 char *mutt_expand_path (char *s, ssize_t slen)
190 return _mutt_expand_path (s, slen, 0);
193 char *_mutt_expand_path (char *s, ssize_t slen, int rx)
195 char p[_POSIX_PATH_MAX] = "";
196 char q[_POSIX_PATH_MAX] = "";
197 char tmp[_POSIX_PATH_MAX];
200 const char *tail = "";
210 if (*(s + 1) == '/' || *(s + 1) == 0) {
211 m_strcpy(p, sizeof(p), NONULL(Homedir));
217 if ((t = strchr (s + 1, '/')))
220 if ((pw = getpwnam (s + 1))) {
221 m_strcpy(p, sizeof(p), pw->pw_dir);
230 /* user not found! */
243 /* if folder = imap[s]://host/: don't append slash */
244 if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
245 Maildir[m_strlen(Maildir) - 1] == '/')
246 m_strcpy(p, sizeof(p), NONULL(Maildir));
248 snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
254 /* elm compatibility, @ expands alias to user name */
262 if ((alias = alias_lookup(s + 1))) {
264 h->env = envelope_new();
265 h->env->from = h->env->to = alias;
266 mutt_default_save (p, sizeof (p), h);
267 h->env->from = h->env->to = NULL;
269 /* Avoid infinite recursion if the resulting folder starts with '@' */
280 m_strcpy(p, sizeof(p), NONULL(Inbox));
287 m_strcpy(p, sizeof(p), NONULL(Outbox));
294 if (*(s + 1) == '!') {
295 m_strcpy(p, sizeof(p), NONULL(LastFolder));
299 m_strcpy(p, sizeof(p), NONULL(Spoolfile));
307 m_strcpy(p, sizeof(p), NONULL(LastFolder));
314 m_strcpy(p, sizeof(p), NONULL(CurrentFolder));
326 if (rx && *p && !recurse) {
327 rx_sanitize_string (q, sizeof (q), p);
328 snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
331 snprintf (tmp, sizeof (tmp), "%s%s", p, tail);
333 m_strcpy(s, slen, tmp);
340 /* move all the headers from extra not present in base into base */
341 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
343 /* copies each existing element if necessary, and sets the element
344 * to NULL in the source so that envelope_delete doesn't leave us
345 * with dangling pointers. */
346 #define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; }
347 MOVE_ELEM(return_path);
354 MOVE_ELEM(mail_followup_to);
355 MOVE_ELEM(list_post);
356 MOVE_ELEM(message_id);
357 MOVE_ELEM(supersedes);
360 if (!base->refs_changed) {
361 MOVE_ELEM(references);
363 if (!base->irt_changed) {
364 MOVE_ELEM(in_reply_to);
366 /* real_subj is subordinate to subject */
367 if (!base->subject) {
368 base->subject = (*extra)->subject;
369 base->real_subj = (*extra)->real_subj;
370 (*extra)->subject = NULL;
371 (*extra)->real_subj = NULL;
373 /* spam and user headers should never be hashed, and the new envelope may
374 * have better values. Use new versions regardless. */
375 mutt_buffer_free (&base->spam);
376 string_list_wipe(&base->userhdrs);
381 envelope_delete(extra);
384 void _mutt_mktemp (char *s, const char *src, int line)
387 snprintf (s, _POSIX_PATH_MAX, "%s/madmutt-%s-%d-%d-%d-%x%x", NONULL (Tempdir),
388 NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++,
389 (unsigned int) rand(), (unsigned int) rand());
393 /* collapse the pathname using ~ or = when possible */
394 void mutt_pretty_mailbox (char *s)
400 scheme = url_check_scheme (s);
402 if (scheme == U_IMAP || scheme == U_IMAPS) {
403 imap_pretty_mailbox (s);
407 /* if s is an url, only collapse path component */
408 if (scheme != U_UNKNOWN) {
409 p = strchr (s, ':') + 1;
410 if (!strncmp (p, "//", 2))
411 q = strchr (p + 2, '/');
413 q = strchr (p, '\0');
417 /* first attempt to collapse the pathname */
419 if (*p == '/' && p[1] == '/') {
423 else if (p[0] == '/' && p[1] == '.' && p[2] == '/') {
432 if (m_strncmp(s, Maildir, (len = m_strlen(Maildir))) == 0 &&
435 memmove (s, s + len, m_strlen(s + len) + 1);
437 else if (m_strncmp(s, Homedir, (len = m_strlen(Homedir))) == 0 &&
440 memmove (s, s + len - 1, m_strlen(s + len - 1) + 1);
444 void mutt_pretty_size (char *s, ssize_t len, long n)
447 m_strcpy(s, len, "0K");
448 else if (n < 10189) /* 0.1K - 9.9K */
449 snprintf (s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0);
450 else if (n < 1023949) { /* 10K - 999K */
451 /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
452 snprintf (s, len, "%ldK", (n + 51) / 1024);
454 else if (n < 10433332) /* 1.0M - 9.9M */
455 snprintf (s, len, "%3.1fM", n / 1048576.0);
458 /* (10433332 + 52428) / 1048576 = 10 */
459 snprintf (s, len, "%ldM", (n + 52428) / 1048576);
463 void mutt_expand_file_fmt(char *dest, ssize_t destlen,
464 const char *fmt, const char *src)
466 char tmp[LONG_STRING];
468 mutt_quote_filename(tmp, sizeof(tmp), src);
469 mutt_expand_fmt(dest, destlen, fmt, tmp);
472 void mutt_expand_fmt(char *dst, ssize_t dlen,
473 const char *fmt, const char *src)
478 while (*fmt && pos < dlen - 1) {
483 pos += m_strcpy(dst + pos, dlen - pos, src);
501 pos += m_strcpy(dst + pos, dlen - pos, " ");
502 pos += m_strcpy(dst + pos, dlen - pos, src);
506 /* return 0 on success, -1 on abort, 1 on error */
507 int mutt_check_overwrite (const char *attname, const char *path,
508 char *fname, ssize_t flen, int *append,
512 char tmp[_POSIX_PATH_MAX];
515 m_strcpy(fname, flen, path);
516 if (access (fname, F_OK) != 0)
518 if (stat (fname, &st) != 0)
520 if (S_ISDIR (st.st_mode)) {
522 switch (mutt_multi_choice
523 (_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"),
526 m_strreplace(directory, fname);
541 mutt_yesorno (_("File is a directory, save under it?"),
543 return (rc == M_NO) ? 1 : -1;
545 if (!attname || !attname[0]) {
547 if (mutt_get_field (_("File under directory: "), tmp, sizeof (tmp),
548 M_FILE | M_CLEAR) != 0 || !tmp[0])
550 mutt_concat_path(fname, flen, path, tmp);
553 mutt_concat_path(fname, flen, path, mutt_basename(attname));
556 if (*append == 0 && access (fname, F_OK) == 0) {
557 switch (mutt_multi_choice
558 (_("File exists, (o)verwrite, (a)ppend, or (c)ancel?"), _("oac")))
566 *append = M_SAVE_APPEND;
568 case 1: /* overwrite */
569 *append = M_SAVE_OVERWRITE;
576 void mutt_save_path(char *d, ssize_t dsize, address_t *a)
578 if (a && a->mailbox) {
579 m_strcpy(d, dsize, a->mailbox);
581 if (!option(OPTSAVEADDRESS)) {
582 char *p = strpbrk(d, "%@");
592 void mutt_safe_path(char *s, ssize_t l, address_t *a)
594 mutt_save_path(s, l, a);
597 if (*s == '/' || ISSPACE(*s) || !isprint((unsigned char)*s))
603 void mutt_FormatString (char *dest, /* output buffer */
604 ssize_t destlen, /* output buffer len */
605 const char *src, /* template string */
606 format_t * callback, /* callback for processing */
607 unsigned long data, /* callback data */
609 { /* callback flags */
610 char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch;
611 char ifstring[SHORT_STRING], elsestring[SHORT_STRING];
612 ssize_t wlen, wid, count, col, len;
615 destlen--; /* save room for the terminal \0 */
616 wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0;
619 while (*src && wlen < destlen) {
630 flags |= M_FORMAT_OPTIONAL;
634 flags &= ~M_FORMAT_OPTIONAL;
636 /* eat the format string */
639 while (count < ssizeof (prefix) &&
640 (isdigit ((unsigned char) *src) || *src == '.' || *src == '-'))
649 break; /* bad format */
651 ch = *src++; /* save the character to switch on */
653 if (flags & M_FORMAT_OPTIONAL) {
655 break; /* bad format */
658 /* eat the `if' part of the string */
661 while (count < ssizeof (ifstring) && *src && *src != '?'
668 /* eat the `else' part of the string (optional) */
670 src++; /* skip the & */
673 while (count < ssizeof (elsestring) && *src && *src != '?') {
680 break; /* bad format */
682 src++; /* move past the trailing `?' */
685 /* handle generic cases first */
687 /* right justify to EOL */
688 ch = *src++; /* pad char */
689 /* calculate space left on line. if we've already written more data
690 than will fit on the line, ignore the rest of the line */
691 if (DrawFullLine || option (OPTSTATUSONTOP))
692 count = (COLS < destlen ? COLS : destlen);
694 count = ((COLS - SW) < destlen ? (COLS - SW) : destlen);
696 count -= col; /* how many columns left on this line */
697 mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
700 count -= wid; /* how many chars to pad */
701 memset (wptr, ch, count);
705 if (wid + wlen > destlen)
706 len = destlen - wlen;
709 memcpy (wptr, buf, len);
712 col += mutt_strwidth (buf);
714 break; /* skip rest of input */
716 else if (ch == '|') {
721 if (destlen > wlen) {
722 count = destlen - wlen;
723 memset (wptr, ch, count);
726 break; /* skip rest of input */
732 while (ch == '_' || ch == ':') {
741 /* use callback function to handle this case */
743 callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring,
756 if ((len = m_strlen(buf)) + wlen > destlen)
757 len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
759 memcpy (wptr, buf, len);
762 col += mutt_strwidth (buf);
765 else if (*src == '\\') {
794 unsigned int bar = strcspn(src, "%\\");
795 char *bar2 = p_dupstr(src, bar);
801 col += mutt_strwidth (bar2);
808 if (flags & M_FORMAT_MAKEPRINT) {
809 /* Make sure that the string is printable by changing all non-printable
810 chars to dots, or spaces for non-printable whitespace */
811 for (cp = dest; *cp; cp++)
812 if (!isprint(*cp) && !((flags & M_FORMAT_TREE) && (*cp <= M_TREE_MAX)))
813 *cp = isspace ((unsigned char) *cp) ? ' ' : '.';
818 /* returns 0 if OK to proceed, -1 to abort, 1 to retry */
819 int mutt_save_confirm (const char *s, struct stat *st)
821 char tmp[_POSIX_PATH_MAX];
826 magic = mx_get_magic (s);
828 if (magic == M_POP) {
829 mutt_error _("Can't save message to POP mailbox.");
835 if (magic == M_NNTP) {
836 mutt_error _("Can't save message to newsserver.");
842 if (magic > 0 && !mx_access (s, W_OK)) {
843 if (option (OPTCONFIRMAPPEND) &&
844 (!TrashPath || (m_strcmp(s, TrashPath) != 0))) {
845 /* if we're appending to the trash, there's no point in asking */
846 snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
847 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
854 if (stat (s, st) != -1) {
856 mutt_error (_("%s is not a mailbox!"), s);
866 if (errno == ENOENT) {
867 if (option (OPTCONFIRMCREATE)) {
868 snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
869 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
882 CLEARLINE (LINES - 1);
886 void mutt_sleep (short s)
888 sleep(MAX(s, SleepTime));
891 /* Decrease a file's modification time by 1 second */
892 time_t mutt_decrease_mtime (const char *f, struct stat *st)
899 if (stat (f, &_st) == -1)
904 if ((mtime = st->st_mtime) == time (NULL)) {
907 utim.modtime = mtime;
914 /* sets mtime of 'to' to mtime of 'from' */
915 void mutt_set_mtime (const char* from, const char* to) {
919 if (stat (from, &st) != -1) {
920 utim.actime = st.st_mtime;
921 utim.modtime = st.st_mtime;
926 const char *mutt_make_version (int full)
928 static char vstring[STRING];
931 snprintf (vstring, sizeof (vstring),
932 "Madmutt/%s-r%s (based on Mutt 1.5.11)",
933 MUTT_VERSION, MUTT_REVISION);
935 snprintf (vstring, sizeof (vstring), "Madmutt/%s-%s",
936 MUTT_VERSION, MUTT_REVISION);
940 void mutt_free_spam_list (SPAM_LIST ** list)
948 *list = (*list)->next;
950 p_delete(&p->template);
955 int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x)
957 static regmatch_t *pmatch = NULL;
958 static int nmatch = 0;
967 for (; l; l = l->next) {
968 /* If this pattern needs more matches, expand pmatch. */
969 if (l->nmatch > nmatch) {
970 p_realloc(&pmatch, l->nmatch);
974 /* Does this pattern match? */
975 if (regexec(l->rx->rx, s, l->nmatch, (regmatch_t *)pmatch, (int) 0) == 0)
977 /* Copy template into text, with substitutions. */
978 for (p = l->template; *p;) {
980 n = atoi (++p); /* find pmatch index */
981 while (isdigit ((unsigned char) *p))
982 ++p; /* skip subst token */
983 for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
998 int mutt_cmp_header (const HEADER * h1, const HEADER * h2) {
1000 if (h1->received != h2->received ||
1001 h1->date_sent != h2->date_sent ||
1002 h1->content->length != h2->content->length ||
1003 h1->lines != h2->lines ||
1004 h1->zhours != h2->zhours ||
1005 h1->zminutes != h2->zminutes ||
1006 h1->zoccident != h2->zoccident ||
1007 h1->mime != h2->mime ||
1008 !mutt_cmp_env (h1->env, h2->env) ||
1009 !mutt_cmp_body (h1->content, h2->content))
1015 if (h1 == NULL && h2 == NULL)
1022 /* return 1 if address lists are strictly identical */
1023 int mutt_cmp_addr (const address_t * a, const address_t * b)
1026 if (m_strcmp(a->mailbox, b->mailbox) ||
1027 m_strcmp(a->personal, b->personal))
1039 int mutt_cmp_list (const string_list_t * a, const string_list_t * b)
1042 if (m_strcmp(a->data, b->data))
1054 int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2)
1057 if (m_strcmp(e1->message_id, e2->message_id) ||
1058 m_strcmp(e1->subject, e2->subject) ||
1059 !mutt_cmp_list (e1->references, e2->references) ||
1060 !mutt_cmp_addr (e1->from, e2->from) ||
1061 !mutt_cmp_addr (e1->sender, e2->sender) ||
1062 !mutt_cmp_addr (e1->reply_to, e2->reply_to) ||
1063 !mutt_cmp_addr (e1->to, e2->to) ||
1064 !mutt_cmp_addr (e1->cc, e2->cc) ||
1065 !mutt_cmp_addr (e1->return_path, e2->return_path))
1071 if (e1 == NULL && e2 == NULL)
1078 int mutt_cmp_body (const BODY * b1, const BODY * b2)
1080 if (b1->type != b2->type ||
1081 b1->encoding != b2->encoding ||
1082 m_strcmp(b1->subtype, b2->subtype) ||
1083 m_strcmp(b1->description, b2->description) ||
1084 !parameter_equal(b1->parameter, b2->parameter) ||
1085 b1->length != b2->length)
1090 int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags)
1093 char qc = 0; /* quote char */
1096 /* reset the destination pointer to the beginning of the buffer */
1097 dest->dptr = dest->data;
1099 tok->dptr = vskipspaces(tok->dptr);
1100 while ((ch = *tok->dptr)) {
1102 if ((ISSPACE(ch) && !(flags & M_TOKEN_SPACE))
1103 || (ch == '#' && !(flags & M_TOKEN_COMMENT))
1104 || (ch == '=' && (flags & M_TOKEN_EQUAL))
1105 || (ch == ';' && !(flags & M_TOKEN_SEMICOLON))
1106 || ((flags & M_TOKEN_PATTERN) && strchr("~=!|", ch)))
1115 qc = 0; /* end of quote */
1117 if (!qc && (ch == '\'' || ch == '"') && !(flags & M_TOKEN_QUOTE)) {
1120 if (ch == '\\' && qc != '\'') {
1122 return -1; /* premature end of token */
1124 switch (ch = *tok->dptr++) {
1128 return -1; /* premature end of token */
1129 mutt_buffer_addch(dest,
1130 (ascii_toupper(*tok->dptr) - 'A' + 1) & 0x7f);
1134 mutt_buffer_addch(dest, '\r');
1137 mutt_buffer_addch(dest, '\n');
1140 mutt_buffer_addch(dest, '\t');
1143 mutt_buffer_addch(dest, '\f');
1146 mutt_buffer_addch(dest, '\033');
1149 if (isdigit((unsigned char)ch)
1150 && isdigit((unsigned char)*tok->dptr)
1151 && isdigit((unsigned char)*(tok->dptr + 1)))
1153 mutt_buffer_addch(dest, (ch << 6) + (*tok->dptr << 3) +
1154 *(tok->dptr + 1) - 3504);
1157 mutt_buffer_addch(dest, ch);
1161 if (ch == '^' && (flags & M_TOKEN_CONDENSE)) {
1163 return -1; /* premature end of token */
1166 mutt_buffer_addch(dest, ch);
1169 mutt_buffer_addch(dest, '\033');
1171 if (isalpha((unsigned char)ch)) {
1172 mutt_buffer_addch(dest, ascii_toupper(ch) - 'A' + 1);
1174 mutt_buffer_addch(dest, '^');
1175 mutt_buffer_addch(dest, ch);
1178 if (ch == '`' && (!qc || qc == '"')) {
1188 if ((pc = strpbrk(pc, "\\`"))) {
1189 /* skip any quoted chars */
1193 } while (pc && *pc != '`');
1198 cmd = p_dupstr(tok->dptr, pc - tok->dptr);
1199 if ((pid = mutt_create_filter(cmd, NULL, &fp, NULL)) < 0) {
1209 expn.data = mutt_read_line(NULL, &expn.dsize, fp, &line);
1211 mutt_wait_filter(pid);
1213 /* if we got output, make a new string consiting of the shell ouptput
1214 plus whatever else was left on the original line */
1215 /* BUT: If this is inside a quoted string, directly add output to
1217 if (expn.data && qc) {
1218 mutt_buffer_addstr(dest, expn.data);
1219 p_delete(&expn.data);
1222 expnlen = m_strlen(expn.data);
1223 tok->dsize = expnlen + m_strlen(tok->dptr) + 1;
1224 ptr = xmalloc(tok->dsize);
1225 memcpy(ptr, expn.data, expnlen);
1226 strcpy(ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */
1228 p_delete(&tok->data);
1231 tok->destroy = 1; /* mark that the caller should destroy this data */
1233 p_delete(&expn.data);
1236 if (ch == '$' && (!qc || qc == '"')
1237 && (*tok->dptr == '{' || isalpha((unsigned char)*tok->dptr)))
1239 char *env = NULL, *var = NULL;
1241 if (*tok->dptr == '{') {
1243 if ((pc = strchr (tok->dptr, '}'))) {
1244 var = p_dupstr(tok->dptr, pc - tok->dptr);
1248 for (pc = tok->dptr; isalnum((unsigned char)*pc) || *pc == '_';
1250 var = p_dupstr(tok->dptr, pc - tok->dptr);
1255 if ((env = getenv (var))
1256 || (mutt_option_value (var, tmp, sizeof (tmp)) && (env = tmp)))
1258 mutt_buffer_addstr (dest, env);
1263 mutt_buffer_addch(dest, ch);
1266 mutt_buffer_addch(dest, 0); /* terminate the string */
1267 tok->dptr = vskipspaces(tok->dptr);