From 5f383768c2ecd0aa545f1dea727173a3558d32fa Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 7 Apr 2019 16:02:02 -0700 Subject: [PATCH] Create mutt_buffer_mailbox() buffer function Relocate some of the buffy function declarations to mailbox.h while adding the new declaration. Co-authored-by: Richard Russon --- mailbox.c | 34 ++++++++++++++++++++++++++-------- mailbox.h | 1 + 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mailbox.c b/mailbox.c index eb187ecfb..f759c8e5f 100644 --- a/mailbox.c +++ b/mailbox.c @@ -481,16 +481,15 @@ bool mutt_mailbox_notify(struct Mailbox *m_cur) } /** - * mutt_mailbox - incoming folders completion routine + * mutt_buffer_mailbox - incoming folders completion routine * @param m_cur Current Mailbox * @param s Buffer containing name of current mailbox - * @param slen Buffer length * * Given a folder name, find the next incoming folder with new mail. */ -void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen) +void mutt_buffer_mailbox(struct Mailbox *m_cur, struct Buffer *s) { - mutt_expand_path(s, slen); + mutt_buffer_expand_path(s); if (mutt_mailbox_check(m_cur, 0)) { @@ -505,11 +504,11 @@ void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen) mutt_expand_path(np->mailbox->path, sizeof(np->mailbox->path)); if ((found || pass) && np->mailbox->has_new) { - mutt_str_strfcpy(s, np->mailbox->path, slen); - mutt_pretty_mailbox(s, slen); + mutt_buffer_strcpy(s, np->mailbox->path); + mutt_buffer_pretty_mailbox(s); return; } - if (mutt_str_strcmp(s, np->mailbox->path) == 0) + if (mutt_str_strcmp(mutt_b2s(s), np->mailbox->path) == 0) found = 1; } } @@ -518,7 +517,26 @@ void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen) } /* no folders with new mail */ - *s = '\0'; + mutt_buffer_reset(s); +} + +/** + * mutt_mailbox - incoming folders completion routine + * @param m_cur Current Mailbox + * @param s Buffer containing name of current mailbox + * @param slen Buffer length + * + * Given a folder name, find the next incoming folder with new mail. + */ +void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen) +{ + struct Buffer *s_buf = mutt_buffer_pool_get(); + + mutt_buffer_addstr(s_buf, NONULL(s)); + mutt_buffer_mailbox(m_cur, s_buf); + mutt_str_strfcpy(s, mutt_b2s(s_buf), slen); + + mutt_buffer_pool_release(&s_buf); } /** diff --git a/mailbox.h b/mailbox.h index 00126eae3..e2a544364 100644 --- a/mailbox.h +++ b/mailbox.h @@ -170,6 +170,7 @@ void mutt_mailbox_setnotified(struct Mailbox *m); #define MUTT_MAILBOX_CHECK_FORCE (1 << 0) #define MUTT_MAILBOX_CHECK_FORCE_STATS (1 << 1) +void mutt_buffer_mailbox(struct Mailbox *m_cur, struct Buffer *s); void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen); bool mutt_mailbox_list(void); int mutt_mailbox_check(struct Mailbox *m_cur, int force); -- 2.40.0