input.c 1.6 KB

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