summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-03-30 19:00:38 -0700
committerKevin McCarthy <kevin@8t8.us>2020-03-31 12:09:28 -0700
commitb207c2807e97d1f3be9ff9ad04a232b0551bcc19 (patch)
tree10639cd29377d2a7f8ce3f1a8b79392bc7f91122 /imap
parent0d8257cbd33919fe0103a7c4b8c2317b5e9cf73d (diff)
Convert mutt_parse_rc_line() to use real buffer to hold the line.
Previously, the parameter converted into a kind of read-only buffer, pointing to the char *line passed in. The problem is that mutt_extract_token() backtick processing allocates and assigns a new token->data. As a result, buffer->destroy was added, whose sole purpose is to keep track of the read-only token buffer being reallocated so that it can be properly freed inside mutt_parse_rc_line(). (The char *line is allocated and freed in source_rc()). Remove the token parameter, and convert line to a const char *. Copy that into a buffer-pool buffer, so the buffer can be modified "normally". Create a mutt_buffer_rc_buffer() function taking the line buffer parameter. To make the source_rc() just a tiny bit faster, have it directly manage and call mutt_parse_rc_buffer() itself. Other callers likely don't need the speed, so remove their cumbersome creation/free of that parameter. The next commit will deal with removing buffer->destroy and fixing up backtick handling.
Diffstat (limited to 'imap')
-rw-r--r--imap/command.c6
-rw-r--r--imap/imap.c6
2 files changed, 4 insertions, 8 deletions
diff --git a/imap/command.c b/imap/command.c
index d35d7c59..37d4445b 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -989,7 +989,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
{
char buf[STRING];
char quoted_name[STRING];
- BUFFER err, token;
+ BUFFER err;
ciss_url_t url;
IMAP_LIST list;
@@ -1024,13 +1024,11 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
url.user = NULL;
url_ciss_tostring (&url, buf + 11, sizeof (buf) - 11, 0);
safe_strcat (buf, sizeof (buf), "\"");
- mutt_buffer_init (&token);
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
- if (mutt_parse_rc_line (buf, &token, &err))
+ if (mutt_parse_rc_line (buf, &err))
dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", err.data));
- FREE (&token.data);
FREE (&err.data);
}
diff --git a/imap/imap.c b/imap/imap.c
index c1a05e13..e19809a6 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2093,7 +2093,7 @@ int imap_subscribe (char *path, int subscribe)
char buf[LONG_STRING*2];
char mbox[LONG_STRING];
int mblen;
- BUFFER err, token;
+ BUFFER err;
IMAP_MBOX mx;
if (!mx_is_imap (path) || imap_parse_path (path, &mx) || !mx.mbox)
@@ -2110,7 +2110,6 @@ int imap_subscribe (char *path, int subscribe)
if (option (OPTIMAPCHECKSUBSCRIBED))
{
- mutt_buffer_init (&token);
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
@@ -2118,9 +2117,8 @@ int imap_subscribe (char *path, int subscribe)
subscribe ? "" : "un");
imap_quote_string_and_backquotes (mbox + mblen, sizeof(mbox) - mblen,
path);
- if (mutt_parse_rc_line (mbox, &token, &err))
+ if (mutt_parse_rc_line (mbox, &err))
dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", err.data));
- FREE (&token.data);
FREE (&err.data);
}