-static int init_expand (char** dst, const char* src) {
- BUFFER token;
- BUFFER in;
-
- if (src && *src) {
- memset (&token, 0, sizeof (BUFFER));
- memset (&in, 0, sizeof (BUFFER));
- in.data = (char*) src;
- in.dptr = in.data;
- in.dsize = str_len (src);
- mutt_extract_token (&token, &in, M_TOKEN_SPACE);
- mem_free (dst);
- if (token.data && *token.data)
- *dst = str_dup (token.data);
- else
+static int init_expand (char** dst, struct option_t* src) {
+ BUFFER token, in;
+ size_t len = 0;
+
+ mem_free (dst);
+
+ if (DTYPE(src->type) == DT_STR ||
+ DTYPE(src->type) == DT_PATH) {
+ /* only expand for string as it's the only place where
+ * we want to expand vars right now */
+ if (src->init && *src->init) {
+ memset (&token, 0, sizeof (BUFFER));
+ memset (&in, 0, sizeof (BUFFER));
+ len = str_len (src->init) + 2;
+ in.data = mem_malloc (len+1);
+ snprintf (in.data, len, "\"%s\"", src->init);
+ in.dptr = in.data;
+ in.dsize = len;
+ mutt_extract_token (&token, &in, 0);
+ if (token.data && *token.data)
+ *dst = str_dup (token.data);
+ else
+ *dst = str_dup ("");
+ mem_free (&in.data);
+ mem_free (&token.data);
+ } else