Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cemcom / input.c
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: input.c,v 3.24 1994/06/24 12:04:09 ceriel Exp $ */
6
7 #include "inputtype.h"
8 #include "file_info.h"
9 #include "input.h"
10 #define INP_TYPE        struct file_info
11 #define INP_VAR         finfo
12 struct file_info        finfo;
13 extern int              nestlevel;
14 #include "nopp.h"
15 #include <inp_pkg.body>
16 #include <alloc.h>
17
18 #include        "dbsymtab.h"
19 #ifndef NOPP
20 #ifdef DBSYMTAB
21 #include <stb.h>
22 #include <em.h>
23 extern int      IncludeLevel;
24 extern char     options[];
25 #endif
26 char *
27 getwdir(fn)
28         register char *fn;
29 {
30         register char *p;
31         char *strrindex();
32
33         p = strrindex(fn, '/');
34         while (p && *(p + 1) == '\0') { /* remove trailing /'s */
35                 *p = '\0';
36                 p = strrindex(fn, '/');
37         }
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, p - &fn[0] + 1);
44                 *p = '/';
45                 return fn;
46         }
47         return "";
48 }
49
50 int     InputLevel;
51 #endif /* NOPP */
52
53 int     NoUnstack;
54
55 AtEoIT()
56 {
57 #ifndef NOPP
58         /* if (NoUnstack) lexwarning("unexpected EOF"); ??? */
59         DoUnstack();
60         InputLevel--;
61 #endif /* NOPP */
62         return 0;
63 }
64
65 AtEoIF()
66 {
67 #ifndef NOPP
68
69         if (nestlevel != nestlow) lexwarning("missing #endif");
70         else
71 #endif /* NOPP */
72         if (NoUnstack) lexerror("unexpected EOF");
73 #ifndef NOPP
74         nestlevel = nestlow;
75 #ifdef DBSYMTAB
76         if (options['g'] && IncludeLevel > 0) {
77                 C_ms_stb_cst(FileName, N_EINCL, 0, (arith) 0);
78         }
79         IncludeLevel--;
80 #endif
81 #endif
82         return 0;
83 }