input.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #define INP_PUSHBACK 3
  12. #define INP_TYPE struct file_info
  13. #define INP_VAR finfo
  14. struct file_info finfo;
  15. #include <inp_pkg.body>
  16. #include <alloc.h>
  17. char *
  18. getwdir(fn)
  19. register char *fn;
  20. {
  21. register char *p;
  22. char *strrchr();
  23. p = strrchr(fn, '/');
  24. while (p && *(p + 1) == '\0') { /* remove trailing /'s */
  25. *p = '\0';
  26. p = strrchr(fn, '/');
  27. }
  28. if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
  29. return "";
  30. if (p) {
  31. *p = '\0';
  32. fn = Salloc(fn, (unsigned)(p - &fn[0] + 1));
  33. *p = '/';
  34. return fn;
  35. }
  36. return ".";
  37. }
  38. int NoUnstack;
  39. int InputLevel;
  40. AtEoIT()
  41. {
  42. InputLevel--;
  43. /* if (NoUnstack) warning("unexpected EOF"); ??? */
  44. unstackrepl();
  45. return 0;
  46. }
  47. AtEoIF()
  48. {
  49. extern int nestlevel;
  50. extern int nestcount;
  51. extern int svnestlevel[];
  52. if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
  53. else if (NoUnstack) warning("unexpected EOF");
  54. nestlevel = svnestlevel[nestcount--];
  55. return 0;
  56. }