input.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 * getwdir(char *fn)
  17. {
  18. register char *p;
  19. char *strrchr();
  20. p = strrchr(fn, '/');
  21. while (p && *(p + 1) == '\0') { /* remove trailing /'s */
  22. *p = '\0';
  23. p = strrchr(fn, '/');
  24. }
  25. if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
  26. return "";
  27. else
  28. if (p) {
  29. *p = '\0';
  30. fn = Salloc(fn, p - &fn[0] + 1);
  31. *p = '/';
  32. return fn;
  33. }
  34. else return "";
  35. }
  36. int NoUnstack;
  37. int Unstacked;
  38. int InputLevel;
  39. AtEoIT()
  40. {
  41. /* if (NoUnstack) warning("unexpected EOF"); ??? */
  42. /* This is wrong; in an #elif, NoUnstack can be set, but you
  43. can still get calls to AtEoIT().
  44. */
  45. InputLevel--;
  46. DoUnstack();
  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. }