arc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "mk.h"
  10. Arc *
  11. newarc(Node *n, Rule *r, char *stem, Resub *match)
  12. {
  13. Arc *a;
  14. a = (Arc *)Malloc(sizeof(Arc));
  15. a->n = n;
  16. a->r = r;
  17. a->stem = strdup(stem);
  18. rcopy(a->match, match, NREGEXP);
  19. a->next = 0;
  20. a->flag = 0;
  21. a->prog = r->prog;
  22. return(a);
  23. }
  24. void
  25. dumpa(char *s, Arc *a)
  26. {
  27. char buf[1024];
  28. Bprint(&bout, "%sArc@%p: n=%p r=%p flag=0x%x stem='%s'",
  29. s, a, a->n, a->r, a->flag, a->stem);
  30. if(a->prog)
  31. Bprint(&bout, " prog='%s'", a->prog);
  32. Bprint(&bout, "\n");
  33. if(a->n){
  34. snprint(buf, sizeof(buf), "%s ", (*s == ' ')? s:"");
  35. dumpn(buf, a->n);
  36. }
  37. }
  38. void
  39. nrep(void)
  40. {
  41. Symtab *sym;
  42. Word *w;
  43. sym = symlook("NREP", S_VAR, 0);
  44. if(sym){
  45. w = sym->u.ptr;
  46. if (w && w->s && *w->s)
  47. nreps = atoi(w->s);
  48. }
  49. if(nreps < 1)
  50. nreps = 1;
  51. if(DEBUG(D_GRAPH))
  52. Bprint(&bout, "nreps = %d\n", nreps);
  53. }