#include "parse.h"
#include "redblack.h"
#include <gram.h>
+#include <errno.h>
/*
* Globals
key.name = name;
key.type = type;
if ((node = rbfind(aliases, &key)) != NULL) {
- /*
- * Compare the global sequence number with the one stored
- * in the alias. If they match then we've seen this alias
- * before and found a loop.
- */
- a = node->data;
- if (a->seqno == alias_seqno)
- return NULL;
- a->seqno = alias_seqno;
+ /*
+ * Compare the global sequence number with the one stored
+ * in the alias. If they match then we've seen this alias
+ * before and found a loop.
+ */
+ a = node->data;
+ if (a->seqno == alias_seqno) {
+ errno = ELOOP;
+ return NULL;
+ }
+ a->seqno = alias_seqno;
+ } else {
+ errno = ENOENT;
}
return a;
}
a->seqno = 0;
list2tq(&a->members, members);
if (rbinsert(aliases, a)) {
- snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
+ snprintf(errbuf, sizeof(errbuf), _("Alias `%s' already defined"), name);
alias_free(a);
return errbuf;
}
key.name = name;
key.type = type;
- if ((node = rbfind(aliases, &key)) == NULL)
+ if ((node = rbfind(aliases, &key)) == NULL) {
+ errno = ENOENT;
return NULL;
+ }
return rbdelete(aliases, node);
}