+++ /dev/null
-The following changes have been made to this directory since R2:
-
- o support for #eject and #pragma directives has been added.
- o endmarkers have been added for fix problems with makedepend
- misinterpreting compiler switches.
- o support for #include SYMBOL has been added.
- o the #undef directive has been changed to actually undefine symbols
- o a bug in error reporting has been fixed.
- o support for the #elif directive has been added
+++ /dev/null
-# Makefile generated by imake - do not edit!
-# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
-#
-# The cpp used on this machine replaces all newlines and multiple tabs and
-# spaces in a macro expansion with a single space. Imake tries to compensate
-# for this, but is not always successful.
-#
-
-#
-# This makefile is automatically generated by imake... do not modify
-# or you may lose your changes when imake generates makefiles again.
-# Ignore this message if you are not using imake.
-#
-# $Source$
-#
-
-NEWTOP=.
-BUILDTOP=.
-
-INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib -I/usr/athena/include
-CFLAGS=$(DBG) $(INCLUDE) $(DEFINES) $(GLOBAL_CDEFS)
-LINTFLAGS=$(INCLUDE) $(DEFINES) $(GLOBAL_CDEFS)
-
-# $Source$
-#
-
-CURSES= -L/usr/css/lib -lcurses -ltermcap
-
-OSDEFS= -DPOSIX -DSOLARIS -I/usr/openwin/include
-OSLIBS= -L/usr/ccs/lib -lcurses -ltermcap -lresolv \
- -lsocket -lnsl -lc /usr/ucblib/libucb.a -lelf -ldl
-CURSES=
-
-GLOBAL_CDEFS= -DHESIOD -DZEPHYR -DGDSS -DATHENA -DDBMS=INGRES -I/usr/athena/include $(OSDEFS)
-
-SRCTOP=/mit/moiradev/src
-
-DESTDIR=
-
-USRDIR= /usr
-ETCDIR= /usr/athena/etc
-PROGDIR=/usr/athena/bin
-LIBDIR= /usr/athena/lib
-LINTLIBDIR = /usr/lib/lint
-INCLDIR= /usr/athena/include
-MANDIR= /usr/athena/man
-
-LZEHPYR=-lzephyr
-
-LIBGDSS= /mit/gdss/`machtype`/libgdss.a
-GDSSINC= -I/mit/gdss/include
-
-LINTLIBFLAG=-C
-
-MR_LIB=$(BUILDTOP)/lib/libmoira.a
-MR_LIBDEP=$(MR_LIB)
-MR_LINTLIB=$(BUILDTOP)/lib/llib-lmoira.ln
-GDB_LIB=$(BUILDTOP)/gdb/libmrgdb.a
-GDB_LIBDEP=$(GDB_LIB)
-GDB_LINTLIB=$(BUILDTOP)/gdb/llib-lmrgdb.ln
-
-COMPILE_ET= compile_et
-
-COM_ERR = -lcom_err
-
-MAKE_COMMANDS= mk_cmds
-
-SS_LIB = -lss
-
-LLIB = -L/usr/athena/lib
-
-CLIBS= $(MR_LIB) $(GDB_LIB) $(LLIB) $(LZEPHYR) $(COM_ERR) -lkrb -ldes -lhesiod
-
-SQL_LIB= /usr/ingres/lib/libingres.a -lm
-
-ARCHIVE= ar cru
-
-RANLIB= /bin/true
-
-INSTALLFILE= install -c -m 444
-
-INSTALLLIB= install -c -m 444
-
-INSTALLPROG= install -c -m 555
-
-INSTALLRAW= install
-
-LD=ld
-
-AS=as
-
-LINT=lint
-
-CC=gcc -traditional
-
-CCRO=$(CC) -R
-
-HCC=$(CC)
-
-CPP=$(CC) -E
-
-DBG=-O
-
-HCFLAGS=$(CFLAGS)
-
-TAGGER=etags
-
-MAKE=make
-RM=rm -f
-MV=mv
-CP=cp
-LN=ln -s
-LPR=lpr -p
-CHMOD=chmod
-AWK=awk
-
-DEPEND=makedepend
-IMAKE=imake -I$(BUILDTOP)/util/imake.includes
-
-# $Source$
-#
-
-# $Source$
-# $Author$
-# $Header$
-#
-# Copyright 1987 by the Massachusetts Institute of Technology.
-#
-# For copying and distribution information,
-# please see the file <mit-copyright.h>.
-#
-# Utility to build makefile header dependancies from C source.
-#
-# If you have source for cpp...
-#
-
-#
-# But if you don't have cpp source...
-#
-SRCS = include.c main.c parse.c pr.c cppsetup.c
-SOURCES = \
- ${SRCDIR}/util/makedepend/include.c \
- ${SRCDIR}/util/makedepend/main.c \
- ${SRCDIR}/util/makedepend/parse.c \
- ${SRCDIR}/util/makedepend/pr.c \
- ${SRCDIR}/util/makedepend/cppsetup.c \
- ${SRCDIR}/util/makedepend/def.h \
- ${SRCDIR}/util/makedepend/Imakefile \
- ${SRCDIR}/util/makedepend/Makefile
-OBJS = include.o main.o parse.o pr.o cppsetup.o
-DEFINES = '-DINCLUDEDIR="/usr/include"'
-
-CODE=$(SRCS) Imakefile
-
-all:: makedepend
-
-makedepend: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) $(OSLIBS)
-
-clean::
- $(RM) makedepend $(OBJS)
-
-cpy.c: cpy.y yylex.c
- yacc cpy.y
- sed -e '/^# *line/d' < y.tab.c > cpy.c
- $(RM) y.tab.c
-
-cpy.y: $(CPPSRC)/cpy.y
- $(RM) $@
- $(LN) $(CPPSRC)/cpy.y .
-
-yylex.c: $(CPPSRC)/yylex.c
- $(RM) $@
- sed -e 's/#if pdp11 | vax | mc68000/& | ns16000 | ibm032/' \
- $(CPPSRC)/yylex.c > yylex.c
-
-cpp.c: $(CPPSRC)/cpp.c cpp.ed
- $(RM) cpp.c
- /lib/cpp $(CPPSRC)/cpp.c \
- | cb \
- | sed -e '/^$$/d' -e '/^#/d' -e 's/ / /g' > cpp.c
- sed -e '/^#/d' < cpp.ed | ed - cpp.c
-
-cpp.o: cpp.c
-cpy.o: cpy.c
-
-clean::
- $(RM) cpp.c cpy.? yylex.c
-
-config: $(SOURCES)
- -mkdir $(DESTDIR)/util/makedepend
- for i in $(SOURCES); do \
- $(RM) ${DESTDIR}/util/makedepend/`basename $$i`; \
- $(CP) $$i ${DESTDIR}/util/makedepend/`basename $$i`; done
-
-depend:: $(SRCS)
- @echo "### Now computing dependencies"
- @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
-
-clean::
- $(RM) *~ \#* *.bak $(TAGSFILE)
-
-tags::
- $(TAGGER) *.c *.h
-
-Makefile::
- -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak
- $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile
-
-print:: ${CODE}
- ${LPR} ${CODE}
-
-src:: ${CODE}
-
-${CODE}:
- $(RM) $@
- -$(LN) ${SRCDIR}/$@ $@
-
-install::
-
-Makefiles::
-
-# DO NOT DELETE THIS LINE
-
+++ /dev/null
-#
-# $XConsortium: cpp.ed,v 1.2 88/09/06 17:53:42 jim Exp $
-#
-# $Locker $
-#
-/struct symtab stab/d
-/struct symtab \*defloc;/d
-/struct symtab \*udfloc;/d
-/struct symtab \*incloc;/d
-/struct symtab \*ifloc;/d
-/struct symtab \*elsloc;/d
-/struct symtab \*eifloc;/d
-/struct symtab \*ifdloc;/d
-/struct symtab \*ifnloc;/d
-/struct symtab \*ysysloc;/d
-/struct symtab \*varloc;/d
-/struct symtab \*lneloc;/d
-/struct symtab \*ulnloc;/d
-/struct symtab \*uflloc;/d
-/^sayline(/s/$/ DELETED/p
-.,/^}/d
-/^unfill(/s/$/ DELETED/p
-.-1,/^}/d
-/^doincl(/s/$/ DELETED/p
-.-1,/^}/d
-/^equfrm(/s/$/ DELETED/p
-.,/^}/d
-/^dodef(/s/$/ DELETED/p
-.-1,/^}/d
-/^control(/s/$/ DELETED/p
-.-1,/^}/d
-/^savestring(/s/$/ DELETED/p
-.-1,/^}/d
-/^stsym(/s/$/ DELETED/p
-.-1,/^}/d
-/^ppsym(/s/$/ DELETED/p
-.-1,/^}/d
-/^yyerror(/s/$/ DELETED/p
-.,/^}/d
-/^ppwarn(/s/$/ DELETED/p
-.,/^}/d
-/^lookup(/s/$/ DELETED/p
-.-1,/^}/d
-/^subst(/s/$/ DELETED/p
-.-1,/^}/d
-/^trmdir(/s/$/ DELETED/p
-.-1,/^}/d
-/^copy(/s/$/ DELETED/p
-.-1,/^}/d
-/^pperror(/s/$/ DELETED/p
-.,/^}/d
-/^main(/s/$/ CHANGED to cpp_varsetup(argc,argv)/p
-.c
-cpp_varsetup(argc,argv)
-.
-/^strdex(/s/$/ DELETED/p
-.-1,/^}/d
-/^ for(i=1; i<argc; i++)/s/$/ To the end DELETED/p
-.,$c
-}
-.
-/^dump(/s/$/ DELETED/p
-.,/^}/c
-dump() { log_fatal("dump\n"); }
-.
-/^refill(/s/$/ DELETED/p
-.,/^}/c
-refill() { log_fatal("refill\n"); }
-.
-/^slookup(/s/$/ DELETED/p
-.-1,/^}/c
-static struct symtab *slookup() { log_fatal("slookup\n"); }
-.
-w
-q
+++ /dev/null
-/*
- * $XConsortium: cppsetup.c,v 1.4 88/09/06 17:53:45 jim Exp $
- */
-#include "def.h"
-
-#ifdef CPP
-/*
- * This file is strictly for the sake of cpy.y and yylex.c (if
- * you indeed have the source for cpp).
- */
-#define IB 1
-#define SB 2
-#define NB 4
-#define CB 8
-#define QB 16
-#define WB 32
-#define SALT '#'
-#if pdp11 | vax | ns16000 | mc68000 | ibm032
-#define COFF 128
-#else
-#define COFF 0
-#endif
-/*
- * These variables used by cpy.y and yylex.c
- */
-extern char *outp, *inp, *newp, *pend;
-extern char *ptrtab;
-extern char fastab[];
-extern char slotab[];
-
-/*
- * cppsetup
- */
-struct filepointer *currentfile;
-struct inclist *currentinc;
-
-cppsetup(line, filep, inc)
- register char *line;
- register struct filepointer *filep;
- register struct inclist *inc;
-{
- register char *p, savec;
- static boolean setupdone = FALSE;
- boolean value;
-
- if (!setupdone) {
- cpp_varsetup();
- setupdone = TRUE;
- }
-
- currentfile = filep;
- currentinc = inc;
- inp = newp = line;
- for (p=newp; *p; p++)
- ;
-
- /*
- * put a newline back on the end, and set up pend, etc.
- */
- *p++ = '\n';
- savec = *p;
- *p = '\0';
- pend = p;
-
- ptrtab = slotab+COFF;
- *--inp = SALT;
- outp=inp;
- value = yyparse();
- *p = savec;
- return(value);
-}
-
-struct symtab *lookup(symbol)
- char *symbol;
-{
- static struct symtab undefined;
- struct symtab *sp;
-
- sp = defined(symbol, currentinc);
- if (sp == NULL) {
- sp = &undefined;
- sp->s_value = NULL;
- }
- return (sp);
-}
-
-pperror(tag, x0,x1,x2,x3,x4)
- int tag,x0,x1,x2,x3,x4;
-{
- log("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
- log(x0,x1,x2,x3,x4);
-}
-
-
-yyerror(s)
- register char *s;
-{
- log_fatal("Fatal error: %s\n", s);
-}
-#endif CPP
+++ /dev/null
-/*
- * $XConsortium: def.h,v 1.6 88/09/22 13:52:33 jim Exp $
- */
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#ifdef USG
-#define u_char unchar
-#endif
-
-#define MAXDEFINES 512
-#define MAXFILES 512
-#define MAXDIRS 10
-#define SYMTABINC 10 /* must be > 1 for define() to work right */
-#define TRUE 1
-#define FALSE 0
-
-/* the following must match the directives table in main.c */
-#define IF 0
-#define IFDEF 1
-#define IFNDEF 2
-#define ELSE 3
-#define ENDIF 4
-#define DEFINE 5
-#define UNDEF 6
-#define INCLUDE 7
-#define LINE 8
-#define PRAGMA 9
-#define ELIF 10
-#define EJECT 11
-#define IFFALSE 12 /* pseudo value --- never matched */
-#define ELIFFALSE 13 /* pseudo value --- never matched */
-#define INCLUDEDOT 14 /* pseudo value --- never matched */
-
-#ifdef DEBUG
-extern int debug;
-#define debug0 ((debug&0x0001)==0) ? debug : log /* show ifn*(def)*,endif */
-#define debug1 ((debug&0x0002)==0) ? debug : log /* trace defined/!defined */
-#define debug2 ((debug&0x0004)==0) ? debug : log /* show #include */
-#define debug3 ((debug&0x0008)==0) ? debug : log /* show #include SYMBOL */
-#define debug4 ((debug&0x0010)==0) ? debug : log /* unused */
-#define debug5 ((debug&0x0020)==0) ? debug : log /* unused */
-#define debug6 ((debug&0x0040)==0) ? debug : log /* unused */
-#else DEBUG
-#define debug0
-#define debug1
-#define debug2
-#define debug3
-#define debug4
-#define debug5
-#define debug6
-#endif DEBUG
-
-typedef u_char boolean;
-
-struct symtab {
- char *s_name;
- char *s_value;
-};
-
-struct inclist {
- char *i_incstring; /* string from #include line */
- char *i_file; /* path name of the include file */
- struct inclist **i_list; /* list of files it itself includes */
- int i_listlen; /* length of i_list */
- struct symtab *i_defs; /* symbol table for this file */
- struct symtab *i_lastdef; /* last symbol defined */
- int i_deflen; /* number of defines */
- boolean i_defchecked; /* whether defines have been checked */
- boolean i_notified; /* whether we have revealed includes */
- boolean i_marked; /* whether it's in the makefile */
- boolean i_searched; /* whether we have read this */
- boolean i_included_sym; /* whether #include SYMBOL was found */
- /* Can't use i_list if TRUE */
-};
-
-struct filepointer {
- char *f_p;
- char *f_base;
- char *f_end;
- long f_len;
- long f_line;
-};
-
-char *copy();
-char *malloc();
-char *realloc();
-char *basename();
-char *getline();
-struct symtab *slookup();
-struct symtab *defined();
-struct symtab *fdefined();
-struct filepointer *getfile();
-struct inclist *newinclude();
-struct inclist *inc_path();
+++ /dev/null
-/*
- * $XConsortium: include.c,v 1.6 88/09/22 13:52:38 jim Exp $
- */
-#include "def.h"
-
-extern struct inclist inclist[ MAXFILES ],
- *inclistp;
-extern char *includedirs[ ];
-extern char *notdotdot[ ];
-extern boolean show_where_not;
-
-struct inclist *inc_path(file, include, dot)
- register char *file,
- *include;
- boolean dot;
-{
- static char path[ BUFSIZ ];
- register char **pp, *p;
- register struct inclist *ip;
- struct stat st;
- boolean found = FALSE;
-
- /*
- * Check all previously found include files for a path that
- * has already been expanded.
- */
- for (ip = inclist; ip->i_file; ip++)
- if ((strcmp(ip->i_incstring, include) == 0) && !ip->i_included_sym)
- {
- found = TRUE;
- break;
- }
-
- /*
- * If the path was surrounded by "", then check the absolute
- * path provided.
- */
- if (!found && dot) {
- if (stat(include, &st) == 0) {
- ip = newinclude(include, include);
- found = TRUE;
- }
- else if (show_where_not)
- log("\tnot in %s\n", include);
- }
-
- /*
- * See if this include file is in the directory of the
- * file being compiled.
- */
- if (!found) {
- for (p=file+strlen(file); p>file; p--)
- if (*p == '/')
- break;
- if (p == file)
- strcpy(path, include);
- else {
- strncpy(path, file, (p-file) + 1);
- path[ (p-file) + 1 ] = '\0';
- strcpy(path + (p-file) + 1, include);
- }
- remove_dotdot(path);
- if (stat(path, &st) == 0) {
- ip = newinclude(path, include);
- found = TRUE;
- }
- else if (show_where_not)
- log("\tnot in %s\n", path);
- }
-
- /*
- * Check the include directories specified. (standard include dir
- * should be at the end.)
- */
- if (!found)
- for (pp = includedirs; *pp; pp++) {
- sprintf(path, "%s/%s", *pp, include);
- remove_dotdot(path);
- if (stat(path, &st) == 0) {
- ip = newinclude(path, include);
- found = TRUE;
- break;
- }
- else if (show_where_not)
- log("\tnot in %s\n", path);
- }
-
- if (!found) {
- /*
- * If we've announced where it's not include it anyway so
- * it gets on the dependency list.
- */
- if (show_where_not)
- ip = newinclude(include, include);
- else
- ip = NULL;
- }
- return(ip);
-}
-
-/*
- * Ocaisionally, pathnames are created that look like ../x/../y
- * Any of the 'x/..' sequences within the name can be eliminated.
- * (but only if 'x' is not a symbolic link!!)
- */
-remove_dotdot(path)
- char *path;
-{
- register char *end, *from, *to, **cp;
- char *components[ MAXFILES ],
- newpath[ BUFSIZ ];
- boolean component_copied;
-
- /*
- * slice path up into components.
- */
- to = newpath;
- if (*path == '/')
- *to++ = '/';
- *to = '\0';
- cp = components;
- for (from=end=path; *end; end++)
- if (*end == '/') {
- while (*end == '/')
- *end++ = '\0';
- if (*from)
- *cp++ = from;
- from = end;
- }
- *cp++ = from;
- *cp = NULL;
-
- /*
- * Now copy the path, removing all 'x/..' components.
- */
- cp = components;
- component_copied = FALSE;
- while(*cp) {
- if (!isdot(*cp) && !isdotdot(*cp) && isdotdot(*(cp+1))) {
- if (issymbolic(newpath, *cp))
- goto dont_remove;
- cp++;
- } else {
- dont_remove:
- if (component_copied)
- *to++ = '/';
- component_copied = TRUE;
- for (from = *cp; *from; )
- *to++ = *from++;
- *to = '\0';
- }
- cp++;
- }
- *to++ = '\0';
-
- /*
- * copy the reconstituted path back to our pointer.
- */
- strcpy(path, newpath);
-}
-
-isdot(p)
- register char *p;
-{
- if(p && *p++ == '.' && *p++ == '\0')
- return(TRUE);
- return(FALSE);
-}
-
-isdotdot(p)
- register char *p;
-{
- if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
- return(TRUE);
- return(FALSE);
-}
-
-issymbolic(dir, component)
- register char *dir, *component;
-{
- struct stat st;
- char buf[ BUFSIZ ], **pp;
-
- sprintf(buf, "%s%s%s", dir, *dir ? "/" : "", component);
- for (pp=notdotdot; *pp; pp++)
- if (strcmp(*pp, buf) == 0)
- return (TRUE);
- if (lstat(buf, &st) == 0
- && (st.st_mode & S_IFMT) == S_IFLNK) {
- *pp++ = copy(buf);
- if (pp >= ¬dotdot[ MAXDIRS ])
- log_fatal("out of .. dirs, increase MAXDIRS\n");
- return(TRUE);
- }
- return(FALSE);
-}
-
-/*
- * Add an include file to the list of those included by 'file'.
- */
-struct inclist *newinclude(newfile, incstring)
- register char *newfile, *incstring;
-{
- register struct inclist *ip;
-
- /*
- * First, put this file on the global list of include files.
- */
- ip = inclistp++;
- if (inclistp == inclist + MAXFILES - 1)
- log_fatal("out of space: increase MAXFILES\n");
- ip->i_file = copy(newfile);
- ip->i_included_sym = FALSE;
- if (incstring == NULL)
- ip->i_incstring = ip->i_file;
- else
- ip->i_incstring = copy(incstring);
-
- return(ip);
-}
-
-included_by(ip, newfile)
- register struct inclist *ip, *newfile;
-{
- register i;
-
- if (ip == NULL)
- return;
- /*
- * Put this include file (newfile) on the list of files included
- * by 'file'. If 'file' is NULL, then it is not an include
- * file itself (i.e. was probably mentioned on the command line).
- * If it is already on the list, don't stick it on again.
- */
- if (ip->i_list == NULL)
- ip->i_list = (struct inclist **)
- malloc(sizeof(struct inclist *) * ++ip->i_listlen);
- else {
- for (i=0; i<ip->i_listlen; i++)
- if (ip->i_list[ i ] == newfile) {
- if (!ip->i_included_sym)
- {
- /* only bitch if ip has */
- /* no #include SYMBOL lines */
- log("%s includes %s more than once!\n",
- ip->i_file, newfile->i_file);
- log("Already have\n");
- for (i=0; i<ip->i_listlen; i++)
- log("\t%s\n", ip->i_list[i]->i_file);
- }
- return;
- }
- ip->i_list = (struct inclist **) realloc(ip->i_list,
- sizeof(struct inclist *) * ++ip->i_listlen);
- }
- ip->i_list[ ip->i_listlen-1 ] = newfile;
-}
-
-inc_clean ()
-{
- register struct inclist *ip;
-
- for (ip = inclist; ip < inclistp; ip++) {
- ip->i_marked = FALSE;
- }
-}
+++ /dev/null
-/*
- * $XConsortium: main.c,v 1.20 88/10/22 11:26:14 jim Exp $
- */
-#include "def.h"
-#ifdef hpux
-#define sigvec sigvector
-#endif /* hpux */
-#include <sys/signal.h>
-
-#ifdef DEBUG
-int debug;
-#endif
-
-char *directives[] = {
- "if",
- "ifdef",
- "ifndef",
- "else",
- "endif",
- "define",
- "undef",
- "include",
- "line",
- "pragma",
- "elif",
- "eject",
- NULL
-};
-
-struct symtab predefs[] = {
-#ifdef apollo
- {"apollo", NULL},
-#endif
-#ifdef ibm032
- {"ibm032", NULL},
-#endif
-#ifdef sun
- {"sun", NULL},
-#ifdef sparc
- {"sparc", NULL},
-#endif
-#endif
-#ifdef hpux
- {"hpux", NULL},
-#endif
-#ifdef vax
- {"vax", NULL},
-#endif
-#ifdef VMS
- {"VMS", NULL},
-#endif
-#ifdef ultrix
- {"ultrix", NULL},
-#endif
-#ifdef mips
- {"mips", NULL},
-#endif
-#ifdef _AIX
- {"_AIX", NULL},
-#endif
- {NULL, NULL}
-};
-
-struct symtab deflist[ MAXDEFINES ];
-struct inclist inclist[ MAXFILES ],
- *inclistp = inclist;
-
-char *filelist[ MAXFILES ];
-char *includedirs[ MAXDIRS ];
-char *notdotdot[ MAXDIRS ];
-char *objfile = ".o";
-char *startat = "# DO NOT DELETE THIS LINE -- make depend depends on it.";
-int width = 78;
-boolean printed = FALSE;
-boolean verbose = FALSE;
-boolean show_where_not = FALSE;
-
-#if defined(POSIX) || (defined(mips) && defined(SYSTYPE_SYSV))
-typedef void sigreturn_t;
-#else
-typedef int sigreturn_t;
-#endif
-sigreturn_t catch();
-
-#if !(defined(mips) && defined(SYSTYPE_SYSV))
-struct sigvec sig_vec = {
- catch,
- (1<<(SIGINT -1))
- |(1<<(SIGQUIT-1))
- |(1<<(SIGBUS-1))
- |(1<<(SIGILL-1))
- |(1<<(SIGSEGV-1))
- |(1<<(SIGHUP-1))
- |(1<<(SIGPIPE-1))
- |(1<<(SIGSYS-1)),
- 0
-};
-#endif /* mips && SYSTYPE_SYSV */
-
-main(argc, argv)
- int argc;
- char **argv;
-{
- register struct symtab *symp = deflist;
- register char **fp = filelist;
- register char **incp = includedirs;
- register char *p;
- register struct inclist *ip;
- char *makefile = NULL;
- struct filepointer *filecontent;
- struct symtab *psymp = predefs;
- char *endmarker = NULL;
-
- while (psymp->s_name)
- *symp++ = *psymp++;
- for(argc--, argv++; argc; argc--, argv++) {
- /* if looking for endmarker then check before parsing */
- if (endmarker && strcmp (endmarker, *argv) == 0) {
- endmarker = NULL;
- continue;
- }
- if (**argv != '-') {
- *fp++ = argv[0];
- continue;
- }
- switch(argv[0][1]) {
- case '-':
- endmarker = &argv[0][2];
- if (endmarker[0] == '\0') endmarker = "--";
- break;
- case 'D':
- symp->s_name = argv[0]+2;
- if (*symp->s_name == '\0') {
- symp->s_name = *(++argv);
- argc--;
- }
- for (p=symp->s_name; *p ; p++)
- if (*p == '=') {
- *p++ = '\0';
- break;
- }
- symp->s_value = p;
- symp++;
- break;
- case 'I':
- *incp++ = argv[0]+2;
- if (**(incp-1) == '\0') {
- *(incp-1) = *(++argv);
- argc--;
- }
- break;
- /* do not use if endmarker processing */
- case 'w':
- if (endmarker) break;
- if (argv[0][2] == '\0') {
- argv++;
- argc--;
- width = atoi(argv[0]);
- } else
- width = atoi(argv[0]+2);
- break;
- case 'o':
- if (endmarker) break;
- if (argv[0][2] == '\0') {
- argv++;
- argc--;
- objfile = argv[0];
- } else
- objfile = argv[0]+2;
- break;
- case 'v':
- if (endmarker) break;
- verbose = TRUE;
-#ifdef DEBUG
- if (argv[0][2])
- debug = atoi(argv[0]+2);
-#endif
- break;
- case 's':
- if (endmarker) break;
- startat = argv[0]+2;
- if (*startat == '\0') {
- startat = *(++argv);
- argc--;
- }
- if (*startat != '#')
- log_fatal("-s flag's value should start %s\n",
- "with '#'.");
- break;
- case 'f':
- if (endmarker) break;
- makefile = argv[0]+2;
- if (*makefile == '\0') {
- makefile = *(++argv);
- argc--;
- }
- break;
-
- /* Ignore -O, -g so we can just pass ${CFLAGS} to
- makedepend
- */
- case 'O':
- case 'g':
- break;
- default:
- if (endmarker) break;
- /* log_fatal("unknown opt = %s\n", argv[0]); */
- log("ignoring option %s\n", argv[0]);
- }
- }
- *incp++ = INCLUDEDIR;
-
- redirect(startat, makefile);
-
- /*
- * catch signals.
- */
-#if defined (mips) && defined (SYSTYPE_SYSV)
-/* should really reset SIGINT to SIG_IGN if it was. */
- signal (SIGHUP, catch);
- signal (SIGINT, catch);
- signal (SIGQUIT, catch);
- signal (SIGILL, catch);
- signal (SIGBUS, catch);
- signal (SIGSEGV, catch);
- signal (SIGSYS, catch);
-#else /* not (mips && SYSTYPE_SYSV) */
- sigvec(SIGHUP, &sig_vec, (struct sigvec *)0);
- sigvec(SIGINT, &sig_vec, (struct sigvec *)0);
- sigvec(SIGQUIT, &sig_vec, (struct sigvec *)0);
- sigvec(SIGILL, &sig_vec, (struct sigvec *)0);
- sigvec(SIGBUS, &sig_vec, (struct sigvec *)0);
- sigvec(SIGSEGV, &sig_vec, (struct sigvec *)0);
- sigvec(SIGSYS, &sig_vec, (struct sigvec *)0);
-#endif /* mips && SYSTYPE_SYSV */
-
- /*
- * now peruse through the list of files.
- */
- for(fp=filelist; *fp; fp++) {
- filecontent = getfile(*fp);
- ip = newinclude(*fp, (char *)NULL);
-
- find_includes(filecontent, ip, ip, 0);
- freefile(filecontent);
- recursive_pr_include(ip, ip->i_file, basename(*fp));
- inc_clean();
- }
- if (printed)
- printf("\n");
- exit(0);
-}
-
-struct filepointer *getfile(file)
- char *file;
-{
- register int fd;
- struct filepointer *content;
- struct stat st;
-
- content = (struct filepointer *)malloc(sizeof(struct filepointer));
- if ((fd = open(file, O_RDONLY)) < 0) {
- log("cannot open \"%s\"\n", file);
- content->f_p = content->f_base = content->f_end = malloc(1);
- *content->f_p = '\0';
- return(content);
- }
- fstat(fd, &st);
- content->f_len = st.st_size+1;
- content->f_base = malloc(content->f_len);
- if (content->f_base == NULL)
- log_fatal("cannot allocate mem\n");
- if (read(fd, content->f_base, st.st_size) != st.st_size)
- log_fatal("cannot read all of %s\n", file);
- close(fd);
- content->f_p = content->f_base;
- content->f_end = content->f_base + st.st_size;
- *content->f_end = '\0';
- content->f_line = 0;
- return(content);
-}
-
-freefile(fp)
- struct filepointer *fp;
-{
- free(fp->f_base);
- free(fp);
-}
-
-/*VARARGS*/
-log_fatal(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
-char *x0, *x1, *x2, *x3, *x4, *x5, *x6, *x7, *x8, *x9;
-{
- log(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
- exit (1);
-}
-
-/*VARARGS0*/
-log(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
-char *x0, *x1, *x2, *x3, *x4, *x5, *x6, *x7, *x8, *x9;
-{
- fprintf(stderr, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
-}
-
-char *copy(str)
- register char *str;
-{
- register char *p = malloc(strlen(str) + 1);
-
- strcpy(p, str);
- return(p);
-}
-
-match(str, list)
- register char *str, **list;
-{
- register int i;
-
- for (i=0; *list; i++, list++)
- if (strcmp(str, *list) == 0)
- return(i);
- return(-1);
-}
-
-/*
- * Get the next line. We only return lines beginning with '#' since that
- * is all this program is ever interested in.
- */
-char *getline(filep)
- register struct filepointer *filep;
-{
- register char *p, /* walking pointer */
- *eof, /* end of file pointer */
- *bol; /* beginning of line pointer */
- register lineno; /* line number */
-
- p = filep->f_p;
- eof = filep->f_end;
- if (p >= eof)
- return((char *)NULL);
- lineno = filep->f_line;
-
- for(bol = p--; ++p < eof; ) {
- if (*p == '/' && *(p+1) == '*') { /* consume comments */
- *p++ = ' ', *p++ = ' ';
- while (*p) {
- if (*p == '*' && *(p+1) == '/') {
- *p++ = ' ', *p = ' ';
- break;
- }
- else if (*p == '\n')
- lineno++;
- *p++ = ' ';
- }
- continue;
- }
- else if (*p == '\n') {
- lineno++;
- if (*bol == '#') {
- *p++ = '\0';
- goto done;
- }
- bol = p+1;
- }
- }
- if (*bol != '#')
- bol = NULL;
-done:
- filep->f_p = p;
- filep->f_line = lineno;
- return(bol);
-}
-
-char *basename(file)
- register char *file;
-{
- register char *p;
-
- for (p=file+strlen(file); p>file && *p != '/'; p--) ;
-
- if (*p == '/')
- p++;
-
- file = copy(p);
- for(p=file+strlen(file); p>file && *p != '.'; p--) ;
-
- if (*p == '.')
- *p = '\0';
- return(file);
-}
-
-redirect(line, makefile)
- char *line,
- *makefile;
-{
- struct stat st;
- FILE *fdin, *fdout;
- char backup[ BUFSIZ ],
- buf[ BUFSIZ ];
- boolean found = FALSE;
- int len;
-
- /*
- * if makefile is "-" then let it pour onto stdout.
- */
- if (makefile && *makefile == '-' && *(makefile+1) == '\0')
- return;
-
- /*
- * use a default makefile is not specified.
- */
- if (!makefile) {
- if (stat("makefile", &st) == 0)
- makefile = "makefile";
- else if (stat("Makefile", &st) == 0)
- makefile = "Makefile";
- else
- log_fatal("[mM]akefile is not present\n");
- }
- else
- stat(makefile, &st);
- if ((fdin = fopen(makefile, "r")) == NULL)
- log_fatal("cannot open \"%s\"\n", makefile);
- sprintf(backup, "%s.bak", makefile);
- unlink(backup);
- if (rename(makefile, backup) < 0)
- log_fatal("cannot rename %s to %s\n", makefile, backup);
- if ((fdout = freopen(makefile, "w", stdout)) == NULL)
- log_fatal("cannot open \"%s\"\n", backup);
- len = strlen(line);
- while (fgets(buf, BUFSIZ, fdin) && !found) {
- if (*buf == '#' && strncmp(line, buf, len) == 0)
- found = TRUE;
- fputs(buf, fdout);
- }
- if (!found) {
- log("Adding new delimiting line \"%s\"\nAdding dependencies...\n",
- line);
- puts(line); /* same as fputs(fdout); but with newline */
- }
- fflush(fdout);
-#if defined (mips) && defined (SYSTYPE_SYSV)
- chmod(makefile, st.st_mode);
-#else /* not (mips && SYSTYPE_SYSV) */
- fchmod(fileno(fdout), st.st_mode);
-#endif /* mips && SYSTYPE_SYSV */
-}
+++ /dev/null
-#!/bin/sh
-#
-# @(#)mdepend.sh 1.3 5/11/88 19:44:36
-#
-# Do the equivalent of the 'makedepend' program, but do it right.
-#
-# Usage:
-#
-# makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
-# [-o object-suffix]
-#
-# Notes:
-#
-# The C compiler used can be overridden with the environment
-# variable "CC".
-#
-# The "-v" switch of the "makedepend" program is not supported.
-#
-#
-# This script should
-# work on both USG and BSD systems. However, when System V.4 comes out,
-# USG users will probably have to change "silent" to "-s" instead of
-# "-" (at least, that's what the documentation implies).
-#
-CC=${CC:-cc}
-
-silent='-'
-
-TMP=${TMPDIR:-/tmp}/mdep$$
-CPPCMD=${TMP}a
-DEPENDLINES=${TMP}b
-TMPMAKEFILE=${TMP}c
-MAGICLINE=${TMP}d
-
-trap "rm -f ${TMP}*; exit 1" 1 2 15
-trap "rm -f ${TMP}*; exit 0" 1 2 13
-
-echo " \c" > $CPPCMD
-if [ `wc -c < $CPPCMD` -eq 1 ]
-then
- c="\c"
- n=
-else
- c=
- n="-n"
-fi
-
-echo $n "exec $CC -E$c" > $CPPCMD
-chmod +x $CPPCMD
-
-files=
-makefile=
-magic_string='# DO NOT DELETE'
-objsuffix='.o'
-width=78
-while [ $# != 0 ]
-do
- case "$1" in
- -D*|-I*)
- echo $n " '$1'$c" >> $CPPCMD
- ;;
- -w)
- width="$2"
- shift
- ;;
- -s)
- magic_string="$2"
- shift
- ;;
- -f)
- makefile="$2"
- shift
- ;;
- -o)
- objsuffix="$2"
- shift
- ;;
- -*)
- echo "Unknown option '$1' ignored" 1>&2
- ;;
- *)
- files="$files $1"
- ;;
- esac
- shift
-done
-echo ' $*' >> $CPPCMD
-
-case "$makefile" in
- '')
- if [ -r makefile ]
- then
- makefile=makefile
- elif [ -r Makefile ]
- then
- makefile=Makefile
- else
- echo 'no makefile or Makefile found' 1>&2
- exit 1
- fi
- ;;
- -)
- makefile=$TMPMAKEFILE
- ;;
-esac
-
-echo '' > $DEPENDLINES
-for i in $files
-do
- $CPPCMD $i \
- | sed -n "/^#/s;^;$i ;p"
-done \
- | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \
- -e 's|"||g' -e 's| \./| |' \
- | awk '{
- if ($1 != $4 && $2 != "#ident")
- {
- ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
- print ofile, $4
- }
- }' \
- | sort -u \
- | awk '
- {
- newrec = rec " " $2
- if ($1 != old1)
- {
- old1 = $1
- if (rec != "")
- print rec
- rec = $1 ": " $2
- }
- else if (length (newrec) > '"$width"')
- {
- print rec
- rec = $1 ": " $2
- }
- else
- rec = newrec
- }
- END \
- {
- if (rec != "")
- print rec
- }' \
- >> $DEPENDLINES
-
-trap "" 1 2 13 15 # Now we are committed
-case "$makefile" in
- $TMPMAKEFILE)
- ;;
- *)
- rm -f Makefile.bak
- cp Makefile Makefile.bak
- ;;
-esac
-
-#
-# Before we go edit the Makefile, we must make sure that magic_string
-# exists, and that it's not the last line. Otherwise, dear old ed
-# will exit prematurely. What a pain.
-#
-cat >> $makefile <<- END_OF_APPEND
- $magic_string
-
-END_OF_APPEND
-ed $silent $makefile <<- END_OF_ED_SCRIPT
- /^$magic_string/w $MAGICLINE
- /^$magic_string/,\$d
- \$r $MAGICLINE
- \$r $DEPENDLINES
- w
- q
-END_OF_ED_SCRIPT
-
-case "$makefile" in
- $TMPMAKEFILE)
- cat $TMPMAKEFILE
- ;;
-esac
-
-rm -f ${TMP}*
+++ /dev/null
-.TH MAKEDEPEND 1 "26 October 1988" "X Version 11"
-.UC 4
-.SH NAME
-makedepend \- create dependencies in makefiles
-.SH SYNOPSIS
-.B makedepend
-[
-.B \-Dname=def
-] [
-.B \-Dname
-] [
-.B \-Iincludedir
-] [
-.B \-fmakefile
-] [
-.B \-oobjsuffix
-] [
-.B \-sstring
-] [
-.B \-wwidth
-] [
-\-\ \-
-.B otheroptions
-\-\ \-
-]
-sourcefile ...
-.br
-.SH DESCRIPTION
-.B Makedepend
-reads each
-.I sourcefile
-in sequence and parses it like a C-preprocessor,
-processing all
-.I #include,
-.I #define,
-.I #undef,
-.I #ifdef,
-.I #ifndef,
-.I #endif,
-.I #if
-and
-.I #else
-directives so that it can correctly tell which
-.I #include,
-directives would be used in a compilation.
-Any
-.I #include,
-directives can reference files having other
-.I #include
-directives, and parsing will occur in these files as well.
-.PP
-Every file that a
-.I sourcefile
-includes,
-directly or indirectly,
-is what
-.B makedepend
-calls a "dependency".
-These dependencies are then written to a
-.I makefile
-in such a way that
-.B make(1)
-will know which object files must be recompiled when a dependency has changed.
-.PP
-By default,
-.B makedepend
-places its output in the file named
-.I makefile
-if it exists, otherwise
-.I Makefile.
-An alternate makefile may be specified with the
-.I -f
-option.
-It first searches the makefile for
-the line
-.sp
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-.sp
-or one provided with the
-.I -s
-option,
-as a delimiter for the dependency output.
-If it finds it, it will delete everything
-following this to the end of the makefile
-and put the output after this line.
-If it doesn't find it, the program
-will append the string to the end of the makefile
-and place the output following that.
-For each
-.I sourcefile
-appearing on the command line,
-.B makedepend
-puts lines in the makefile of the form
-.sp
- sourcefile.o: dfile ...
-.sp
-Where "sourcefile.o" is the name from the command
-line with its suffix replaced with ".o",
-and "dfile" is a dependency discovered in a
-.I #include
-directive while parsing
-.I sourcefile
-or one of the files it included.
-.SH EXAMPLE
-Normally,
-.B makedepend
-will be used in a makefile target so that typing "make depend" will
-bring the dependencies up to date for the makefile.
-For example,
-.nf
- SRCS = file1.c file2.c ...
- CFLAGS = -O -DHACK -I../foobar -xyz
- depend:
- makedepend -- $(CFLAGS) -- $(SRCS)
-.fi
-.SH OPTIONS
-.B Makedepend
-will ignore any option that it does not understand so that you may use
-the same arguments that you would for
-.B cc(1).
-.TP 5
-.B \-Dname=def or \-Dname
-Define.
-This places a definition for
-.I name
-in
-.B makedepend's
-symbol table.
-Without
-.I =def
-the symbol becomes defined as "1".
-.TP 5
-.B \-Iincludedir
-Include directory.
-This option tells
-.B makedepend
-to prepend
-.I includedir
-to its list of directories to search when it encounters
-a
-.I #include
-directive.
-By default,
-.B makedepend
-only searches /usr/include.
-.TP 5
-.B \-fmakefile
-Filename.
-This allows you to specify an alternate makefile in which
-.B makedepend
-can place its output.
-.TP 5
-.B \-oobjsuffix
-Object file suffix.
-Some systems may have object files whose suffix is something other
-than ".o".
-This option allows you to specify another suffix, such as
-".b" with
-.I -o.b
-or ":obj"
-with
-.I -o:obj
-and so forth.
-.TP 5
-.B \-sstring
-Starting string delimiter.
-This option permits you to specify
-a different string for
-.B makedepend
-to look for in the makefile.
-.TP 5
-.B \-wwidth
-Line width.
-Normally,
-.B makedepend
-will ensure that every output line that it writes will be no wider than
-78 characters for the sake of readability.
-This option enables you to change this width.
-.TP 5
-.B "\-\ \- options \-\ \-"
-If
-.B makedepend
-encounters a double hyphen (\-\ \-) in the argument list,
-then any unrecognized argument following it
-will be silently ignored; a second double hyphen terminates this
-special treatment.
-In this way,
-.B makedepend
-can be made to safely ignore esoteric compiler arguments that might
-normally be found in a CFLAGS
-.B make
-macro (see the
-.B EXAMPLE
-section above).
-All options that
-.B makedepend
-recognizes and appear between the pair of double hyphens
-are processed normally.
-.SH ALGORITHM
-The approach used in this program enables it to run an order of magnitude
-faster than any other "dependency generator" I have ever seen.
-Central to this performance are two assumptions:
-that all files compiled by a single
-makefile will be compiled with roughly the same
-.I -I
-and
-.I -D
-options;
-and that most files in a single directory will include largely the
-same files.
-.PP
-Given these assumptions,
-.B makedepend
-expects to be called once for each makefile, with
-all source files that are maintained by the
-makefile appearing on the command line.
-It parses each source and include
-file exactly once, maintaining an internal symbol table
-for each.
-Thus, the first file on the command line will take an amount of time
-proportional to the amount of time that a normal C preprocessor takes.
-But on subsequent files, if it encounter's an include file
-that it has already parsed, it does not parse it again.
-.PP
-For example,
-imagine you are compiling two files,
-.I file1.c
-and
-.I file2.c,
-they each include the header file
-.I header.h,
-and the file
-.I header.h
-in turn includes the files
-.I def1.h
-and
-.I def2.h.
-When you run the command
-.sp
- makedepend file1.c file2.c
-.sp
-.B makedepend
-will parse
-.I file1.c
-and consequently,
-.I header.h
-and then
-.I def1.h
-and
-.I def2.h.
-It then decides that the dependencies for this file are
-.sp
- file1.o: header.h def1.h def2.h
-.sp
-But when the program parses
-.I file2.c
-and discovers that it, too, includes
-.I header.h,
-it does not parse the file,
-but simply adds
-.I header.h,
-.I def1.h
-and
-.I def2.h
-to the list of dependencies for
-.I file2.o.
-.SH "SEE ALSO"
-cc(1), make(1)
-.SH BUGS
-If you do not have the source for cpp, the Berkeley Unix C preprocessor,
-then
-.B makedepend
-will be compiled in such a way that all
-.I #if
-directives will evaluate to "true" regardless of their actual value.
-This may cause the wrong
-.I #include
-directives to be evaluated.
-.B Makedepend
-should simply have its own parser written for
-.I #if
-expressions.
-.PP
-Imagine you are parsing two files,
-say
-.I file1.c
-and
-.I file2.c,
-each includes the file
-.I def.h.
-The list of files that
-.I def.h
-includes might truly be different when
-.I def.h
-is included by
-.I file1.c
-than when it is included by
-.I file2.c.
-But once
-.B makedepend
-arrives at a list of dependencies for a file,
-it is cast in concrete.
-.SH AUTHOR
-Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
+++ /dev/null
-/*
- * $XConsortium: parse.c,v 1.8 88/09/22 13:52:51 jim Exp $
- */
-#include "def.h"
-#include <sys/signal.h>
-
-extern char *directives[];
-extern struct symtab deflist[];
-
-find_includes(filep, file, file_red, recursion)
- struct filepointer *filep;
- struct inclist *file, *file_red;
- int recursion;
-{
- register char *line;
- register int type;
-
- while (line = getline(filep)) {
- switch(type = deftype(line, filep, file_red, file, TRUE)) {
- case IF:
- doif:
- type = find_includes(filep, file,
- file_red, recursion+1);
- while ((type == ELIF) || (type == ELIFFALSE))
- type = gobble(filep, file, file_red);
- if (type == ELSE)
- gobble(filep, file, file_red);
- break;
- case IFFALSE:
- doiffalse:
- type = gobble(filep, file, file_red);
- if (type == ELSE)
- find_includes(filep, file,
- file_red, recursion+1);
- else
- if (type == ELIF)
- goto doif;
- else
- if (type == ELIFFALSE)
- goto doiffalse;
- break;
- case IFDEF:
- case IFNDEF:
- if ((type == IFDEF && defined(line, file_red))
- || (type == IFNDEF && !defined(line, file_red))) {
- debug1(type == IFNDEF ?
- "line %d: %s !def'd in %s via %s%s\n" : "",
- filep->f_line, line,
- file->i_file, file_red->i_file, ": doit");
- type = find_includes(filep, file,
- file_red, recursion+1);
- if (type == ELSE)
- gobble(filep, file, file_red);
- }
- else {
- debug1(type == IFDEF ?
- "line %d: %s !def'd in %s via %s%s\n" : "",
- filep->f_line, line,
- file->i_file, file_red->i_file, ": gobble");
- type = gobble(filep, file, file_red);
- if (type == ELSE)
- find_includes(filep, file,
- file_red, recursion+1);
- }
- break;
- case ELSE:
- case ELIFFALSE:
- case ELIF:
- if (!recursion)
- gobble(filep, file, file_red);
- case ENDIF:
- if (recursion)
- return(type);
- case DEFINE:
- define(line, file);
- break;
- case UNDEF:
- /*
- * undefine all occurances of line by killing s_name
- */
- if (!*line) {
- log("%s, line %d: incomplete undef == \"%s\"\n",
- file_red->i_file, filep->f_line, line);
- break;
- }
- {
- struct symtab *val;
- for(val = defined(line, file_red);
- (val && val->s_name);
- val = defined(line, file_red))
-
- *(val->s_name) = '\0';
- }
- break;
- case INCLUDE:
- add_include(file, file_red, line, FALSE);
- break;
- case INCLUDEDOT:
- add_include(file, file_red, line, TRUE);
- break;
- case PRAGMA:
- case EJECT:
- break;
- case -1:
- log("%s", file_red->i_file);
- if (file_red != file)
- log(" (reading %s)", file->i_file);
- log(", line %d: unknown directive == \"%s\"\n",
- filep->f_line, line);
- break;
- case -2:
- log("%s", file_red->i_file);
- if (file_red != file)
- log(" (reading %s)", file->i_file);
- log(", line %d: incomplete include == \"%s\"\n",
- filep->f_line, line);
- break;
- }
- }
- return(-1);
-}
-
-gobble(filep, file, file_red)
- register struct filepointer *filep;
- struct inclist *file, *file_red;
-{
- register char *line;
- register int type;
-
- while (line = getline(filep)) {
- switch(type = deftype(line, filep, file_red, file, FALSE)) {
- case IF:
- case IFFALSE:
- case IFDEF:
- case IFNDEF:
- type = gobble(filep, file, file_red);
- while ((type == ELIF) || (type == ELIFFALSE))
- type = gobble(filep, file, file_red);
- if (type == ELSE)
- type = gobble(filep, file, file_red);
- break;
- case ELSE:
- case ENDIF:
- debug0("%s, line %d: #%s\n",
- file->i_file, filep->f_line,
- directives[type]);
- return(type);
- case DEFINE:
- case UNDEF:
- case INCLUDE:
- case INCLUDEDOT:
- case PRAGMA:
- case EJECT:
- break;
- case ELIF:
- case ELIFFALSE:
- return(type);
- case -1:
- log("%s, line %d: unknown directive == \"%s\"\n",
- file_red->i_file, filep->f_line, line);
- break;
- }
- }
- return(-1);
-}
-
-/*
- * Decide what type of # directive this line is.
- */
-deftype(line, filep, file_red, file, parse_it)
- register char *line;
- register struct filepointer *filep;
- register struct inclist *file_red, *file;
- int parse_it;
-{
- register char *p;
- char *directive, savechar;
- register int ret;
-
- /*
- * Parse the directive...
- */
- directive=line+1;
- while (*directive == ' ' || *directive == '\t')
- directive++;
-
- p = directive;
- while (*p >= 'a' && *p <= 'z')
- p++;
- savechar = *p;
- *p = '\0';
- ret = match(directive, directives);
- *p = savechar;
-
- /* If we don't recognize this compiler directive or we happen to just
- * be gobbling up text while waiting for an #endif or #elif or #else
- * in the case of an #elif we must check the zero_value and return an
- * ELIF or an ELIFFALSE.
- */
-
- if (ret == ELIF && !parse_it)
- {
- while (*p == ' ' || *p == '\t')
- p++;
- /*
- * parse an expression.
- */
- debug0("%s, line %d: #elif %s ",
- file->i_file, filep->f_line, p);
- if (zero_value(p, filep, file_red))
- {
- debug0("false...\n");
- return(ELIFFALSE);
- }
- else
- {
- debug0("true...\n");
- return(ret);
- }
- }
-
- if (ret < 0 || ! parse_it)
- return(ret);
-
- /*
- * now decide how to parse the directive, and do it.
- */
- while (*p == ' ' || *p == '\t')
- p++;
- switch (ret) {
- case IF:
- /*
- * parse an expression.
- */
- debug0("%s, line %d: #if %s\n",
- file->i_file, filep->f_line, p);
- if (zero_value(p, filep, file_red))
- ret = IFFALSE;
- break;
- case IFDEF:
- case IFNDEF:
- debug0("%s, line %d: #%s %s\n",
- file->i_file, filep->f_line, directives[ret], p);
- case UNDEF:
- /*
- * separate the name of a single symbol.
- */
- while (isalnum(*p) || *p == '_')
- *line++ = *p++;
- *line = '\0';
- break;
- case INCLUDE:
- debug2("%s, line %d: #include %s\n",
- file->i_file, filep->f_line, p);
-
- /* Support ANSI macro substitution */
- {
- struct symtab *sym = defined(p, file_red);
- while (sym) {
- p = sym->s_value;
- debug3("%s : #includes SYMBOL %s = %s\n",
- file->i_incstring,
- sym -> s_name,
- sym -> s_value);
- /* mark file as having included a 'soft include' */
- file->i_included_sym = TRUE;
- sym = defined(p, file_red);
- }
- }
-
- /*
- * Separate the name of the include file.
- */
- while (*p && *p != '"' && *p != '<')
- p++;
- if (! *p)
- return(-2);
- if (*p++ == '"') {
- ret = INCLUDEDOT;
- while (*p && *p != '"')
- *line++ = *p++;
- } else
- while (*p && *p != '>')
- *line++ = *p++;
- *line = '\0';
- break;
- case DEFINE:
- /*
- * copy the definition back to the beginning of the line.
- */
- strcpy (line, p);
- break;
- case ELSE:
- case ENDIF:
- case ELIF:
- case PRAGMA:
- case EJECT:
- debug0("%s, line %d: #%s\n",
- file->i_file, filep->f_line, directives[ret]);
- /*
- * nothing to do.
- */
- break;
- }
- return(ret);
-}
-
-struct symtab *defined(symbol, file)
- register char *symbol;
- struct inclist *file;
-{
- register struct symtab *val;
-
- if (val = slookup(symbol, deflist)) {
- debug1("%s defined on command line\n", symbol);
- return(val);
- }
- if (val = fdefined(symbol, file))
- return(val);
- debug1("%s not defined in %s\n", symbol, file->i_file);
- return(NULL);
-}
-
-struct symtab *fdefined(symbol, file)
- register char *symbol;
- struct inclist *file;
-{
- register struct inclist **ip;
- register struct symtab *val;
- register int i;
- static int recurse_lvl = 0;
-
- if (file->i_defchecked)
- return(NULL);
- file->i_defchecked = TRUE;
- if (val = slookup(symbol, file->i_defs))
- debug1("%s defined in %s\n", symbol, file->i_file);
- if (val == NULL && file->i_list)
- for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
- if (val = fdefined(symbol, *ip)) {
- debug1("%s defined in %s\n",
- symbol, (*ip)->i_file);
- break;
- }
- recurse_lvl--;
- file->i_defchecked = FALSE;
-
- return(val);
-}
-
-struct symtab *slookup(symbol, stab)
- register char *symbol;
- register struct symtab *stab;
-{
- if (stab)
- for (; stab->s_name; stab++)
- if (strcmp(symbol, stab->s_name) == 0)
- return(stab);
- return(NULL);
-}
-
-/*
- * Return true if the #if expression evaluates to 0
- */
-zero_value(exp, filep, file_red)
- register char *exp;
- register struct filepointer *filep;
- register struct inclist *file_red;
-{
-#ifdef CPP
- return (cppsetup(exp, filep, file_red) == 0);
-#else CPP
- return(TRUE);
-#endif CPP
-}
-
-define(def, file)
- register char *def;
- register struct inclist *file;
-{
- register char *p;
- struct symtab *sp = file->i_lastdef++;
- register int i;
-
- /*
- * If we are out of space, allocate some more.
- */
- if (file->i_defs == NULL
- || file->i_lastdef == file->i_defs + file->i_deflen) {
- if (file->i_defs)
- file->i_defs = (struct symtab *) realloc(file->i_defs,
- sizeof(struct symtab)*(file->i_deflen+SYMTABINC));
- else
- file->i_defs = (struct symtab *)
- malloc(sizeof (struct symtab) * SYMTABINC);
- i=file->i_deflen;
- file->i_deflen += SYMTABINC;
- while (i < file->i_deflen)
- file->i_defs[ i++ ].s_name = NULL;
- file->i_lastdef = file->i_defs + file->i_deflen - SYMTABINC;
- if (sp) /* be sure we use last cell in previous group */
- file->i_lastdef--;
- sp = file->i_lastdef++;
- }
- else if (file->i_lastdef > file->i_defs + file->i_deflen)
- log_fatal("define() botch\n");
-
- /*
- * copy the symbol being defined.
- */
- p = def;
- while (isalnum(*p) || *p == '_')
- p++;
- if (*p)
- *p++ = '\0';
- sp->s_name = copy(def);
-
- /*
- * And copy its value.
- */
- while (*p == ' ' && *p == '\t')
- p++;
- sp->s_value = copy(p);
-}
+++ /dev/null
-/*
- * $XConsortium: pr.c,v 1.6 88/09/30 08:55:13 jim Exp $
- */
-#include "def.h"
-
-extern struct inclist inclist[ MAXFILES ],
- *inclistp;
-extern char *objfile;
-extern int width;
-extern boolean printed;
-extern boolean verbose;
-extern boolean show_where_not;
-
-add_include(file, file_red, include, dot)
- struct inclist *file, *file_red;
- char *include;
- boolean dot;
-{
- register struct inclist *newfile;
- register struct filepointer *content;
-
- /*
- * First decide what the pathname of this include file really is.
- */
- newfile = inc_path(file->i_file, include, dot);
- if (newfile == NULL) {
- if (file != file_red)
- log("%s (reading %s): ",
- file_red->i_file, file->i_file);
- else
- log("%s: ", file->i_file);
- log("cannot find include file \"%s\"\n", include);
- show_where_not = TRUE;
- newfile = inc_path(file->i_file, include, dot);
- show_where_not = FALSE;
- }
-
- included_by(file, newfile);
- if (!newfile->i_searched) {
- newfile->i_searched = TRUE;
- content = getfile(newfile->i_file);
- find_includes(content, newfile, file_red, 0);
- freefile(content);
- }
-}
-
-recursive_pr_include(head, file, base)
- register struct inclist *head;
- register char *file, *base;
-{
- register int i;
-
- if (head->i_marked)
- return;
- head->i_marked = TRUE;
- if (head->i_file != file)
- pr(head, file, base);
- for (i=0; i<head->i_listlen; i++)
- recursive_pr_include(head->i_list[ i ], file, base);
-}
-
-pr(ip, file, base)
- register struct inclist *ip;
- char *file, *base;
-{
- static char *lastfile;
- static int current_len;
- register int len, i;
- char buf[ BUFSIZ ];
-
- printed = TRUE;
- len = strlen(ip->i_file)+1;
- if (current_len + len > width || file != lastfile) {
- lastfile = file;
- sprintf(buf, "\n%s%s: %s", base, objfile, ip->i_file);
- len = current_len = strlen(buf);
- }
- else {
- buf[0] = ' ';
- strcpy(buf+1, ip->i_file);
- current_len += len;
- }
- fwrite(buf, len, 1, stdout);
-
- /*
- * If verbose is set, then print out what this file includes.
- */
- if (! verbose || ip->i_list == NULL || ip->i_notified)
- return;
- ip->i_notified = TRUE;
- lastfile = NULL;
- printf("\n# %s includes:", ip->i_file);
- for (i=0; i<ip->i_listlen; i++)
- printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
-}
-
-#if defined (mips) && defined (SYSTYPE_SYSV)
-void catch()
-{
- fflush(stdout);
- log_fatal("got signal\n");
-}
-#else /* not (mips && SYSTYPE_SYSV) */
-#ifdef ultrix
-void
-#endif
-catch(n)
-{
- fflush(stdout);
- log_fatal("got signal %d\n", n);
-}
-#endif /* mips && SYSTYPE_SYSV */
-