1987-03-10 11:49:39 +00:00
|
|
|
/* $Header$ */
|
1987-03-09 19:15:41 +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".
|
|
|
|
*/
|
1986-10-20 14:42:41 +00:00
|
|
|
/* make dependencies; Date: jan 07, 1986; Author: Erik Baalbergen */
|
1988-10-07 09:48:23 +00:00
|
|
|
/* Log:
|
|
|
|
[Thu Oct 6 09:56:30 MET 1988; erikb]
|
|
|
|
Added option '-d' which suppresses "file.c :" be printed
|
|
|
|
*/
|
1986-10-20 14:42:41 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define BSIZ 1024
|
1988-10-07 09:48:23 +00:00
|
|
|
char *prog;
|
|
|
|
|
|
|
|
int dflag = 0; /* suppress "file.c :" */
|
1986-10-20 14:42:41 +00:00
|
|
|
|
|
|
|
struct namelist {
|
|
|
|
struct namelist *next;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct namelist *freelist;
|
|
|
|
struct namelist *new_namelist();
|
|
|
|
struct namelist *nl = 0;
|
|
|
|
|
|
|
|
char *Malloc(u)
|
|
|
|
unsigned u;
|
|
|
|
{
|
|
|
|
char *sp, *malloc();
|
|
|
|
|
|
|
|
if ((sp = malloc(u)) == 0) {
|
|
|
|
fprintf(stderr, "%s: out of space\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct namelist *
|
|
|
|
new_namelist()
|
|
|
|
{
|
|
|
|
register struct namelist *nlp = freelist;
|
|
|
|
|
|
|
|
if (nlp) {
|
|
|
|
freelist = nlp->next;
|
|
|
|
return nlp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (struct namelist *) Malloc(sizeof(struct namelist));
|
|
|
|
}
|
|
|
|
|
|
|
|
free_namelist(nlp)
|
|
|
|
struct namelist *nlp;
|
|
|
|
{
|
|
|
|
if (nlp) {
|
|
|
|
free_namelist(nlp->next);
|
|
|
|
nlp->next = freelist;
|
|
|
|
freelist = nlp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_name(nm)
|
|
|
|
char *nm;
|
|
|
|
{
|
1988-10-07 09:48:23 +00:00
|
|
|
struct namelist *nlp = nl, *lnlp = 0, *nnlp;
|
1986-10-20 14:42:41 +00:00
|
|
|
char *strcpy();
|
|
|
|
|
|
|
|
while (nlp) {
|
|
|
|
register i = strcmp(nm, nlp->name);
|
|
|
|
if (i < 0)
|
|
|
|
break;
|
|
|
|
if (i == 0) /* already present */
|
|
|
|
return;
|
|
|
|
lnlp = nlp;
|
|
|
|
nlp = nlp->next;
|
|
|
|
}
|
|
|
|
|
1988-10-07 10:26:37 +00:00
|
|
|
(nnlp = new_namelist())->name = strcpy(Malloc((unsigned)strlen(nm) + 1), nm);
|
1986-10-20 14:42:41 +00:00
|
|
|
|
|
|
|
if (lnlp) {
|
|
|
|
nnlp->next = lnlp->next;
|
|
|
|
lnlp->next = nnlp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nnlp->next = nl;
|
|
|
|
nl = nnlp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print_namelist(nm, nlp)
|
|
|
|
char *nm;
|
|
|
|
struct namelist *nlp;
|
|
|
|
{
|
1988-10-07 09:48:23 +00:00
|
|
|
while (nlp) {
|
|
|
|
if (!dflag)
|
|
|
|
printf("%s: ", nm);
|
|
|
|
printf("%s\n", nlp->name);
|
|
|
|
nlp = nlp->next;
|
1986-10-20 14:42:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1988-10-07 10:26:37 +00:00
|
|
|
/*ARGSUSED*/
|
1986-10-20 14:42:41 +00:00
|
|
|
main(argc, argv)
|
|
|
|
char *argv[];
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
1988-10-07 09:48:23 +00:00
|
|
|
prog = *argv++;
|
1990-07-18 14:38:48 +00:00
|
|
|
if (*argv && **argv == '-') {
|
1988-10-07 09:48:23 +00:00
|
|
|
char *opt = &(*argv++)[1];
|
|
|
|
|
|
|
|
if (*opt++ != 'd' || *opt) {
|
|
|
|
fprintf(stderr, "use: %s [-d] [file ...]\n", prog);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
dflag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*argv) {
|
1986-10-20 14:42:41 +00:00
|
|
|
free_namelist(nl);
|
|
|
|
nl = 0;
|
|
|
|
if (dofile(*argv) == 0)
|
|
|
|
++err;
|
|
|
|
print_namelist(*argv++, nl);
|
|
|
|
}
|
1987-03-09 13:29:04 +00:00
|
|
|
exit(err ? 1 : 0);
|
1986-10-20 14:42:41 +00:00
|
|
|
}
|
|
|
|
|
1987-02-04 13:04:51 +00:00
|
|
|
int
|
|
|
|
contains_slash(s)
|
|
|
|
register char *s;
|
|
|
|
{
|
1988-10-07 09:48:23 +00:00
|
|
|
while (*s)
|
1987-02-04 13:04:51 +00:00
|
|
|
if (*s++ == '/') return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1988-10-07 10:26:37 +00:00
|
|
|
extern char *fgets();
|
|
|
|
|
1986-10-20 14:42:41 +00:00
|
|
|
dofile(fn)
|
|
|
|
char *fn;
|
|
|
|
{
|
1988-10-07 10:26:37 +00:00
|
|
|
char buf[BSIZ];
|
1986-10-20 14:42:41 +00:00
|
|
|
FILE *fp;
|
|
|
|
char *nm, *include_line();
|
|
|
|
|
|
|
|
if ((fp = fopen(fn, "r")) == 0) {
|
1988-10-07 09:48:23 +00:00
|
|
|
fprintf(stderr, "%s: cannot read %s\n", prog, fn);
|
1986-10-20 14:42:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1987-02-04 13:04:51 +00:00
|
|
|
if (contains_slash(fn)) {
|
1988-10-07 09:48:23 +00:00
|
|
|
fprintf(stderr, "%s: (warning) %s not in current directory; not checked\n", prog, fn);
|
1987-02-04 13:04:51 +00:00
|
|
|
fclose(fp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1986-10-20 14:42:41 +00:00
|
|
|
while (fgets(buf, BSIZ, fp) != NULL)
|
|
|
|
if (nm = include_line(buf)) {
|
|
|
|
add_name(nm);
|
1988-10-07 10:26:37 +00:00
|
|
|
if (dofile(nm)) ;
|
1986-10-20 14:42:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
include_line(s)
|
|
|
|
char *s;
|
|
|
|
{
|
|
|
|
while ((*s == '\t') || (*s == ' '))
|
|
|
|
s++;
|
|
|
|
|
|
|
|
if (*s++ == '#') {
|
|
|
|
while ((*s == '\t') || (*s == ' '))
|
|
|
|
s++;
|
|
|
|
if (
|
|
|
|
(*s++ == 'i') &&
|
|
|
|
(*s++ == 'n') &&
|
|
|
|
(*s++ == 'c') &&
|
|
|
|
(*s++ == 'l') &&
|
|
|
|
(*s++ == 'u') &&
|
|
|
|
(*s++ == 'd') &&
|
|
|
|
(*s++ == 'e')
|
|
|
|
) {
|
|
|
|
while ((*s == '\t') || (*s == ' '))
|
|
|
|
s++;
|
|
|
|
if (*s++ == '"') {
|
1988-10-07 09:48:23 +00:00
|
|
|
char *nm = s;
|
|
|
|
|
1986-10-20 14:42:41 +00:00
|
|
|
while (*s != 0 && *s != '"')
|
|
|
|
s++;
|
|
|
|
*s = '\0';
|
|
|
|
return nm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (char *) 0;
|
|
|
|
}
|