static Dtree *addstruct(Dtree *t, Node *pat, Node *val, Node ***cap, size_t *ncap) { Node *elt, *memb; Type *ty; size_t i, j; if (t->any) return t->any; for (i = 0; i < pat->expr.nargs; i++) { elt = pat->expr.args[i]; for (j = 0; j < t->nval; j++) { if (!strcmp(namestr(elt->expr.idx), namestr(t->val[j]->expr.idx))) { ty = exprtype(pat->expr.args[i]); memb = structmemb(val, elt->expr.idx, ty); t = addpat(t, pat->expr.args[i], memb, cap, ncap); break; } } } return t; }
static void hyphen_init(const char *patfile, const char *expfile) { pattern = trie_alloc(128); char buf[TOKLEN + 1]; FILE *fp = fopen(patfile, "r"); if (!fp) exit(error(ERR_IO, "can't access file: %s\n", patfile)); while (~fscanf(fp, "%s", buf)) addpat(buf); fclose(fp); if (!strcmp(expfile, "-")) return; if (!(fp = fopen(expfile, "r"))) exit(error(ERR_IO, "can't access file: %s\n", expfile)); while (~fscanf(fp, "%s", buf)) strcpy(except[nexp++], buf); fclose(fp); }