ack/lang/cem/cemcom/input.c

87 lines
1.5 KiB
C
Raw Normal View History

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1994-06-24 14:02:31 +00:00
/* $Id$ */
1986-03-10 13:07:55 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "inputtype.h"
#include "file_info.h"
#include "input.h"
#define INP_TYPE struct file_info
#define INP_VAR finfo
struct file_info finfo;
extern int nestlevel;
#include "nopp.h"
1987-03-27 16:39:57 +00:00
#include <inp_pkg.body>
#include <alloc.h>
1986-03-10 13:07:55 +00:00
1991-11-08 15:12:28 +00:00
#include "dbsymtab.h"
1986-03-10 13:07:55 +00:00
#ifndef NOPP
1991-11-08 15:12:28 +00:00
#ifdef DBSYMTAB
#include <stb.h>
#include <em.h>
1991-11-08 15:12:28 +00:00
extern int IncludeLevel;
extern char options[];
#endif
char *
getwdir(fn)
register char *fn;
1986-03-10 13:07:55 +00:00
{
register char *p;
char *strrchr();
1986-03-10 13:07:55 +00:00
p = strrchr(fn, '/');
1986-03-10 13:07:55 +00:00
while (p && *(p + 1) == '\0') { /* remove trailing /'s */
*p = '\0';
p = strrchr(fn, '/');
1986-03-10 13:07:55 +00:00
}
if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
return "";
1986-03-10 13:07:55 +00:00
if (p) {
*p = '\0';
fn = Salloc(fn, p - &fn[0] + 1);
1986-03-10 13:07:55 +00:00
*p = '/';
return fn;
1986-03-10 13:07:55 +00:00
}
return "";
1986-03-10 13:07:55 +00:00
}
int InputLevel;
#endif /* NOPP */
1986-03-10 13:07:55 +00:00
int NoUnstack;
AtEoIT()
1986-03-10 13:07:55 +00:00
{
#ifndef NOPP
/* if (NoUnstack) lexwarning("unexpected EOF"); ??? */
DoUnstack();
InputLevel--;
#endif /* NOPP */
return 0;
}
1986-03-10 13:07:55 +00:00
AtEoIF()
{
1987-08-07 19:53:54 +00:00
#ifndef NOPP
if (nestlevel != nestlow) lexwarning("missing #endif");
1987-08-07 19:53:54 +00:00
else
#endif /* NOPP */
1988-05-02 15:37:13 +00:00
if (NoUnstack) lexerror("unexpected EOF");
#ifndef NOPP
nestlevel = nestlow;
1991-11-08 15:12:28 +00:00
#ifdef DBSYMTAB
if (options['g'] && IncludeLevel > 0) {
C_ms_stb_cst(FileName, N_EINCL, 0, (arith) 0);
1991-11-08 15:12:28 +00:00
}
IncludeLevel--;
#endif
1988-05-02 15:37:13 +00:00
#endif
return 0;
1986-03-10 13:07:55 +00:00
}