input.c 1.5 KB

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