arc.c 826 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "mk.h"
  2. Arc *
  3. newarc(Node *n, Rule *r, char *stem, Resub *match)
  4. {
  5. Arc *a;
  6. a = (Arc *)Malloc(sizeof(Arc));
  7. a->n = n;
  8. a->r = r;
  9. a->stem = strdup(stem);
  10. rcopy(a->match, match, NREGEXP);
  11. a->next = 0;
  12. a->flag = 0;
  13. a->prog = r->prog;
  14. return(a);
  15. }
  16. void
  17. dumpa(char *s, Arc *a)
  18. {
  19. char buf[1024];
  20. Bprint(&bout, "%sArc@%p: n=%p r=%p flag=0x%x stem='%s'",
  21. s, a, a->n, a->r, a->flag, a->stem);
  22. if(a->prog)
  23. Bprint(&bout, " prog='%s'", a->prog);
  24. Bprint(&bout, "\n");
  25. if(a->n){
  26. snprint(buf, sizeof(buf), "%s ", (*s == ' ')? s:"");
  27. dumpn(buf, a->n);
  28. }
  29. }
  30. void
  31. nrep(void)
  32. {
  33. Symtab *sym;
  34. Word *w;
  35. sym = symlook("NREP", S_VAR, 0);
  36. if(sym){
  37. w = sym->u.ptr;
  38. if (w && w->s && *w->s)
  39. nreps = atoi(w->s);
  40. }
  41. if(nreps < 1)
  42. nreps = 1;
  43. if(DEBUG(D_GRAPH))
  44. Bprint(&bout, "nreps = %d\n", nreps);
  45. }