var.c 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. void
  11. setvar(char *name, void *value)
  12. {
  13. symlook(name, S_VAR, value)->u.ptr = value;
  14. symlook(name, S_MAKEVAR, (void*)"");
  15. }
  16. static void
  17. print1(Symtab *s)
  18. {
  19. Word *w;
  20. Bprint(&bout, "\t%s=", s->name);
  21. for (w = s->u.ptr; w; w = w->next)
  22. Bprint(&bout, "'%s'", w->s);
  23. Bprint(&bout, "\n");
  24. }
  25. void
  26. dumpv(char *s)
  27. {
  28. Bprint(&bout, "%s:\n", s);
  29. symtraverse(S_VAR, print1);
  30. }
  31. char *
  32. shname(char *a)
  33. {
  34. Rune r;
  35. int n;
  36. while (*a) {
  37. n = chartorune(&r, a);
  38. if (!WORDCHR(r))
  39. break;
  40. a += n;
  41. }
  42. return a;
  43. }