static bool rule_satisfiable(multiset_table *cmt, pp_linkset *ls) { unsigned int hashval; const char * t; char *name, *s; pp_linkset_node *p; int bad, n_subscripts; for (hashval = 0; hashval < ls->hash_table_size; hashval++) { for (p = ls->hash_table[hashval]; p!=NULL; p=p->next) { /* ok, we've got our hands on one of the criterion links */ name = strdupa(p->str); /* could actually use the string in place because we change it back */ /* now we want to see if we can satisfy this criterion link */ /* with a collection of the links in the cms table */ s = name; if (islower((int)*s)) s++; /* skip head-dependent indicator */ for (; isupper((int)*s); s++) {} for (;*s != '\0'; s++) if (*s != '*') *s = '#'; s = name; t = p->str; if (islower((int)*s)) s++; /* skip head-dependent indicator */ if (islower((int)*t)) t++; /* skip head-dependent indicator */ for (; isupper((int) *s); s++, t++) {} /* s and t remain in lockstep */ bad = 0; n_subscripts = 0; for (;*s != '\0' && bad==0; s++, t++) { if (*s == '*') continue; n_subscripts++; /* after the upper case part, and is not a * so must be a regular subscript */ *s = *t; if (!match_in_cms_table(cmt, name)) bad++; *s = '#'; } if (n_subscripts == 0) { /* now we handle the special case which occurs if there were 0 subscripts */ if (!match_in_cms_table(cmt, name)) bad++; } /* now if bad==0 this criterion link does the job to satisfy the needs of the trigger link */ if (bad == 0) return true; } } return false; }
static bool all_connectors_exist(multiset_table *cmt, const char *pp_link) { ppdebug("check PP-link=%s\n", pp_link); const char *s; for (s = pp_link; isupper(*s); s++) {} /* The first iteration of the next loop handles the special case * which occurs if there were 0 subscripts. */ do { ppdebug("subscript at %d\n", (int)(s-pp_link-strspn(pp_link, AtoZ))); if (*s == '#') continue; if (!match_in_cms_table(cmt, pp_link, s)) return false; } while (*s++ != '\0' && *s != '\0'); /* while characters still exist */ return true; }