input.c 1.2 KB

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