summaryrefslogtreecommitdiffstats
path: root/muttlib.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-09-19 18:52:24 -0700
committerKevin McCarthy <kevin@8t8.us>2019-09-19 19:14:03 -0700
commit192a6d0ebe7d303b5a340a5334ada58bd5e509a6 (patch)
treee4deaa91bcb4cea9065460fbb1fae14bbd002c74 /muttlib.c
parenta4b53e19ef471efc1938348d1623b811354f1c93 (diff)
Convert mutt_complete() to use the buffer pool.
Add helper functions mutt_buffer_substrcpy() and mutt_buffer_concatn_path(). Remove mutt_concatn_path() because mutt_complete() was the only caller.
Diffstat (limited to 'muttlib.c')
-rw-r--r--muttlib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/muttlib.c b/muttlib.c
index 08458cfe..78b43769 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -1275,6 +1275,22 @@ void mutt_buffer_concat_path (BUFFER *d, const char *dir, const char *fname)
mutt_buffer_printf (d, fmt, dir, fname);
}
+/*
+ * Write the concatened pathname (dir + "/" + fname) into dst.
+ * The slash is omitted when dir or fname is of 0 length.
+ */
+void mutt_buffer_concatn_path (BUFFER *dst, const char *dir, size_t dirlen,
+ const char *fname, size_t fnamelen)
+{
+ mutt_buffer_clear (dst);
+ if (dirlen)
+ mutt_buffer_addstr_n (dst, dir, dirlen);
+ if (dirlen && fnamelen)
+ mutt_buffer_addch (dst, '/');
+ if (fnamelen)
+ mutt_buffer_addstr_n (dst, fname, fnamelen);
+}
+
const char *mutt_getcwd (BUFFER *cwd)
{
char *retval;