Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cpp.ansi / 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 1.4 1994/06/24 11:37:29 ceriel Exp $ */
6
7 #include "file_info.h"
8 #include "input.h"
9
10 #define INP_PUSHBACK    3
11 #define INP_TYPE        struct file_info
12 #define INP_VAR         finfo
13 struct file_info        finfo;
14 #include <inp_pkg.body>
15 #include <alloc.h>
16
17 char *
18 getwdir(fn)
19         register char *fn;
20 {
21         register char *p;
22         char *strrindex();
23
24         p = strrindex(fn, '/');
25         while (p && *(p + 1) == '\0') { /* remove trailing /'s */
26                 *p = '\0';
27                 p = strrindex(fn, '/');
28         }
29
30         if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
31                 return "";
32         if (p) {
33                 *p = '\0';
34                 fn = Salloc(fn, (unsigned)(p - &fn[0] + 1));
35                 *p = '/';
36                 return fn;
37         }
38         return ".";
39 }
40
41 int     NoUnstack;
42 int     InputLevel;
43
44 AtEoIT()
45 {
46         InputLevel--;
47         /* if (NoUnstack) warning("unexpected EOF"); ??? */
48         unstackrepl();
49         return 0;
50 }
51
52 AtEoIF()
53 {
54         extern int nestlevel;
55         extern int nestcount;
56         extern int svnestlevel[];
57
58         if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
59         else if (NoUnstack) warning("unexpected EOF");
60         nestlevel = svnestlevel[nestcount--];
61         return 0;
62 }