input.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <stdlib.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include "file_info.h"
  10. #include "input.h"
  11. #define INP_TYPE struct file_info
  12. #define INP_VAR finfo
  13. struct file_info finfo;
  14. #include <inp_pkg.body>
  15. #include <alloc.h>
  16. char *
  17. getwdir(fn)
  18. char *fn;
  19. {
  20. register char *p;
  21. char *strrchr();
  22. p = strrchr(fn, '/');
  23. while (p && *(p + 1) == '\0') { /* remove trailing /'s */
  24. *p = '\0';
  25. p = strrchr(fn, '/');
  26. }
  27. if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
  28. return "";
  29. else
  30. if (p) {
  31. *p = '\0';
  32. fn = Salloc(fn, p - &fn[0] + 1);
  33. *p = '/';
  34. return fn;
  35. }
  36. else return "";
  37. }
  38. int NoUnstack;
  39. int Unstacked;
  40. int InputLevel;
  41. AtEoIT()
  42. {
  43. /* if (NoUnstack) warning("unexpected EOF"); ??? */
  44. /* This is wrong; in an #elif, NoUnstack can be set, but you
  45. can still get calls to AtEoIT().
  46. */
  47. InputLevel--;
  48. DoUnstack();
  49. return 0;
  50. }
  51. AtEoIF()
  52. {
  53. extern int nestlevel;
  54. extern int nestcount;
  55. extern int svnestlevel[];
  56. if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
  57. else if (NoUnstack) warning("unexpected EOF");
  58. nestlevel = svnestlevel[nestcount--];
  59. return 0;
  60. }