summaryrefslogtreecommitdiffstats
path: root/commands.c
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 /commands.c
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 'commands.c')
-rw-r--r--commands.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/commands.c b/commands.c
index 3e847fee..32bbe026 100644
--- a/commands.c
+++ b/commands.c
@@ -737,7 +737,7 @@ void mutt_shell_escape (void)
/* enter a mutt command */
void mutt_enter_command (void)
{
- BUFFER err, token;
+ BUFFER err;
char buffer[LONG_STRING];
int r;
@@ -747,9 +747,7 @@ void mutt_enter_command (void)
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
- mutt_buffer_init (&token);
- r = mutt_parse_rc_line (buffer, &token, &err);
- FREE (&token.data);
+ r = mutt_parse_rc_line (buffer, &err);
if (err.data[0])
{
/* since errbuf could potentially contain printf() sequences in it,