ack/lang/cem/cemcom.ansi/input.c

88 lines
1.5 KiB
C
Raw Normal View History

1989-02-07 11:04:05 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#include "inputtype.h"
#include "file_info.h"
#include "input.h"
#define INP_PUSHBACK 3
#define INP_TYPE struct file_info
#define INP_VAR finfo
struct file_info finfo;
#include "nopp.h"
#include <inp_pkg.body>
#include <alloc.h>
1989-02-07 11:04:05 +00:00
#include "dbsymtab.h"
1989-02-07 11:04:05 +00:00
#ifndef NOPP
#ifdef DBSYMTAB
#include <stb.h>
extern int IncludeLevel;
extern char options[];
#endif
1989-02-07 11:04:05 +00:00
char *
getwdir(fn)
register char *fn;
{
register char *p;
char *strrindex();
p = strrindex(fn, '/');
while (p && *(p + 1) == '\0') { /* remove trailing /'s */
*p = '\0';
p = strrindex(fn, '/');
}
if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
return "";
if (p) {
*p = '\0';
fn = Salloc(fn,(unsigned) (p - &fn[0] + 1));
1989-02-07 11:04:05 +00:00
*p = '/';
return fn;
}
return "";
1989-02-07 11:04:05 +00:00
}
int InputLevel;
extern int nestlevel;
#endif /* NOPP */
1989-02-07 11:04:05 +00:00
int NoUnstack;
AtEoIT()
{
#ifndef NOPP
InputLevel--;
1989-02-07 11:04:05 +00:00
unstackrepl();
#endif /* NOPP */
1989-02-07 11:04:05 +00:00
return 0;
}
1993-01-18 15:10:01 +00:00
extern char *source;
1989-02-07 11:04:05 +00:00
AtEoIF()
{
#ifndef NOPP
if (nestlevel != nestlow) lexwarning("missing #endif");
else
#endif /* NOPP */
1989-02-07 11:04:05 +00:00
if (NoUnstack) lexerror("unexpected EOF");
#ifndef NOPP
nestlevel = nestlow;
#ifdef DBSYMTAB
if (options['g'] && IncludeLevel > 0) {
C_ms_std(FileName, N_EINCL, 0);
}
IncludeLevel--;
1989-02-07 11:04:05 +00:00
#endif
#endif /* NOPP */
1993-01-18 15:10:01 +00:00
if (WorkingDir[0] != '\0') free(WorkingDir);
if (FileName != source) free(FileName);
1989-02-07 11:04:05 +00:00
return 0;
}