From 31b7d5cfd69ee46324c121a53b3adede27a99b0d Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Tue, 27 Aug 2019 08:48:54 +0000 Subject: [PATCH] Add: mailbox_path() to tidy Mailbox usage --- browser.c | 14 ++++----- compose.c | 4 +-- compress.c | 34 +++++++++++----------- core/mailbox.c | 4 +-- core/mailbox.h | 5 ++++ hdrline.c | 4 +-- imap/browse.c | 2 +- imap/imap.c | 14 ++++----- imap/message.c | 2 +- index.c | 12 ++++---- init.c | 4 +-- maildir/maildir.c | 36 +++++++++++------------ maildir/mh.c | 24 +++++++-------- maildir/shared.c | 66 +++++++++++++++++++++--------------------- mbox/mbox.c | 52 ++++++++++++++++----------------- mutt_mailbox.c | 16 +++++----- mx.c | 42 +++++++++++++-------------- nntp/nntp.c | 4 +-- notmuch/mutt_notmuch.c | 12 ++++---- pattern.c | 2 +- pop/pop.c | 14 ++++----- sidebar.c | 26 ++++++++--------- status.c | 2 +- 23 files changed, 200 insertions(+), 195 deletions(-) diff --git a/browser.c b/browser.c index 0acb3f293..7045cffb0 100644 --- a/browser.c +++ b/browser.c @@ -784,7 +784,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state, struct MailboxNode *np = NULL; STAILQ_FOREACH(np, &ml, entries) { - if (mutt_str_strcmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) != 0) + if (mutt_str_strcmp(mutt_b2s(buf), mailbox_path(np->mailbox)) != 0) break; } @@ -857,7 +857,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) np->mailbox->msg_unread = Context->mailbox->msg_unread; } - mutt_buffer_strcpy(mailbox, mutt_b2s(np->mailbox->pathbuf)); + mutt_buffer_strcpy(mailbox, mailbox_path(np->mailbox)); if (C_BrowserAbbreviateMailboxes) mutt_buffer_pretty_mailbox(mailbox); @@ -870,14 +870,14 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) continue; case MUTT_NOTMUCH: case MUTT_NNTP: - add_folder(menu, state, mutt_b2s(np->mailbox->pathbuf), + add_folder(menu, state, mailbox_path(np->mailbox), np->mailbox->name, NULL, np->mailbox, NULL); continue; default: /* Continue */ break; } - if (lstat(mutt_b2s(np->mailbox->pathbuf), &s) == -1) + if (lstat(mailbox_path(np->mailbox), &s) == -1) continue; if ((!S_ISREG(s.st_mode)) && (!S_ISDIR(s.st_mode)) && (!S_ISLNK(s.st_mode))) @@ -887,10 +887,10 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) { struct stat st2; - mutt_buffer_printf(md, "%s/new", mutt_b2s(np->mailbox->pathbuf)); + mutt_buffer_printf(md, "%s/new", mailbox_path(np->mailbox)); if (stat(mutt_b2s(md), &s) < 0) s.st_mtime = 0; - mutt_buffer_printf(md, "%s/cur", mutt_b2s(np->mailbox->pathbuf)); + mutt_buffer_printf(md, "%s/cur", mailbox_path(np->mailbox)); if (stat(mutt_b2s(md), &st2) < 0) st2.st_mtime = 0; if (st2.st_mtime > s.st_mtime) @@ -1619,7 +1619,7 @@ void mutt_buffer_select_file(struct Buffer *file, SelectFileFlags flags, // TODO(sileht): It could be better to select INBOX instead. But I // don't want to manipulate Context/Mailboxes/mailbox->account here for now. // Let's just protect neomutt against crash for now. #1417 - if (mutt_str_strcmp(mutt_b2s(Context->mailbox->pathbuf), + if (mutt_str_strcmp(mailbox_path(Context->mailbox), state.entry[nentry].name) == 0) { mutt_error(_("Can't delete currently selected mailbox")); diff --git a/compose.c b/compose.c index e18f98878..bf191d958 100644 --- a/compose.c +++ b/compose.c @@ -1570,7 +1570,7 @@ int mutt_compose_menu(struct Email *e, char *fcc, size_t fcclen, struct Email *e if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->mailbox->magic == MUTT_NNTP)) #endif { - mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf)); + mutt_str_strfcpy(buf, mailbox_path(Context->mailbox), sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); } @@ -2065,7 +2065,7 @@ int mutt_compose_menu(struct Email *e, char *fcc, size_t fcclen, struct Email *e buf[0] = '\0'; if (Context) { - mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf)); + mutt_str_strfcpy(buf, mailbox_path(Context->mailbox), sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); } if (actx->idxlen) diff --git a/compress.c b/compress.c index e3f2026ed..3c20069e6 100644 --- a/compress.c +++ b/compress.c @@ -137,13 +137,13 @@ static int setup_paths(struct Mailbox *m) char tmp[PATH_MAX]; /* Setup the right paths */ - mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf)); + mutt_str_replace(&m->realpath, mailbox_path(m)); /* We will uncompress to /tmp */ mutt_mktemp(tmp, sizeof(tmp)); mutt_buffer_strcpy(m->pathbuf, tmp); - FILE *fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "w"); + FILE *fp = mutt_file_fopen(mailbox_path(m), "w"); if (!fp) return -1; @@ -212,12 +212,12 @@ static struct CompressInfo *set_compress_info(struct Mailbox *m) return m->compress_info; /* Open is compulsory */ - const char *o = find_hook(MUTT_OPEN_HOOK, mutt_b2s(m->pathbuf)); + const char *o = find_hook(MUTT_OPEN_HOOK, mailbox_path(m)); if (!o) return NULL; - const char *c = find_hook(MUTT_CLOSE_HOOK, mutt_b2s(m->pathbuf)); - const char *a = find_hook(MUTT_APPEND_HOOK, mutt_b2s(m->pathbuf)); + const char *c = find_hook(MUTT_CLOSE_HOOK, mailbox_path(m)); + const char *a = find_hook(MUTT_APPEND_HOOK, mailbox_path(m)); struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo)); m->compress_info = ci; @@ -280,7 +280,7 @@ static const char *compress_format_str(char *buf, size_t buflen, size_t col, int break; case 't': /* Plaintext, temporary file */ - mutt_buffer_quote_filename(quoted, mutt_b2s(m->pathbuf), false); + mutt_buffer_quote_filename(quoted, mailbox_path(m), false); snprintf(buf, buflen, "%s", mutt_b2s(quoted)); break; } @@ -382,7 +382,7 @@ bool mutt_comp_can_append(struct Mailbox *m) return true; mutt_error(_("Can't append without an append-hook or close-hook : %s"), - mutt_b2s(m->pathbuf)); + mailbox_path(m)); return false; } @@ -462,7 +462,7 @@ static int comp_mbox_open(struct Mailbox *m) int rc; /* If there's no close-hook, or the file isn't writable */ - if (!ci->cmd_close || (access(mutt_b2s(m->pathbuf), W_OK) != 0)) + if (!ci->cmd_close || (access(mailbox_path(m), W_OK) != 0)) m->readonly = true; if (setup_paths(m) != 0) @@ -481,7 +481,7 @@ static int comp_mbox_open(struct Mailbox *m) unlock_realpath(m); - m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL); + m->magic = mx_path_probe(mailbox_path(m), NULL); if (m->magic == MUTT_UNKNOWN) { mutt_error(_("Can't identify the contents of the compressed file")); @@ -500,7 +500,7 @@ static int comp_mbox_open(struct Mailbox *m) cmo_fail: /* remove the partial uncompressed file */ - remove(mutt_b2s(m->pathbuf)); + remove(mailbox_path(m)); free_compress_info(m); return -1; } @@ -527,7 +527,7 @@ static int comp_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) if (!ci->cmd_append && !ci->cmd_close) { mutt_error(_("Can't append without an append-hook or close-hook : %s"), - mutt_b2s(m->pathbuf)); + mailbox_path(m)); goto cmoa_fail1; } @@ -551,7 +551,7 @@ static int comp_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) mutt_error(_("Compress command failed: %s"), ci->cmd_open); goto cmoa_fail2; } - m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL); + m->magic = mx_path_probe(mailbox_path(m), NULL); } else m->magic = C_MboxType; @@ -577,7 +577,7 @@ static int comp_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) cmoa_fail2: /* remove the partial uncompressed file */ - remove(mutt_b2s(m->pathbuf)); + remove(mailbox_path(m)); cmoa_fail1: /* Free the compress_info to prevent close from trying to recompress */ free_compress_info(m); @@ -726,23 +726,23 @@ static int comp_mbox_close(struct Mailbox *m) if (rc == 0) { mutt_any_key_to_continue(NULL); - mutt_error(_("Error. Preserving temporary file: %s"), mutt_b2s(m->pathbuf)); + mutt_error(_("Error. Preserving temporary file: %s"), mailbox_path(m)); } else - remove(mutt_b2s(m->pathbuf)); + remove(mailbox_path(m)); unlock_realpath(m); } else { /* If the file was removed, remove the compressed folder too */ - if ((access(mutt_b2s(m->pathbuf), F_OK) != 0) && !C_SaveEmpty) + if ((access(mailbox_path(m), F_OK) != 0) && !C_SaveEmpty) { remove(m->realpath); } else { - remove(mutt_b2s(m->pathbuf)); + remove(mailbox_path(m)); } } diff --git a/core/mailbox.c b/core/mailbox.c index c914091ab..57cf644dc 100644 --- a/core/mailbox.c +++ b/core/mailbox.c @@ -92,7 +92,7 @@ struct Mailbox *mailbox_find(const char *path) struct Mailbox *m = NULL; STAILQ_FOREACH(np, &ml, entries) { - if ((stat(mutt_b2s(np->mailbox->pathbuf), &tmp_sb) == 0) && + if ((stat(mailbox_path(np->mailbox), &tmp_sb) == 0) && (sb.st_dev == tmp_sb.st_dev) && (sb.st_ino == tmp_sb.st_ino)) { m = np->mailbox; @@ -146,7 +146,7 @@ void mailbox_update(struct Mailbox *m) if (!m) return; - if (stat(mutt_b2s(m->pathbuf), &sb) == 0) + if (stat(mailbox_path(m), &sb) == 0) m->size = (off_t) sb.st_size; else m->size = 0; diff --git a/core/mailbox.h b/core/mailbox.h index bb1e75cf9..c874123bb 100644 --- a/core/mailbox.h +++ b/core/mailbox.h @@ -186,4 +186,9 @@ void mailbox_size_add (struct Mailbox *m, const struct Email *e); void mailbox_size_sub (struct Mailbox *m, const struct Email *e); void mailbox_update (struct Mailbox *m); +static inline const char *mailbox_path(const struct Mailbox *m) +{ + return mutt_b2s(m->pathbuf); +} + #endif /* MUTT_CORE_MAILBOX_H */ diff --git a/hdrline.c b/hdrline.c index a2f1ba09d..d39e3487b 100644 --- a/hdrline.c +++ b/hdrline.c @@ -642,11 +642,11 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co case 'b': if (m) { - p = strrchr(mutt_b2s(m->pathbuf), '/'); + p = strrchr(mailbox_path(m), '/'); if (p) mutt_str_strfcpy(buf, p + 1, buflen); else - mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen); + mutt_str_strfcpy(buf, mailbox_path(m), buflen); } else mutt_str_strfcpy(buf, "(null)", buflen); diff --git a/imap/browse.c b/imap/browse.c index 439b04edf..7748882ac 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -117,7 +117,7 @@ static void add_folder(char delim, char *folder, bool noselect, bool noinferiors struct MailboxNode *np = NULL; STAILQ_FOREACH(np, &ml, entries) { - if (mutt_str_strcmp(tmp, mutt_b2s(np->mailbox->pathbuf)) == 0) + if (mutt_str_strcmp(tmp, mailbox_path(np->mailbox)) == 0) break; } diff --git a/imap/imap.c b/imap/imap.c index 0df031d2f..6d88d85d5 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -520,16 +520,16 @@ static int complete_hosts(char *buf, size_t buflen) struct MailboxNode *np = NULL; STAILQ_FOREACH(np, &ml, entries) { - if (!mutt_str_startswith(mutt_b2s(np->mailbox->pathbuf), buf, CASE_MATCH)) + if (!mutt_str_startswith(mailbox_path(np->mailbox), buf, CASE_MATCH)) continue; if (rc) { - mutt_str_strfcpy(buf, mutt_b2s(np->mailbox->pathbuf), buflen); + mutt_str_strfcpy(buf, mailbox_path(np->mailbox), buflen); rc = 0; } else - longest_common_prefix(buf, mutt_b2s(np->mailbox->pathbuf), matchlen, buflen); + longest_common_prefix(buf, mailbox_path(np->mailbox), matchlen, buflen); } neomutt_mailboxlist_clear(&ml); @@ -1535,7 +1535,7 @@ int imap_fast_trash(struct Mailbox *m, char *dest) /* check that the save-to folder is in the same account */ if (!mutt_account_match(&(adata->conn->account), &(dest_adata->conn->account))) { - mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf)); + mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mailbox_path(m)); goto out; } @@ -1847,7 +1847,7 @@ int imap_ac_add(struct Account *a, struct Mailbox *m) struct ConnAccount conn_account; char mailbox[PATH_MAX]; - if (imap_parse_path(mutt_b2s(m->pathbuf), &conn_account, mailbox, sizeof(mailbox)) < 0) + if (imap_parse_path(mailbox_path(m), &conn_account, mailbox, sizeof(mailbox)) < 0) return -1; adata = imap_adata_new(); @@ -1867,14 +1867,14 @@ int imap_ac_add(struct Account *a, struct Mailbox *m) if (!m->mdata) { - struct Url *url = url_parse(mutt_b2s(m->pathbuf)); + struct Url *url = url_parse(mailbox_path(m)); struct ImapMboxData *mdata = imap_mdata_new(adata, url->path); /* fixup path and realpath, mainly to replace / by /INBOX */ char buf[1024]; imap_qualify_path(buf, sizeof(buf), &adata->conn_account, mdata->name); mutt_buffer_strcpy(m->pathbuf, buf); - mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf)); + mutt_str_replace(&m->realpath, mailbox_path(m)); m->mdata = mdata; m->free_mdata = imap_mdata_free; diff --git a/imap/message.c b/imap/message.c index 8f72cb2dd..2cb5bee01 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1609,7 +1609,7 @@ int imap_copy_messages(struct Mailbox *m, struct EmailList *el, char *dest, bool /* check that the save-to folder is in the same account */ if (!mutt_account_match(&adata->conn->account, &conn_account)) { - mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf)); + mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mailbox_path(m)); return 1; } diff --git a/index.c b/index.c index a12352a08..115be7ef6 100644 --- a/index.c +++ b/index.c @@ -638,7 +638,7 @@ static int main_change_folder(struct Menu *menu, int op, struct Mailbox *m, m = mailbox_find_name(buf); if (m) { - mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen); + mutt_str_strfcpy(buf, mailbox_path(m), buflen); } else { @@ -663,7 +663,7 @@ static int main_change_folder(struct Menu *menu, int op, struct Mailbox *m, new_last_folder = mutt_str_strdup(Context->mailbox->realpath); else #endif - new_last_folder = mutt_str_strdup(mutt_b2s(Context->mailbox->pathbuf)); + new_last_folder = mutt_str_strdup(mailbox_path(Context->mailbox)); *oldcount = Context->mailbox->msg_count; int check = mx_mbox_close(&Context); @@ -2241,7 +2241,7 @@ int mutt_index_menu(void) if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->mailbox && !mutt_buffer_is_empty(Context->mailbox->pathbuf)) { - mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf)); + mutt_buffer_strcpy(folderbuf, mailbox_path(Context->mailbox)); mutt_buffer_pretty_mailbox(folderbuf); mutt_mailbox_next_buffer(Context ? Context->mailbox : NULL, folderbuf); if (mutt_buffer_is_empty(folderbuf)) @@ -2256,10 +2256,10 @@ int mutt_index_menu(void) m = mutt_sb_get_highlight(); if (!m) goto changefoldercleanup; - mutt_buffer_strcpy(folderbuf, mutt_b2s(m->pathbuf)); + mutt_buffer_strcpy(folderbuf, mailbox_path(m)); /* Mark the selected dir for the neomutt browser */ - mutt_browser_select_dir(mutt_b2s(m->pathbuf)); + mutt_browser_select_dir(mailbox_path(m)); } #endif else @@ -2267,7 +2267,7 @@ int mutt_index_menu(void) if (C_ChangeFolderNext && Context && Context->mailbox && mutt_buffer_is_empty(Context->mailbox->pathbuf)) { - mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf)); + mutt_buffer_strcpy(folderbuf, mailbox_path(Context->mailbox)); mutt_buffer_pretty_mailbox(folderbuf); } #ifdef USE_NNTP diff --git a/init.c b/init.c index e02423e57..dadc0b483 100644 --- a/init.c +++ b/init.c @@ -2427,7 +2427,7 @@ static enum CommandResult parse_unmailboxes(struct Buffer *buf, struct Buffer *s if (!clear_this && tmp_valid) { clear_this = - (mutt_str_strcasecmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) == 0) || + (mutt_str_strcasecmp(mutt_b2s(buf), mailbox_path(np->mailbox)) == 0) || (mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->name) == 0); } @@ -3192,7 +3192,7 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands) struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_NOTMUCH); struct MailboxNode *mp = STAILQ_FIRST(&ml); if (mp) - cs_str_string_set(Config, "spoolfile", mutt_b2s(mp->mailbox->pathbuf), NULL); + cs_str_string_set(Config, "spoolfile", mailbox_path(mp->mailbox), NULL); neomutt_mailboxlist_clear(&ml); } #endif diff --git a/maildir/maildir.c b/maildir/maildir.c index cfcd08865..398269850 100644 --- a/maildir/maildir.c +++ b/maildir/maildir.c @@ -81,7 +81,7 @@ static void maildir_check_dir(struct Mailbox *m, const char *dir_name, struct Buffer *path = mutt_buffer_pool_get(); struct Buffer *msgpath = mutt_buffer_pool_get(); - mutt_buffer_printf(path, "%s/%s", mutt_b2s(m->pathbuf), dir_name); + mutt_buffer_printf(path, "%s/%s", mailbox_path(m), dir_name); /* when $mail_check_recent is set, if the new/ directory hasn't been modified since * the user last exited the m, then we know there is no recent mail. */ @@ -250,8 +250,8 @@ int maildir_sync_message(struct Mailbox *m, int msgno) mutt_buffer_printf(partpath, "%s/%s%s", (e->read || e->old) ? "cur" : "new", mutt_b2s(newpath), suffix); - mutt_buffer_printf(fullpath, "%s/%s", mutt_b2s(m->pathbuf), mutt_b2s(partpath)); - mutt_buffer_printf(oldpath, "%s/%s", mutt_b2s(m->pathbuf), e->path); + mutt_buffer_printf(fullpath, "%s/%s", mailbox_path(m), mutt_b2s(partpath)); + mutt_buffer_printf(oldpath, "%s/%s", mailbox_path(m), e->path); if (mutt_str_strcmp(mutt_b2s(fullpath), mutt_b2s(oldpath)) == 0) { @@ -306,40 +306,40 @@ static int maildir_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) return 0; } - if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU)) + if (mkdir(mailbox_path(m), S_IRWXU)) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } char tmp[PATH_MAX]; - snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m)); if (mkdir(tmp, S_IRWXU)) { mutt_perror(tmp); - rmdir(mutt_b2s(m->pathbuf)); + rmdir(mailbox_path(m)); return -1; } - snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/new", mailbox_path(m)); if (mkdir(tmp, S_IRWXU)) { mutt_perror(tmp); - snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m)); rmdir(tmp); - rmdir(mutt_b2s(m->pathbuf)); + rmdir(mailbox_path(m)); return -1; } - snprintf(tmp, sizeof(tmp), "%s/tmp", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/tmp", mailbox_path(m)); if (mkdir(tmp, S_IRWXU)) { mutt_perror(tmp); - snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m)); rmdir(tmp); - snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/new", mailbox_path(m)); rmdir(tmp); - rmdir(mutt_b2s(m->pathbuf)); + rmdir(mailbox_path(m)); return -1; } @@ -380,14 +380,14 @@ int maildir_mbox_check(struct Mailbox *m, int *index_hint) return 0; struct Buffer *buf = mutt_buffer_pool_get(); - mutt_buffer_printf(buf, "%s/new", mutt_b2s(m->pathbuf)); + mutt_buffer_printf(buf, "%s/new", mailbox_path(m)); if (stat(mutt_b2s(buf), &st_new) == -1) { mutt_buffer_pool_release(&buf); return -1; } - mutt_buffer_printf(buf, "%s/cur", mutt_b2s(m->pathbuf)); + mutt_buffer_printf(buf, "%s/cur", mailbox_path(m)); if (stat(mutt_b2s(buf), &st_cur) == -1) { mutt_buffer_pool_release(&buf); @@ -603,7 +603,7 @@ int maildir_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e while (true) { snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", - mutt_b2s(m->pathbuf), subdir, (long long) time(NULL), + mailbox_path(m), subdir, (long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix); mutt_debug(LL_DEBUG2, "Trying %s\n", path); @@ -657,7 +657,7 @@ static int maildir_msg_save_hcache(struct Mailbox *m, struct Email *e) { int rc = 0; #ifdef USE_HCACHE - header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL); + header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL); char *key = e->path + 3; int keylen = maildir_hcache_keylen(key); rc = mutt_hcache_store(hc, key, keylen, e, 0); diff --git a/maildir/mh.c b/maildir/mh.c index ce81745c5..d04351170 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -194,7 +194,7 @@ void mh_update_sequences(struct Mailbox *m) return; } - snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf)); + snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox_path(m)); /* first, copy unknown sequences */ FILE *fp_old = fopen(sequences, "r"); @@ -364,7 +364,7 @@ static int mh_sequences_changed(struct Mailbox *m) char path[PATH_MAX]; struct stat sb; - if ((snprintf(path, sizeof(path), "%s/.mh_sequences", mutt_b2s(m->pathbuf)) < sizeof(path)) && + if ((snprintf(path, sizeof(path), "%s/.mh_sequences", mailbox_path(m)) < sizeof(path)) && (stat(path, &sb) == 0)) { return (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->last_visited) > 0); @@ -385,7 +385,7 @@ static int mh_already_notified(struct Mailbox *m, int msgno) char path[PATH_MAX]; struct stat sb; - if ((snprintf(path, sizeof(path), "%s/%d", mutt_b2s(m->pathbuf), msgno) < sizeof(path)) && + if ((snprintf(path, sizeof(path), "%s/%d", mailbox_path(m), msgno) < sizeof(path)) && (stat(path, &sb) == 0)) { return (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->last_visited) <= 0); @@ -435,7 +435,7 @@ static int mh_mbox_check_stats(struct Mailbox *m, int flags) if (!check_new) return 0; - if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0) + if (mh_read_sequences(&mhs, mailbox_path(m)) < 0) return false; m->msg_count = 0; @@ -468,7 +468,7 @@ static int mh_mbox_check_stats(struct Mailbox *m, int flags) mhs_free_sequences(&mhs); - dirp = opendir(mutt_b2s(m->pathbuf)); + dirp = opendir(mailbox_path(m)); if (dirp) { while ((de = readdir(dirp))) @@ -559,19 +559,19 @@ static int mh_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) return 0; } - if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU)) + if (mkdir(mailbox_path(m), S_IRWXU)) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } char tmp[PATH_MAX]; - snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", mutt_b2s(m->pathbuf)); + snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", mailbox_path(m)); const int i = creat(tmp, S_IRWXU); if (i == -1) { mutt_perror(tmp); - rmdir(mutt_b2s(m->pathbuf)); + rmdir(mailbox_path(m)); return -1; } close(i); @@ -608,12 +608,12 @@ int mh_mbox_check(struct Mailbox *m, int *index_hint) if (!C_CheckNew) return 0; - mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf)); + mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf)); if (stat(buf, &st) == -1) return -1; /* create .mh_sequences when there isn't one. */ - snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf)); + snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox_path(m)); int i = stat(buf, &st_cur); if ((i == -1) && (errno == ENOENT)) { @@ -663,7 +663,7 @@ int mh_mbox_check(struct Mailbox *m, int *index_hint) maildir_parse_dir(m, &last, NULL, &count, NULL); maildir_delayed_parsing(m, &md, NULL); - if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0) + if (mh_read_sequences(&mhs, mailbox_path(m)) < 0) return -1; mh_update_maildir(md, &mhs); mhs_free_sequences(&mhs); diff --git a/maildir/shared.c b/maildir/shared.c index 0fda04c72..2c90b84b1 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -119,9 +119,9 @@ mode_t mh_umask(struct Mailbox *m) return mdata->mh_umask; struct stat st; - if (stat(mutt_b2s(m->pathbuf), &st)) + if (stat(mailbox_path(m), &st)) { - mutt_debug(LL_DEBUG1, "stat failed on %s\n", mutt_b2s(m->pathbuf)); + mutt_debug(LL_DEBUG1, "stat failed on %s\n", mailbox_path(m)); return 077; } @@ -144,7 +144,7 @@ int mh_mkstemp(struct Mailbox *m, FILE **fp, char **tgt) mode_t omask = umask(mh_umask(m)); while (true) { - snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mutt_b2s(m->pathbuf), + snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox_path(m), NONULL(ShortHostname), (int) getpid(), mutt_rand64()); fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666); if (fd == -1) @@ -209,7 +209,7 @@ static void mh_sequences_add_one(struct Mailbox *m, int n, bool unseen, bool fla snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(C_MhSeqReplied)); snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(C_MhSeqFlagged)); - snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf)); + snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox_path(m)); FILE *fp_old = fopen(sequences, "r"); if (fp_old) { @@ -299,18 +299,18 @@ static void maildir_update_mtime(struct Mailbox *m) if (m->magic == MUTT_MAILDIR) { - snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "cur"); + snprintf(buf, sizeof(buf), "%s/%s", mailbox_path(m), "cur"); if (stat(buf, &st) == 0) mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME); - snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "new"); + snprintf(buf, sizeof(buf), "%s/%s", mailbox_path(m), "new"); } else { - snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf)); + snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox_path(m)); if (stat(buf, &st) == 0) mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME); - mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf)); + mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf)); } if (stat(buf, &st) == 0) @@ -341,11 +341,11 @@ int maildir_parse_dir(struct Mailbox *m, struct Maildir ***last, if (subdir) { - mutt_buffer_printf(buf, "%s/%s", mutt_b2s(m->pathbuf), subdir); + mutt_buffer_printf(buf, "%s/%s", mailbox_path(m), subdir); is_old = C_MarkOld ? (mutt_str_strcmp("cur", subdir) == 0) : false; } else - mutt_buffer_strcpy(buf, mutt_b2s(m->pathbuf)); + mutt_buffer_strcpy(buf, mailbox_path(m)); DIR *dirp = opendir(mutt_b2s(buf)); if (!dirp) @@ -645,7 +645,7 @@ static void mh_sort_natural(struct Mailbox *m, struct Maildir **md) { if (!m || !md || !*md || (m->magic != MUTT_MH) || (C_Sort != SORT_ORDER)) return; - mutt_debug(LL_DEBUG3, "maildir: sorting %s into natural order\n", mutt_b2s(m->pathbuf)); + mutt_debug(LL_DEBUG3, "maildir: sorting %s into natural order\n", mailbox_path(m)); *md = maildir_sort(*md, (size_t) -1, md_cmp_path); } @@ -688,7 +688,7 @@ void maildir_delayed_parsing(struct Mailbox *m, struct Maildir **md, struct Prog bool sort = false; #ifdef USE_HCACHE - header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL); + header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL); #endif for (p = *md, count = 0; p; p = p->next, count++) @@ -704,7 +704,7 @@ void maildir_delayed_parsing(struct Mailbox *m, struct Maildir **md, struct Prog if (!sort) { - mutt_debug(LL_DEBUG3, "maildir: need to sort %s by inode\n", mutt_b2s(m->pathbuf)); + mutt_debug(LL_DEBUG3, "maildir: need to sort %s by inode\n", mailbox_path(m)); p = maildir_sort(p, (size_t) -1, md_cmp_inode); if (!last) *md = p; @@ -712,10 +712,10 @@ void maildir_delayed_parsing(struct Mailbox *m, struct Maildir **md, struct Prog last->next = p; sort = true; p = skip_duplicates(p, &last); - snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path); + snprintf(fn, sizeof(fn), "%s/%s", mailbox_path(m), p->email->path); } - snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path); + snprintf(fn, sizeof(fn), "%s/%s", mailbox_path(m), p->email->path); #ifdef USE_HCACHE struct stat lastchanged = { 0 }; @@ -807,7 +807,7 @@ int mh_read_dir(struct Mailbox *m, const char *subdir) if (!m->quiet) { - snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0); } @@ -829,14 +829,14 @@ int mh_read_dir(struct Mailbox *m, const char *subdir) if (!m->quiet) { - snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, count); } maildir_delayed_parsing(m, &md, &progress); if (m->magic == MUTT_MH) { - if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0) + if (mh_read_sequences(&mhs, mailbox_path(m)) < 0) { maildir_free_maildir(&md); return -1; @@ -876,10 +876,10 @@ int mh_commit_msg(struct Mailbox *m, struct Message *msg, struct Email *e, bool return -1; } - DIR *dirp = opendir(mutt_b2s(m->pathbuf)); + DIR *dirp = opendir(mailbox_path(m)); if (!dirp) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } @@ -913,7 +913,7 @@ int mh_commit_msg(struct Mailbox *m, struct Message *msg, struct Email *e, bool { hi++; snprintf(tmp, sizeof(tmp), "%u", hi); - snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), tmp); + snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), tmp); if (mutt_file_safe_rename(msg->path, path) == 0) { if (e) @@ -924,7 +924,7 @@ int mh_commit_msg(struct Mailbox *m, struct Message *msg, struct Email *e, bool } else if (errno != EEXIST) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } } @@ -989,7 +989,7 @@ int md_commit_message(struct Mailbox *m, struct Message *msg, struct Email *e) { mutt_buffer_printf(path, "%s/%lld.R%" PRIu64 ".%s%s", subdir, (long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix); - mutt_buffer_printf(full, "%s/%s", mutt_b2s(m->pathbuf), mutt_b2s(path)); + mutt_buffer_printf(full, "%s/%s", mailbox_path(m), mutt_b2s(path)); mutt_debug(LL_DEBUG2, "renaming %s to %s\n", msg->path, mutt_b2s(full)); @@ -1026,7 +1026,7 @@ int md_commit_message(struct Mailbox *m, struct Message *msg, struct Email *e) } else if (errno != EEXIST) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); rc = -1; goto cleanup; } @@ -1069,7 +1069,7 @@ int mh_rewrite_message(struct Mailbox *m, int msgno) { char oldpath[PATH_MAX]; char partpath[PATH_MAX]; - snprintf(oldpath, sizeof(oldpath), "%s/%s", mutt_b2s(m->pathbuf), e->path); + snprintf(oldpath, sizeof(oldpath), "%s/%s", mailbox_path(m), e->path); mutt_str_strfcpy(partpath, e->path, sizeof(partpath)); if (m->magic == MUTT_MAILDIR) @@ -1101,7 +1101,7 @@ int mh_rewrite_message(struct Mailbox *m, int msgno) if ((m->magic == MUTT_MH) && (rc == 0)) { char newpath[PATH_MAX]; - snprintf(newpath, sizeof(newpath), "%s/%s", mutt_b2s(m->pathbuf), e->path); + snprintf(newpath, sizeof(newpath), "%s/%s", mailbox_path(m), e->path); rc = mutt_file_safe_rename(newpath, oldpath); if (rc == 0) mutt_str_replace(&e->path, partpath); @@ -1346,7 +1346,7 @@ int mh_sync_mailbox_message(struct Mailbox *m, int msgno, header_cache_t *hc) if (e->deleted && ((m->magic != MUTT_MAILDIR) || !C_MaildirTrash)) { char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), e->path); + snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), e->path); if ((m->magic == MUTT_MAILDIR) || (C_MhPurge && (m->magic == MUTT_MH))) { #ifdef USE_HCACHE @@ -1375,7 +1375,7 @@ int mh_sync_mailbox_message(struct Mailbox *m, int msgno, header_cache_t *hc) if (*e->path != ',') { char tmp[PATH_MAX]; - snprintf(tmp, sizeof(tmp), "%s/,%s", mutt_b2s(m->pathbuf), e->path); + snprintf(tmp, sizeof(tmp), "%s/,%s", mailbox_path(m), e->path); unlink(tmp); rename(path, tmp); } @@ -1527,11 +1527,11 @@ int maildir_mh_open_message(struct Mailbox *m, struct Message *msg, int msgno, b struct Email *e = m->emails[msgno]; char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), e->path); + snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), e->path); msg->fp = fopen(path, "r"); if (!msg->fp && (errno == ENOENT) && is_maildir) - msg->fp = maildir_open_find_message(mutt_b2s(m->pathbuf), e->path, NULL); + msg->fp = maildir_open_find_message(mailbox_path(m), e->path, NULL); if (!msg->fp) { @@ -1704,12 +1704,12 @@ int mh_mbox_sync(struct Mailbox *m, int *index_hint) #ifdef USE_HCACHE if ((m->magic == MUTT_MAILDIR) || (m->magic == MUTT_MH)) - hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL); + hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL); #endif if (!m->quiet) { - snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count); } @@ -1781,7 +1781,7 @@ int mh_msg_save_hcache(struct Mailbox *m, struct Email *e) { int rc = 0; #ifdef USE_HCACHE - header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL); + header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL); rc = mutt_hcache_store(hc, e->path, strlen(e->path), e, 0); mutt_hcache_close(hc); #endif diff --git a/mbox/mbox.c b/mbox/mbox.c index 6232960e6..d243d48ec 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -199,9 +199,9 @@ static int mmdf_parse_mailbox(struct Mailbox *m) struct stat sb; struct Progress progress; - if (stat(mutt_b2s(m->pathbuf), &sb) == -1) + if (stat(mailbox_path(m), &sb) == -1) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } mutt_file_get_stat_timespec(&adata->atime, &sb, MUTT_STAT_ATIME); @@ -213,7 +213,7 @@ static int mmdf_parse_mailbox(struct Mailbox *m) if (!m->quiet) { char msgbuf[256]; - snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0); } @@ -363,9 +363,9 @@ static int mbox_parse_mailbox(struct Mailbox *m) struct Progress progress; /* Save information about the folder at the time we opened it. */ - if (stat(mutt_b2s(m->pathbuf), &sb) == -1) + if (stat(mailbox_path(m), &sb) == -1) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } @@ -374,12 +374,12 @@ static int mbox_parse_mailbox(struct Mailbox *m) mutt_file_get_stat_timespec(&adata->atime, &sb, MUTT_STAT_ATIME); if (!m->readonly) - m->readonly = access(mutt_b2s(m->pathbuf), W_OK) ? true : false; + m->readonly = access(mailbox_path(m), W_OK) ? true : false; if (!m->quiet) { char msgbuf[256]; - snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0); } @@ -617,7 +617,7 @@ static int reopen_mailbox(struct Mailbox *m, int *index_hint) case MUTT_MMDF: cmp_headers = email_cmp_strict; mutt_file_fclose(&adata->fp); - adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "r"); + adata->fp = mutt_file_fopen(mailbox_path(m), "r"); if (!adata->fp) rc = -1; else if (m->magic == MUTT_MBOX) @@ -853,7 +853,7 @@ void mbox_reset_atime(struct Mailbox *m, struct stat *st) if (!st) { - if (stat(mutt_b2s(m->pathbuf), &st2) < 0) + if (stat(mailbox_path(m), &st2) < 0) return; st = &st2; } @@ -868,7 +868,7 @@ void mbox_reset_atime(struct Mailbox *m, struct stat *st) utimebuf.actime = utimebuf.modtime - 1; } - utime(mutt_b2s(m->pathbuf), &utimebuf); + utime(mailbox_path(m), &utimebuf); } /** @@ -883,7 +883,7 @@ struct Account *mbox_ac_find(struct Account *a, const char *path) if (!np) return NULL; - if (mutt_str_strcmp(mutt_b2s(np->mailbox->pathbuf), path) != 0) + if (mutt_str_strcmp(mailbox_path(np->mailbox), path) != 0) return NULL; return a; @@ -911,10 +911,10 @@ static int mbox_mbox_open(struct Mailbox *m) if (!adata) return -1; - adata->fp = fopen(mutt_b2s(m->pathbuf), "r+"); + adata->fp = fopen(mailbox_path(m), "r+"); if (!adata->fp) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } mutt_sig_block(); @@ -953,16 +953,16 @@ static int mbox_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags) if (!adata) return -1; - adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), (flags & MUTT_NEWFOLDER) ? "w" : "a"); + adata->fp = mutt_file_fopen(mailbox_path(m), (flags & MUTT_NEWFOLDER) ? "w" : "a"); if (!adata->fp) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } if (mbox_lock_mailbox(m, true, true) != false) { - mutt_error(_("Couldn't lock %s"), mutt_b2s(m->pathbuf)); + mutt_error(_("Couldn't lock %s"), mailbox_path(m)); mutt_file_fclose(&adata->fp); return -1; } @@ -1002,7 +1002,7 @@ static int mbox_mbox_check(struct Mailbox *m, int *index_hint) bool unlock = false; bool modified = false; - if (stat(mutt_b2s(m->pathbuf), &st) == 0) + if (stat(mailbox_path(m), &st) == 0) { if ((mutt_file_stat_timespec_compare(&st, MUTT_STAT_MTIME, &m->mtime) == 0) && (st.st_size == m->size)) @@ -1144,7 +1144,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) /* need to open the file for writing in such a way that it does not truncate * the file, so use read-write mode. */ - adata->fp = freopen(mutt_b2s(m->pathbuf), "r+", adata->fp); + adata->fp = freopen(mailbox_path(m), "r+", adata->fp); if (!adata->fp) { mx_fastclose_mailbox(m); @@ -1224,7 +1224,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) if (!m->quiet) { - snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count); } @@ -1308,9 +1308,9 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) fp = NULL; /* Save the state of this folder. */ - if (stat(mutt_b2s(m->pathbuf), &statbuf) == -1) + if (stat(mailbox_path(m), &statbuf) == -1) { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); unlink(tempfile); goto bail; } @@ -1392,7 +1392,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) mbox_reset_atime(m, &statbuf); /* reopen the mailbox in read-only mode */ - adata->fp = fopen(mutt_b2s(m->pathbuf), "r"); + adata->fp = fopen(mailbox_path(m), "r"); if (!adata->fp) { unlink(tempfile); @@ -1422,7 +1422,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) if (C_CheckMboxSize) { - struct Mailbox *m_tmp = mailbox_find(mutt_b2s(m->pathbuf)); + struct Mailbox *m_tmp = mailbox_find(mailbox_path(m)); if (m_tmp && !m_tmp->has_new) mailbox_update(m_tmp); } @@ -1453,7 +1453,7 @@ bail: /* Come here in case of disaster */ FREE(&new_offset); FREE(&old_offset); - adata->fp = freopen(mutt_b2s(m->pathbuf), "r", adata->fp); + adata->fp = freopen(mailbox_path(m), "r", adata->fp); if (!adata->fp) { mutt_error(_("Could not reopen mailbox")); @@ -1507,7 +1507,7 @@ static int mbox_mbox_close(struct Mailbox *m) struct utimbuf ut; ut.actime = adata->atime.tv_sec; ut.modtime = m->mtime.tv_sec; - utime(mutt_b2s(m->pathbuf), &ut); + utime(mailbox_path(m), &ut); #endif } @@ -1735,7 +1735,7 @@ static int mmdf_msg_padding_size(struct Mailbox *m) static int mbox_mbox_check_stats(struct Mailbox *m, int flags) { struct stat sb = { 0 }; - if (stat(mutt_b2s(m->pathbuf), &sb) != 0) + if (stat(mailbox_path(m), &sb) != 0) return -1; bool new_or_changed; diff --git a/mutt_mailbox.c b/mutt_mailbox.c index 037ae872b..726accb06 100644 --- a/mutt_mailbox.c +++ b/mutt_mailbox.c @@ -43,7 +43,7 @@ static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, int orig_flagged = m_check->msg_flagged; #endif - enum MailboxType mb_magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL); + enum MailboxType mb_magic = mx_path_probe(mailbox_path(m_check), NULL); switch (mb_magic) { @@ -58,10 +58,10 @@ static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, default: m_check->has_new = false; - if ((stat(mutt_b2s(m_check->pathbuf), &sb) != 0) || + if ((stat(mailbox_path(m_check), &sb) != 0) || (S_ISREG(sb.st_mode) && (sb.st_size == 0)) || ((m_check->magic == MUTT_UNKNOWN) && - ((m_check->magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL)) <= 0))) + ((m_check->magic = mx_path_probe(mailbox_path(m_check), NULL)) <= 0))) { /* if the mailbox still doesn't exist, set the newly created flag to be * ready for when it does. */ @@ -77,7 +77,7 @@ static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, if (!m_cur || mutt_buffer_is_empty(m_cur->pathbuf) || (((m_check->magic == MUTT_IMAP) || (m_check->magic == MUTT_NNTP) || (m_check->magic == MUTT_NOTMUCH) || (m_check->magic == MUTT_POP)) ? - (mutt_str_strcmp(mutt_b2s(m_check->pathbuf), mutt_b2s(m_cur->pathbuf)) != 0) : + (mutt_str_strcmp(mailbox_path(m_check), mailbox_path(m_cur)) != 0) : ((sb.st_dev != ctx_sb->st_dev) || (sb.st_ino != ctx_sb->st_ino)))) { switch (m_check->magic) @@ -161,7 +161,7 @@ int mutt_mailbox_check(struct Mailbox *m_cur, int force) #ifdef USE_NNTP || (m_cur->magic == MUTT_NNTP) #endif - || stat(mutt_b2s(m_cur->pathbuf), &contex_sb) != 0) + || stat(mailbox_path(m_cur), &contex_sb) != 0) { contex_sb.st_dev = 0; contex_sb.st_ino = 0; @@ -218,7 +218,7 @@ bool mutt_mailbox_list(void) if (!np->mailbox->has_new || (have_unnotified && np->mailbox->notified)) continue; - mutt_buffer_strcpy(path, mutt_b2s(np->mailbox->pathbuf)); + mutt_buffer_strcpy(path, mailbox_path(np->mailbox)); mutt_buffer_pretty_mailbox(path); if (!first && (MuttMessageWindow->cols >= 7) && @@ -306,11 +306,11 @@ void mutt_mailbox_next_buffer(struct Mailbox *m_cur, struct Buffer *s) mutt_buffer_expand_path(np->mailbox->pathbuf); if ((found || (pass > 0)) && np->mailbox->has_new) { - mutt_buffer_strcpy(s, mutt_b2s(np->mailbox->pathbuf)); + mutt_buffer_strcpy(s, mailbox_path(np->mailbox)); mutt_buffer_pretty_mailbox(s); return; } - if (mutt_str_strcmp(mutt_b2s(s), mutt_b2s(np->mailbox->pathbuf)) == 0) + if (mutt_str_strcmp(mutt_b2s(s), mailbox_path(np->mailbox)) == 0) found = true; } neomutt_mailboxlist_clear(&ml); diff --git a/mx.c b/mx.c index 3f7c80104..ee2f94ea4 100644 --- a/mx.c +++ b/mx.c @@ -194,7 +194,7 @@ static int mx_open_mailbox_append(struct Mailbox *m, OpenMailboxFlags flags) m->append = true; if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR)) { - m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL); + m->magic = mx_path_probe(mailbox_path(m), NULL); if (m->magic == MUTT_UNKNOWN) { @@ -204,14 +204,14 @@ static int mx_open_mailbox_append(struct Mailbox *m, OpenMailboxFlags flags) } else { - mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf)); + mutt_error(_("%s is not a mailbox"), mailbox_path(m)); return -1; } } if (m->magic == MUTT_MAILBOX_ERROR) { - if (stat(mutt_b2s(m->pathbuf), &sb) == -1) + if (stat(mailbox_path(m), &sb) == -1) { if (errno == ENOENT) { @@ -225,7 +225,7 @@ static int mx_open_mailbox_append(struct Mailbox *m, OpenMailboxFlags flags) } else { - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); return -1; } } @@ -324,16 +324,16 @@ struct Context *mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags) if (m->magic == MUTT_UNKNOWN) { - m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL); + m->magic = mx_path_probe(mailbox_path(m), NULL); m->mx_ops = mx_get_ops(m->magic); } if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR) || !m->mx_ops) { if (m->magic == MUTT_MAILBOX_ERROR) - mutt_perror(mutt_b2s(m->pathbuf)); + mutt_perror(mailbox_path(m)); else if ((m->magic == MUTT_UNKNOWN) || !m->mx_ops) - mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf)); + mutt_error(_("%s is not a mailbox"), mailbox_path(m)); mx_fastclose_mailbox(m); ctx_free(&ctx); @@ -349,7 +349,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags) OptForceRefresh = true; if (!m->quiet) - mutt_message(_("Reading %s..."), mutt_b2s(m->pathbuf)); + mutt_message(_("Reading %s..."), mailbox_path(m)); int rc = m->mx_ops->mbox_open(ctx->mailbox); m->opened++; @@ -369,7 +369,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags) mutt_clear_error(); if (rc == -2) { - mutt_error(_("Reading from %s interrupted..."), mutt_b2s(m->pathbuf)); + mutt_error(_("Reading from %s interrupted..."), mailbox_path(m)); mutt_sort_headers(ctx, true); } } @@ -436,14 +436,14 @@ static int sync_mailbox(struct Mailbox *m, int *index_hint) if (!m->quiet) { /* L10N: Displayed before/as a mailbox is being synced */ - mutt_message(_("Writing %s..."), mutt_b2s(m->pathbuf)); + mutt_message(_("Writing %s..."), mailbox_path(m)); } int rc = m->mx_ops->mbox_sync(m, index_hint); if ((rc != 0) && !m->quiet) { /* L10N: Displayed if a mailbox sync fails */ - mutt_error(_("Unable to write %s"), mutt_b2s(m->pathbuf)); + mutt_error(_("Unable to write %s"), mailbox_path(m)); } return rc; @@ -498,7 +498,7 @@ static int trash_append(struct Mailbox *m) return -1; } - if ((lstat(mutt_b2s(m->pathbuf), &stc) == 0) && (stc.st_ino == st.st_ino) && + if ((lstat(mailbox_path(m), &stc) == 0) && (stc.st_ino == st.st_ino) && (stc.st_dev == st.st_dev) && (stc.st_rdev == st.st_rdev)) { return 0; /* we are in the trash folder: simple sync */ @@ -615,7 +615,7 @@ int mx_mbox_close(struct Context **ptr) if ((read_msgs != 0) && (C_Move != MUTT_NO)) { bool is_spool; - char *p = mutt_find_hook(MUTT_MBOX_HOOK, mutt_b2s(m->pathbuf)); + char *p = mutt_find_hook(MUTT_MBOX_HOOK, mailbox_path(m)); if (p) { is_spool = true; @@ -624,7 +624,7 @@ int mx_mbox_close(struct Context **ptr) else { mutt_str_strfcpy(mbox, C_Mbox, sizeof(mbox)); - is_spool = mutt_is_spool(mutt_b2s(m->pathbuf)) && !mutt_is_spool(mbox); + is_spool = mutt_is_spool(mailbox_path(m)) && !mutt_is_spool(mbox); } if (is_spool && (mbox[0] != '\0')) @@ -740,7 +740,7 @@ int mx_mbox_close(struct Context **ptr) /* copy mails to the trash before expunging */ if (purge && (m->msg_deleted != 0) && - (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Trash) != 0)) + (mutt_str_strcmp(mailbox_path(m), C_Trash) != 0)) { if (trash_append(ctx->mailbox) != 0) return -1; @@ -788,9 +788,9 @@ int mx_mbox_close(struct Context **ptr) if ((m->msg_count == m->msg_deleted) && ((m->magic == MUTT_MMDF) || (m->magic == MUTT_MBOX)) && - !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty) + !mutt_is_spool(mailbox_path(m)) && !C_SaveEmpty) { - mutt_file_unlink_empty(mutt_b2s(m->pathbuf)); + mutt_file_unlink_empty(mailbox_path(m)); } #ifdef USE_SIDEBAR @@ -890,7 +890,7 @@ int mx_mbox_sync(struct Mailbox *m, int *index_hint) deleted = m->msg_deleted; if (purge && (m->msg_deleted != 0) && - (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Trash) != 0)) + (mutt_str_strcmp(mailbox_path(m), C_Trash) != 0)) { if (trash_append(m) != 0) return -1; @@ -921,9 +921,9 @@ int mx_mbox_sync(struct Mailbox *m, int *index_hint) if ((m->msg_count == m->msg_deleted) && ((m->magic == MUTT_MBOX) || (m->magic == MUTT_MMDF)) && - !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty) + !mutt_is_spool(mailbox_path(m)) && !C_SaveEmpty) { - unlink(mutt_b2s(m->pathbuf)); + unlink(mailbox_path(m)); mx_fastclose_mailbox(m); return 0; } @@ -1402,7 +1402,7 @@ int mx_path_canon2(struct Mailbox *m, const char *folder) if (m->realpath) mutt_str_strfcpy(buf, m->realpath, sizeof(buf)); else - mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf)); + mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf)); int rc = mx_path_canon(buf, sizeof(buf), folder, &m->magic); diff --git a/nntp/nntp.c b/nntp/nntp.c index 0e2b957c4..dbba5f865 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2425,12 +2425,12 @@ static int nntp_mbox_open(struct Mailbox *m) void *hc = NULL; anum_t first, last, count = 0; - struct Url *url = url_parse(mutt_b2s(m->pathbuf)); + struct Url *url = url_parse(mailbox_path(m)); if (!url || !url->host || !url->path || !((url->scheme == U_NNTP) || (url->scheme == U_NNTPS))) { url_free(&url); - mutt_error(_("%s is an invalid newsgroup specification"), mutt_b2s(m->pathbuf)); + mutt_error(_("%s is an invalid newsgroup specification"), mailbox_path(m)); return -1; } diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index ab2523160..6bd769e3c 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -92,7 +92,7 @@ char *C_NmRepliedTag; ///< Config: (notmuch) Tag to use for replied messages static header_cache_t *nm_hcache_open(struct Mailbox *m) { #ifdef USE_HCACHE - return mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL); + return mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL); #else return NULL; #endif @@ -306,7 +306,7 @@ static int init_mailbox(struct Mailbox *m) if (m->mdata) return 0; - m->mdata = nm_mdata_new(mutt_b2s(m->pathbuf)); + m->mdata = nm_mdata_new(mailbox_path(m)); if (!m->mdata) return -1; @@ -1938,10 +1938,10 @@ static int nm_mbox_check_stats(struct Mailbox *m, int flags) int limit = C_NmDbLimit; mutt_debug(LL_DEBUG1, "nm: count\n"); - url = url_parse(mutt_b2s(m->pathbuf)); + url = url_parse(mailbox_path(m)); if (!url) { - mutt_error(_("failed to parse notmuch uri: %s"), mutt_b2s(m->pathbuf)); + mutt_error(_("failed to parse notmuch uri: %s"), mailbox_path(m)); goto done; } @@ -2355,7 +2355,7 @@ static int nm_mbox_sync(struct Mailbox *m, int *index_hint) int rc = 0; struct Progress progress; - char *uri = mutt_str_strdup(mutt_b2s(m->pathbuf)); + char *uri = mutt_str_strdup(mailbox_path(m)); bool changed = false; mutt_debug(LL_DEBUG1, "nm: sync start\n"); @@ -2364,7 +2364,7 @@ static int nm_mbox_sync(struct Mailbox *m, int *index_hint) { char msgbuf[PATH_MAX + 64]; /* all is in this function so we don't use data->progress here */ - snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf)); + snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m)); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count); } diff --git a/pattern.c b/pattern.c index d7d54d767..aef8e53a3 100644 --- a/pattern.c +++ b/pattern.c @@ -306,7 +306,7 @@ static bool eat_query(struct Pattern *pat, int flags, struct Buffer *s, struct B } else { - char *escaped_folder = mutt_path_escape(mutt_b2s(Context->mailbox->pathbuf)); + char *escaped_folder = mutt_path_escape(mailbox_path(Context->mailbox)); mutt_debug(LL_DEBUG2, "escaped folder path: %s\n", escaped_folder); mutt_buffer_addch(&cmd_buf, '\''); mutt_buffer_addstr(&cmd_buf, escaped_folder); diff --git a/pop/pop.c b/pop/pop.c index e276be9b1..98db515b0 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -380,7 +380,7 @@ static int pop_fetch_headers(struct Mailbox *m) struct Progress progress; #ifdef USE_HCACHE - header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf)); + header_cache_t *hc = pop_hcache_open(adata, mailbox_path(m)); #endif time(&adata->check_time); @@ -785,7 +785,7 @@ int pop_ac_add(struct Account *a, struct Mailbox *m) a->adata = adata; a->free_adata = pop_adata_free; - struct Url *url = url_parse(mutt_b2s(m->pathbuf)); + struct Url *url = url_parse(mailbox_path(m)); if (!url) return 0; @@ -821,9 +821,9 @@ static int pop_mbox_open(struct Mailbox *m) struct ConnAccount acct = { { 0 } }; struct Url url; - if (pop_parse_path(mutt_b2s(m->pathbuf), &acct)) + if (pop_parse_path(mailbox_path(m), &acct)) { - mutt_error(_("%s is an invalid POP path"), mutt_b2s(m->pathbuf)); + mutt_error(_("%s is an invalid POP path"), mailbox_path(m)); return -1; } @@ -832,7 +832,7 @@ static int pop_mbox_open(struct Mailbox *m) url_tostring(&url, buf, sizeof(buf), 0); mutt_buffer_strcpy(m->pathbuf, buf); - mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf)); + mutt_str_replace(&m->realpath, mailbox_path(m)); struct PopAccountData *adata = m->account->adata; if (!adata) @@ -961,7 +961,7 @@ static int pop_mbox_sync(struct Mailbox *m, int *index_hint) MUTT_PROGRESS_MSG, C_WriteInc, num_deleted); #ifdef USE_HCACHE - hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf)); + hc = pop_hcache_open(adata, mailbox_path(m)); #endif for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++) @@ -1217,7 +1217,7 @@ static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e) #ifdef USE_HCACHE struct PopAccountData *adata = pop_adata_get(m); struct PopEmailData *edata = e->edata; - header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf)); + header_cache_t *hc = pop_hcache_open(adata, mailbox_path(m)); rc = mutt_hcache_store(hc, edata->uid, strlen(edata->uid), e, 0); mutt_hcache_close(hc); #endif diff --git a/sidebar.c b/sidebar.c index fb7f66f6c..c6d2c6de6 100644 --- a/sidebar.c +++ b/sidebar.c @@ -307,13 +307,13 @@ static int cb_qsort_sbe(const void *a, const void *b) { case SORT_COUNT: if (m2->msg_count == m1->msg_count) - rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf)); + rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2)); else rc = (m2->msg_count - m1->msg_count); break; case SORT_UNREAD: if (m2->msg_unread == m1->msg_unread) - rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf)); + rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2)); else rc = (m2->msg_unread - m1->msg_unread); break; @@ -322,15 +322,15 @@ static int cb_qsort_sbe(const void *a, const void *b) break; case SORT_FLAGGED: if (m2->msg_flagged == m1->msg_flagged) - rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf)); + rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2)); else rc = (m2->msg_flagged - m1->msg_flagged); break; case SORT_PATH: { - rc = mutt_inbox_cmp(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf)); + rc = mutt_inbox_cmp(mailbox_path(m1), mailbox_path(m2)); if (rc == 0) - rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf)); + rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2)); break; } } @@ -381,7 +381,7 @@ static void update_entries_visibility(void) continue; } - if (mutt_list_find(&SidebarWhitelist, mutt_b2s(sbe->mailbox->pathbuf)) || + if (mutt_list_find(&SidebarWhitelist, mailbox_path(sbe->mailbox)) || mutt_list_find(&SidebarWhitelist, sbe->mailbox->name)) { /* Explicitly asked to be visible */ @@ -847,7 +847,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) else if (m->msg_flagged > 0) SET_COLOR(MT_COLOR_FLAGGED); else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) && - (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Spoolfile) == 0)) + (mutt_str_strcmp(mailbox_path(m), C_Spoolfile) == 0)) { SET_COLOR(MT_COLOR_SB_SPOOLFILE); } @@ -881,8 +881,8 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) /* check whether C_Folder is a prefix of the current folder's path */ bool maildir_is_prefix = false; if ((mutt_buffer_len(m->pathbuf) > maildirlen) && - (mutt_str_strncmp(C_Folder, mutt_b2s(m->pathbuf), maildirlen) == 0) && C_SidebarDelimChars && - strchr(C_SidebarDelimChars, mutt_b2s(m->pathbuf)[maildirlen])) + (mutt_str_strncmp(C_Folder, mailbox_path(m), maildirlen) == 0) && C_SidebarDelimChars && + strchr(C_SidebarDelimChars, mailbox_path(m)[maildirlen])) { maildir_is_prefix = true; } @@ -894,7 +894,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) if (C_SidebarShortPath) { /* disregard a trailing separator, so strlen() - 2 */ - sidebar_folder_name = mutt_b2s(m->pathbuf); + sidebar_folder_name = mailbox_path(m); for (int i = mutt_str_strlen(sidebar_folder_name) - 2; i >= 0; i--) { if (C_SidebarDelimChars && strchr(C_SidebarDelimChars, sidebar_folder_name[i])) @@ -906,7 +906,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) } else if ((C_SidebarComponentDepth > 0) && C_SidebarDelimChars) { - sidebar_folder_name = mutt_b2s(m->pathbuf) + maildir_is_prefix * (maildirlen + 1); + sidebar_folder_name = mailbox_path(m) + maildir_is_prefix * (maildirlen + 1); for (int i = 0; i < C_SidebarComponentDepth; i++) { char *chars_after_delim = strpbrk(sidebar_folder_name, C_SidebarDelimChars); @@ -917,7 +917,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) } } else - sidebar_folder_name = mutt_b2s(m->pathbuf) + maildir_is_prefix * (maildirlen + 1); + sidebar_folder_name = mailbox_path(m) + maildir_is_prefix * (maildirlen + 1); if (m->name) { @@ -926,7 +926,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) else if (maildir_is_prefix && C_SidebarFolderIndent) { int lastsep = 0; - const char *tmp_folder_name = mutt_b2s(m->pathbuf) + maildirlen + 1; + const char *tmp_folder_name = mailbox_path(m) + maildirlen + 1; int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1; for (int i = 0; i < tmplen; i++) { diff --git a/status.c b/status.c index 310b3aaf8..7e7dc3582 100644 --- a/status.c +++ b/status.c @@ -154,7 +154,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c } else if (m && !mutt_buffer_is_empty(m->pathbuf)) { - mutt_str_strfcpy(tmp, mutt_b2s(m->pathbuf), sizeof(tmp)); + mutt_str_strfcpy(tmp, mailbox_path(m), sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp)); } else -- 2.40.0