From 862a44f79841c7fbc1e6c59a3a1f01b73164bfa1 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 13 Nov 2018 02:02:02 +0000 Subject: [PATCH] path_canon: drop folder --- compress.c | 11 +---------- imap/imap.c | 21 +-------------------- imap/imap.h | 2 +- maildir/mh.c | 11 +---------- mbox/mbox.c | 11 +---------- muttlib.c | 2 +- mx.c | 4 ++-- mx.h | 3 +-- nntp/nntp.c | 19 +------------------ notmuch/mutt_notmuch.c | 19 +------------------ pop/pop.c | 19 +------------------ 11 files changed, 12 insertions(+), 110 deletions(-) diff --git a/compress.c b/compress.c index 997b0d6ee..0300b098f 100644 --- a/compress.c +++ b/compress.c @@ -941,20 +941,11 @@ enum MailboxType comp_path_probe(const char *path, const struct stat *st) /** * comp_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int comp_path_canon(char *buf, size_t buflen, const char *folder) +int comp_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - mutt_path_canon(buf, buflen, HomeDir); return 0; } diff --git a/imap/imap.c b/imap/imap.c index dfb0db7bc..ca8ad20d5 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2821,30 +2821,11 @@ enum MailboxType imap_path_probe(const char *path, const struct stat *st) /** * imap_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int imap_path_canon(char *buf, size_t buflen, const char *folder) +int imap_path_canon(char *buf, size_t buflen) { if (!buf) return -1; -#if 0 - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - size_t flen = mutt_str_strlen(folder); - if ((flen > 0) && (folder[flen - 1] != '/')) - { - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - else - { - mutt_str_inline_replace(buf, buflen, 1, folder); - } - } -#endif - struct Url url; char tmp[PATH_MAX]; char tmp2[PATH_MAX]; diff --git a/imap/imap.h b/imap/imap.h index 40ad29968..85f740981 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -96,7 +96,7 @@ int imap_subscribe(char *path, bool subscribe); int imap_complete(char *buf, size_t buflen, char *path); int imap_fast_trash(struct Mailbox *m, char *dest); int imap_path_probe(const char *path, const struct stat *st); -int imap_path_canon(char *buf, size_t buflen, const char *folder); +int imap_path_canon(char *buf, size_t buflen); extern struct MxOps mx_imap_ops; diff --git a/maildir/mh.c b/maildir/mh.c index 02dcb0435..a1f5ecd0c 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -2747,20 +2747,11 @@ enum MailboxType maildir_path_probe(const char *path, const struct stat *st) /** * maildir_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int maildir_path_canon(char *buf, size_t buflen, const char *folder) +int maildir_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - mutt_path_canon(buf, buflen, HomeDir); return 0; } diff --git a/mbox/mbox.c b/mbox/mbox.c index 3963a866a..492a52944 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1714,20 +1714,11 @@ enum MailboxType mbox_path_probe(const char *path, const struct stat *st) /** * mbox_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int mbox_path_canon(char *buf, size_t buflen, const char *folder) +int mbox_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - mutt_path_canon(buf, buflen, HomeDir); return 0; } diff --git a/muttlib.c b/muttlib.c index cfe490cfd..aa06d981f 100644 --- a/muttlib.c +++ b/muttlib.c @@ -294,7 +294,7 @@ char *mutt_expand_path_regex(char *buf, size_t buflen, bool regex) /* Rewrite IMAP path in canonical form - aids in string comparisons of * folders. May possibly fail, in which case buf should be the same. */ if (imap_path_probe(buf, NULL) == MUTT_IMAP) - imap_path_canon(buf, buflen, NULL); + imap_path_canon(buf, buflen); #endif return buf; diff --git a/mx.c b/mx.c index 518a2d34b..00f14e711 100644 --- a/mx.c +++ b/mx.c @@ -1558,7 +1558,7 @@ int mx_path_canon(char *buf, size_t buflen, const char *folder, enum MailboxType if (!ops || !ops->path_canon) return -1; - if (ops->path_canon(buf, buflen, folder) < 0) + if (ops->path_canon(buf, buflen) < 0) { mutt_path_canon(buf, buflen, HomeDir); } @@ -1602,7 +1602,7 @@ int mx_path_pretty(char *buf, size_t buflen, const char *folder) if (!ops->path_canon) return -1; - if (ops->path_canon(buf, buflen, folder) < 0) + if (ops->path_canon(buf, buflen) < 0) return -1; if (!ops->path_pretty) diff --git a/mx.h b/mx.h index 8c1bfe98b..e122c07e7 100644 --- a/mx.h +++ b/mx.h @@ -227,11 +227,10 @@ struct MxOps * path_canon - Canonicalise a mailbox path * @param buf Path to modify * @param buflen Length of buffer - * @param folder Base path for '=' substitution * @retval 0 Success * @retval -1 Failure */ - int (*path_canon) (char *buf, size_t buflen, const char *folder); + int (*path_canon) (char *buf, size_t buflen); /** * path_pretty - Abbreviate a mailbox path * @param buf Path to modify diff --git a/nntp/nntp.c b/nntp/nntp.c index 90debff4c..439b8cddf 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2877,28 +2877,11 @@ enum MailboxType nntp_path_probe(const char *path, const struct stat *st) /** * nntp_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int nntp_path_canon(char *buf, size_t buflen, const char *folder) +int nntp_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - size_t flen = mutt_str_strlen(folder); - if ((flen > 0) && (folder[flen - 1] != '/')) - { - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - else - { - mutt_str_inline_replace(buf, buflen, 1, folder); - } - } - return 0; } diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 8ba77351e..4bee6bd87 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -2544,28 +2544,11 @@ enum MailboxType nm_path_probe(const char *path, const struct stat *st) /** * nm_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int nm_path_canon(char *buf, size_t buflen, const char *folder) +int nm_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - size_t flen = mutt_str_strlen(folder); - if ((flen > 0) && (folder[flen - 1] != '/')) - { - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - else - { - mutt_str_inline_replace(buf, buflen, 1, folder); - } - } - return 0; } diff --git a/pop/pop.c b/pop/pop.c index e0c029dcd..9889f00e5 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -1257,28 +1257,11 @@ enum MailboxType pop_path_probe(const char *path, const struct stat *st) /** * pop_path_canon - Canonicalise a mailbox path - Implements MxOps::path_canon() */ -int pop_path_canon(char *buf, size_t buflen, const char *folder) +int pop_path_canon(char *buf, size_t buflen) { if (!buf) return -1; - if ((buf[0] == '+') || (buf[0] == '=')) - { - if (!folder) - return -1; - - size_t flen = mutt_str_strlen(folder); - if ((flen > 0) && (folder[flen - 1] != '/')) - { - buf[0] = '/'; - mutt_str_inline_replace(buf, buflen, 0, folder); - } - else - { - mutt_str_inline_replace(buf, buflen, 1, folder); - } - } - return 0; } -- 2.40.0