]> granicus.if.org Git - neomutt/commitdiff
Convert parse_path_(un)list to use buffer pool for path
authorKevin McCarthy <kevin@8t8.us>
Tue, 8 Oct 2019 05:07:40 +0000 (13:07 +0800)
committerRichard Russon <rich@flatcap.org>
Tue, 8 Oct 2019 16:43:58 +0000 (17:43 +0100)
Don't use the buf parameter to avoid stretching it out, as it's used
for the entire rc parsing, and typically just holds command names.

Co-authored-by: Richard Russon <rich@flatcap.org>
init.c

diff --git a/init.c b/init.c
index bcac0a9d80a5659f25df2af3e73afb4264a84ed6..d621d9d43de1dd3fb5602042d2f2c8465fb4f9ca 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1453,15 +1453,15 @@ static enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s,
 static enum CommandResult parse_path_list(struct Buffer *buf, struct Buffer *s,
                                           unsigned long data, struct Buffer *err)
 {
-  char path[PATH_MAX];
+  struct Buffer *path = mutt_buffer_pool_get();
 
   do
   {
-    mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
-    mutt_str_strfcpy(path, buf->data, sizeof(path));
-    mutt_expand_path(path, sizeof(path));
-    add_to_stailq((struct ListHead *) data, path);
+    mutt_extract_token(path, s, MUTT_TOKEN_NO_FLAGS);
+    mutt_buffer_expand_path(path);
+    add_to_stailq((struct ListHead *) data, mutt_b2s(path));
   } while (MoreArgs(s));
+  mutt_buffer_pool_release(&path);
 
   return MUTT_CMD_SUCCESS;
 }
@@ -1474,21 +1474,21 @@ static enum CommandResult parse_path_list(struct Buffer *buf, struct Buffer *s,
 static enum CommandResult parse_path_unlist(struct Buffer *buf, struct Buffer *s,
                                             unsigned long data, struct Buffer *err)
 {
-  char path[PATH_MAX];
+  struct Buffer *path = mutt_buffer_pool_get();
 
   do
   {
-    mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
+    mutt_extract_token(path, s, MUTT_TOKEN_NO_FLAGS);
     /* Check for deletion of entire list */
-    if (mutt_str_strcmp(buf->data, "*") == 0)
+    if (mutt_str_strcmp(mutt_b2s(path), "*") == 0)
     {
       mutt_list_free((struct ListHead *) data);
       break;
     }
-    mutt_str_strfcpy(path, buf->data, sizeof(path));
-    mutt_expand_path(path, sizeof(path));
-    remove_from_stailq((struct ListHead *) data, path);
+    mutt_buffer_expand_path(path);
+    remove_from_stailq((struct ListHead *) data, mutt_b2s(path));
   } while (MoreArgs(s));
+  mutt_buffer_pool_release(&path);
 
   return MUTT_CMD_SUCCESS;
 }