input.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #include "file_info.h"
  7. #include "input.h"
  8. #define INP_TYPE struct file_info
  9. #define INP_VAR finfo
  10. struct file_info finfo;
  11. #include <inp_pkg.body>
  12. #include <alloc.h>
  13. char *
  14. getwdir(fn)
  15. char *fn;
  16. {
  17. register char *p;
  18. char *strrindex();
  19. p = strrindex(fn, '/');
  20. while (p && *(p + 1) == '\0') { /* remove trailing /'s */
  21. *p = '\0';
  22. p = strrindex(fn, '/');
  23. }
  24. if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
  25. return "";
  26. else
  27. if (p) {
  28. *p = '\0';
  29. fn = Salloc(fn, p - &fn[0] + 1);
  30. *p = '/';
  31. return fn;
  32. }
  33. else return "";
  34. }
  35. int NoUnstack;
  36. int Unstacked;
  37. int InputLevel;
  38. AtEoIT()
  39. {
  40. /* if (NoUnstack) warning("unexpected EOF"); ??? */
  41. /* This is wrong; in an #elif, NoUnstack can be set, but you
  42. can still get calls to AtEoIT().
  43. */
  44. InputLevel--;
  45. DoUnstack();
  46. return 0;
  47. }
  48. AtEoIF()
  49. {
  50. extern int nestlevel;
  51. extern int nestcount;
  52. extern int svnestlevel[];
  53. if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
  54. else if (NoUnstack) warning("unexpected EOF");
  55. nestlevel = svnestlevel[nestcount--];
  56. return 0;
  57. }