return r;
}
-/* Stack structure
- * FILO designed to contain the list of config files that have been sourced
- * and avoid cyclic sourcing */
-static struct List *MuttrcStack;
+/* FILO designed to contain the list of config files that have been sourced and
+ * avoid cyclic sourcing */
+static struct STailQHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack);
/**
* to_absolute_path - Convert relative filepath to an absolute path
if (rcfile[rcfilelen - 1] != '|')
{
- if (!to_absolute_path(rcfile, mutt_front_list(MuttrcStack)))
+ struct STailQNode *np = STAILQ_FIRST(&MuttrcStack);
+ if (!to_absolute_path(rcfile, np ? NONULL(np->data) : ""))
{
mutt_error("Error: impossible to build path of '%s'.", rcfile_path);
return -1;
}
- if (!MuttrcStack || mutt_find_list(MuttrcStack, rcfile) == NULL)
+ STAILQ_FOREACH(np, &MuttrcStack, entries)
{
- mutt_push_list(&MuttrcStack, rcfile);
+ if (mutt_strcmp(np->data, rcfile) == 0)
+ {
+ break;
+ }
+ }
+ if (!np)
+ {
+ np = safe_calloc(1, sizeof(struct STailQNode));
+ np->data = safe_strdup(rcfile);
+ STAILQ_INSERT_HEAD(&MuttrcStack, np, entries);
}
else
{
}
}
- mutt_pop_list(&MuttrcStack);
+ if (!STAILQ_EMPTY(&MuttrcStack))
+ {
+ STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
+ }
return rc;
}
struct STailQNode *mutt_find_stailq(struct STailQHead *h, const char *data);
int mutt_remove_from_rx_list(struct RxList **l, const char *str);
-/* handle stack */
-void mutt_push_list(struct List **head, const char *data);
-bool mutt_pop_list(struct List **head);
-const char *mutt_front_list(struct List *head);
-
void mutt_init(int skip_sys_rc, struct List *commands);
/* flag to mutt_pattern_comp() */
return NULL;
}
-void mutt_push_list(struct List **head, const char *data)
-{
- struct List *tmp = NULL;
- tmp = safe_malloc(sizeof(struct List));
- tmp->data = safe_strdup(data);
- tmp->next = *head;
- *head = tmp;
-}
-
-bool mutt_pop_list(struct List **head)
-{
- struct List *elt = *head;
- if (!elt)
- return false;
- *head = elt->next;
- FREE(&elt->data);
- FREE(&elt);
- return true;
-}
-
-const char *mutt_front_list(struct List *head)
-{
- if (!head || !head->data)
- return "";
- return head->data;
-}
-
int mutt_remove_from_rx_list(struct RxList **l, const char *str)
{
struct RxList *p = NULL, *last = NULL;