+ uselabel(root);
+}
+
+/*
+ * Find the label contained in the command l in the command linked
+ * list cp. L is excluded from the search. Return NULL if not found.
+ */
+static struct s_command *
+findlabel(l, cp)
+ struct s_command *l, *cp;
+{
+ struct s_command *r;
+
+ for (; cp; cp = cp->next) {
+ if (cp->code == ':' && cp != l && strcmp(l->t, cp->t) == 0)
+ return (cp);
+ if (cp->code == '{' && (r = findlabel(l, cp->u.c)))
+ return (r);
+ }
+ return (NULL);
+}
+
+/*
+ * Find any unused labels. This is because we want to warn the user if they
+ * accidentally put whitespace on a label name causing it be a different label
+ * than they intended.
+ */
+static void
+uselabel(cp)
+ struct s_command *cp;
+{
+ for (; cp; cp = cp->next) {
+ if (cp->code == ':' && cp->lused == 0)
+ err(WARNING, "unused label '%s'", cp->t);
+ if (cp->code == '{')
+ uselabel(cp->u.c);
+ }