input.c 1.6 KB

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