static int
_string_list_contains (string_list_t *list, const char *member, int *index);
+static const char *
+_string_list_has_duplicate (string_list_t *list);
+
static int
_string_list_length (string_list_t *list);
return 0;
}
+/* Return duplicate string in list (if any), NULL otherwise. */
+const char *
+_string_list_has_duplicate (string_list_t *list)
+{
+ string_node_t *node, *dup;
+
+ if (list == NULL)
+ return NULL;
+
+ for (node = list->head; node; node = node->next) {
+ for (dup = node->next; dup; dup = dup->next) {
+ if (strcmp (node->str, dup->str) == 0)
+ return node->str;
+ }
+ }
+
+ return NULL;
+}
+
int
_string_list_length (string_list_t *list)
{
token_list_t *replacements)
{
macro_t *macro, *previous;
+ const char *dup;
_check_for_reserved_macro_name(parser, loc, identifier);
+ /* Check for any duplicate parameter names. */
+ if ((dup = _string_list_has_duplicate (parameters)) != NULL) {
+ glcpp_error (loc, parser, "Duplicate macro parameter \"%s\"",
+ dup);
+ }
+
macro = ralloc (parser, macro_t);
ralloc_steal (macro, parameters);
ralloc_steal (macro, replacements);