1989-10-23 10:35:56 +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".
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1989-10-23 10:35:56 +00:00
|
|
|
|
2006-07-19 10:28:43 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1989-10-23 10:35:56 +00:00
|
|
|
#include "file_info.h"
|
|
|
|
#include "input.h"
|
2019-03-01 17:36:11 +00:00
|
|
|
#include "error.h"
|
|
|
|
#include "replace.h"
|
1989-10-23 10:35:56 +00:00
|
|
|
|
|
|
|
#define INP_PUSHBACK 3
|
|
|
|
#define INP_TYPE struct file_info
|
|
|
|
#define INP_VAR finfo
|
|
|
|
struct file_info finfo;
|
|
|
|
#include <inp_pkg.body>
|
1993-03-18 13:24:20 +00:00
|
|
|
#include <alloc.h>
|
1989-10-23 10:35:56 +00:00
|
|
|
|
2019-03-01 17:36:11 +00:00
|
|
|
char *getwdir(register char *fn)
|
1989-10-23 10:35:56 +00:00
|
|
|
{
|
|
|
|
register char *p;
|
2006-07-23 20:01:02 +00:00
|
|
|
char *strrchr();
|
1989-10-23 10:35:56 +00:00
|
|
|
|
2006-07-23 20:01:02 +00:00
|
|
|
p = strrchr(fn, '/');
|
1989-10-23 10:35:56 +00:00
|
|
|
while (p && *(p + 1) == '\0') { /* remove trailing /'s */
|
|
|
|
*p = '\0';
|
2006-07-23 20:01:02 +00:00
|
|
|
p = strrchr(fn, '/');
|
1989-10-23 10:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
|
|
|
|
return "";
|
|
|
|
if (p) {
|
|
|
|
*p = '\0';
|
1990-04-25 15:10:13 +00:00
|
|
|
fn = Salloc(fn, (unsigned)(p - &fn[0] + 1));
|
1989-10-23 10:35:56 +00:00
|
|
|
*p = '/';
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
return ".";
|
|
|
|
}
|
|
|
|
|
|
|
|
int NoUnstack;
|
|
|
|
int InputLevel;
|
|
|
|
|
2019-03-01 17:36:11 +00:00
|
|
|
int AtEoIT(void)
|
1989-10-23 10:35:56 +00:00
|
|
|
{
|
|
|
|
InputLevel--;
|
|
|
|
/* if (NoUnstack) warning("unexpected EOF"); ??? */
|
|
|
|
unstackrepl();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-01 17:36:11 +00:00
|
|
|
int AtEoIF(void)
|
1989-10-23 10:35:56 +00:00
|
|
|
{
|
|
|
|
extern int nestlevel;
|
|
|
|
extern int nestcount;
|
|
|
|
extern int svnestlevel[];
|
|
|
|
|
|
|
|
if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
|
|
|
|
else if (NoUnstack) warning("unexpected EOF");
|
|
|
|
nestlevel = svnestlevel[nestcount--];
|
|
|
|
return 0;
|
|
|
|
}
|