From 46c0a7cc253c97761bc36c2aa02f588de586192d Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Tue, 10 Apr 2007 16:22:08 -0700 Subject: [PATCH] Simplify body cache path creation --- bcache.c | 9 +-------- url.c | 3 ++- url.h | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bcache.c b/bcache.c index 5b6d63ee6..dbdc34672 100644 --- a/bcache.c +++ b/bcache.c @@ -57,7 +57,7 @@ static int bcache_path(ACCOUNT *account, const char *mailbox, * if this ever changes, we have a memleak here */ url.path = NULL; - if (url_ciss_tostring (&url, host, sizeof (host), 0) < 0) + if (url_ciss_tostring (&url, host, sizeof (host), U_PATH) < 0) { dprint (1, (debugfile, "bcache_path: URL to string failed\n")); return -1; @@ -65,13 +65,6 @@ static int bcache_path(ACCOUNT *account, const char *mailbox, dprint (3, (debugfile, "bcache_path: URL: '%s'\n", host)); - /* transform URL scheme:// to scheme: */ - for (s = p = host; *s; s++) - /* keep trailing slash */ - if (*s != '/' || *(s + 1) == '\0') - *p++ = *s; - *p = '\0'; - len = snprintf (dst, dstlen-1, "%s/%s%s%s", MessageCachedir, host, NONULL(mailbox), (mailbox && *mailbox && diff --git a/url.c b/url.c index 3e3c5a33c..14a902413 100644 --- a/url.c +++ b/url.c @@ -184,7 +184,8 @@ int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags) if (ciss->host) { - safe_strcat (dest, len, "//"); + if (!(flags & U_PATH)) + safe_strcat (dest, len, "//"); len -= (l = strlen (dest)); dest += l; if (ciss->user) { diff --git a/url.h b/url.h index cf9b4b462..926416e74 100644 --- a/url.h +++ b/url.h @@ -16,6 +16,7 @@ typedef enum url_scheme url_scheme_t; #define U_DECODE_PASSWD (1) +#define U_PATH (1 << 1) typedef struct ciss_url { -- 2.50.1