]> granicus.if.org Git - neomutt/commitdiff
Simplify body cache path creation
authorBrendan Cully <brendan@kublai.com>
Tue, 10 Apr 2007 23:22:08 +0000 (16:22 -0700)
committerBrendan Cully <brendan@kublai.com>
Tue, 10 Apr 2007 23:22:08 +0000 (16:22 -0700)
bcache.c
url.c
url.h

index 5b6d63ee6ad360a51177c3bf89486e508fe5ccb2..dbdc34672a81ae9f39588ff77936d8d578eb97ce 100644 (file)
--- 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 3e3c5a33ce24a0e3b35cb00c9446ce9f31f7a6b9..14a9024132a112c0ec184e832a7270eab93d6f71 100644 (file)
--- 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 cf9b4b462d1705973dea96c72bf9a0c8b4158f25..926416e743e369510f092d2f9136625eb70c9067 100644 (file)
--- 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
 {