- and --follow-tags.
-
- This function is as large as this only because of the glorious
- expressivity of the C programming language. */
-
- {
- int i, ind = 0;
- int size = ARRAY_SIZE (known_tags);
- interesting_tags = (const char **)xmalloc ((size + 1) * sizeof (char *));
-
- for (i = 0; i < size; i++)
- {
- const char *name = known_tags[i].name;
-
- /* Normally here we could say:
- interesting_tags[i] = name;
- But we need to respect the settings of --ignore-tags and
- --follow-tags, so the code gets a bit hairier. */
-
- if (opt.ignore_tags)
- {
- /* --ignore-tags was specified. Do not match these
- specific tags. --ignore-tags takes precedence over
- --follow-tags, so we process --ignore first and fall
- through if there's no match. */
- int j, lose = 0;
- for (j = 0; opt.ignore_tags[j] != NULL; j++)
- /* Loop through all the tags this user doesn't care about. */
- if (strcasecmp(opt.ignore_tags[j], name) == EQ)
- {
- lose = 1;
- break;
- }
- if (lose)
- continue;
- }
-
- if (opt.follow_tags)
- {
- /* --follow-tags was specified. Only match these specific tags, so
- continue back to top of for if we don't match one of them. */
- int j, win = 0;
- for (j = 0; opt.follow_tags[j] != NULL; j++)
- /* Loop through all the tags this user cares about. */
- if (strcasecmp(opt.follow_tags[j], name) == EQ)
- {
- win = 1;
- break;
- }
- if (!win)
- continue; /* wasn't one of the explicitly desired tags */
- }
-
- /* If we get to here, --follow-tags isn't being used or the
- tag is among the ones that are followed, and --ignore-tags,
- if specified, didn't include this tag, so it's an
- "interesting" one. */
- interesting_tags[ind++] = name;
- }
- interesting_tags[ind] = NULL;
- }
-
- /* The same for attributes, except we loop through tag_url_attributes.
- Here we also need to make sure that the list of attributes is
- unique, and to include the attributes from additional_attributes. */
- {
- int i, ind;
- const char **att = xmalloc ((ARRAY_SIZE (additional_attributes) + 1)
- * sizeof (char *));
- /* First copy the "additional" attributes. */
- for (i = 0; i < ARRAY_SIZE (additional_attributes); i++)
- att[i] = additional_attributes[i];
- ind = i;
- att[ind] = NULL;
- for (i = 0; i < ARRAY_SIZE (tag_url_attributes); i++)
- {
- int j, seen = 0;
- const char *look_for = tag_url_attributes[i].attr_name;
- for (j = 0; j < ind - 1; j++)
- if (!strcmp (att[j], look_for))
- {
- seen = 1;
- break;
- }
- if (!seen)
- {
- att = xrealloc (att, (ind + 2) * sizeof (*att));
- att[ind++] = look_for;
- att[ind] = NULL;
- }
- }
- interesting_attributes = att;
- }
-}