Rocco Rutte wrote : > * Kyle Wheeler wrote: > > On Wednesday, June 17 at 05:28 PM, quoth Rocco Rutte: > > > >>This would appear to break situations like mine, where I use '=' to > > >>refer to $folder: > > > >> mailboxes = =friends =mutt > > > >No, because mutt_expand_path() is called in advance that would expand a > > >leading '=' using $folder. However, ==foo is kind of broken. > > > Ahh, I see. > > > I wonder... would this redefine other prefixes? Like, what if you did > > !!=foo or @=foo ? > > The same thing, the prefix is always stripped regardless if it expands > to something. So yes, all prefixes followed by = are broken, i.e. have > an empty alias with that patch.
Yes, this would break. I'm not sure why someone would use '!!=foo' as a parameter to 'mailboxes' though ;) I replaced: if (*buf != '=' && (p = strchr(buf, '=')) != NULL) By: if (strchr("~...@!*><!-^", *buf) == NULL && (p = strchr(buf + 1, '=')) != NULL) This will avoid the prefixes to get caught in it. I attached the revised patch with this change. Thanks for the feedback, Bertrand
diff -r d213f3acdb68 buffy.c --- a/buffy.c Mon Jun 15 14:24:27 2009 -0700 +++ b/buffy.c Wed Jun 17 14:05:53 2009 -0400 @@ -194,7 +194,9 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err) { BUFFY **tmp,*tmp1; + char *alias; char buf[_POSIX_PATH_MAX]; + char tbuf[_POSIX_PATH_MAX]; struct stat sb; char f1[PATH_MAX], f2[PATH_MAX]; char *p, *q; @@ -203,6 +205,7 @@ { mutt_extract_token (path, s, 0); strfcpy (buf, path->data, sizeof (buf)); + alias = NULL; if(data == M_UNMAILBOXES && mutt_strcmp(buf,"*") == 0) { @@ -220,6 +223,14 @@ /* Skip empty tokens. */ if(!*buf) continue; + /* Extract mailbox alias if any. */ + if (strchr("~...@!*><!-^", *buf) == NULL && (p = strchr(buf, '=')) != NULL) + { + alias = mutt_substrdup(buf, p); + strcpy(tbuf, p + 1); + strcpy(buf, tbuf); + } + /* avoid duplicates */ p = realpath (buf, f1); for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) @@ -249,15 +260,21 @@ *tmp = (BUFFY *) safe_calloc (1, sizeof (BUFFY)); strfcpy ((*tmp)->path, buf, sizeof ((*tmp)->path)); (*tmp)->next = NULL; + (*tmp)->alias = NULL; /* it is tempting to set magic right here */ (*tmp)->magic = 0; - } (*tmp)->new = 0; (*tmp)->notified = 1; (*tmp)->newly_created = 0; + if (alias != NULL) + { + mutt_str_replace(&(*tmp)->alias, alias); + free(alias); + } + /* for check_mbox_size, it is important that if the folder is new (tested by * reading it), the size is set to 0 so that later when we check we see * that it increased . without check_mbox_size we probably don't care. @@ -271,6 +288,7 @@ else (*tmp)->size = 0; } + return 0; } diff -r d213f3acdb68 buffy.h --- a/buffy.h Mon Jun 15 14:24:27 2009 -0700 +++ b/buffy.h Wed Jun 17 14:05:53 2009 -0400 @@ -23,6 +23,7 @@ typedef struct buffy_t { char path[_POSIX_PATH_MAX]; + char *alias; off_t size; struct buffy_t *next; short new; /* mailbox has new mail */ diff -r d213f3acdb68 muttlib.c --- a/muttlib.c Mon Jun 15 14:24:27 2009 -0700 +++ b/muttlib.c Wed Jun 17 14:05:53 2009 -0400 @@ -27,6 +27,7 @@ #include "mailbox.h" #include "mx.h" #include "url.h" +#include "buffy.h" #ifdef USE_IMAP #include "imap.h" @@ -354,6 +355,7 @@ char q[_POSIX_PATH_MAX] = ""; char tmp[_POSIX_PATH_MAX]; char *t; + BUFFY *btmp; char *tail = ""; @@ -444,6 +446,20 @@ } } break; + + case '*': + { + tail = s + 1; + for (btmp = Incoming; btmp; btmp = btmp->next) { + if (btmp->alias != NULL && mutt_strcmp(s + 1, btmp->alias) == 0) + { + strfcpy (p, btmp->path, sizeof (p)); + tail = ""; + break; + } + } + } + break; case '>': {