input.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "inputtype.h"
  7. #include "file_info.h"
  8. #include "input.h"
  9. #define INP_TYPE struct file_info
  10. #define INP_VAR finfo
  11. struct file_info finfo;
  12. extern int nestlevel;
  13. #include "nopp.h"
  14. #include <inp_pkg.body>
  15. #include <alloc.h>
  16. #include "dbsymtab.h"
  17. #ifndef NOPP
  18. #ifdef DBSYMTAB
  19. #include <stb.h>
  20. #include <em.h>
  21. extern int IncludeLevel;
  22. extern char options[];
  23. #endif
  24. char *
  25. getwdir(fn)
  26. register char *fn;
  27. {
  28. register char *p;
  29. char *strrindex();
  30. p = strrindex(fn, '/');
  31. while (p && *(p + 1) == '\0') { /* remove trailing /'s */
  32. *p = '\0';
  33. p = strrindex(fn, '/');
  34. }
  35. if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
  36. return "";
  37. if (p) {
  38. *p = '\0';
  39. fn = Salloc(fn, p - &fn[0] + 1);
  40. *p = '/';
  41. return fn;
  42. }
  43. return "";
  44. }
  45. int InputLevel;
  46. #endif /* NOPP */
  47. int NoUnstack;
  48. AtEoIT()
  49. {
  50. #ifndef NOPP
  51. /* if (NoUnstack) lexwarning("unexpected EOF"); ??? */
  52. DoUnstack();
  53. InputLevel--;
  54. #endif /* NOPP */
  55. return 0;
  56. }
  57. AtEoIF()
  58. {
  59. #ifndef NOPP
  60. if (nestlevel != nestlow) lexwarning("missing #endif");
  61. else
  62. #endif /* NOPP */
  63. if (NoUnstack) lexerror("unexpected EOF");
  64. #ifndef NOPP
  65. nestlevel = nestlow;
  66. #ifdef DBSYMTAB
  67. if (options['g'] && IncludeLevel > 0) {
  68. C_ms_stb_cst(FileName, N_EINCL, 0, (arith) 0);
  69. }
  70. IncludeLevel--;
  71. #endif
  72. #endif
  73. return 0;
  74. }