Added some code for dependency generator
authorceriel <none@none>
Tue, 23 Jan 1990 15:25:21 +0000 (15:25 +0000)
committerceriel <none@none>
Tue, 23 Jan 1990 15:25:21 +0000 (15:25 +0000)
util/cpp/Makefile
util/cpp/Parameters
util/cpp/domacro.c
util/cpp/idf.h
util/cpp/macro.h
util/cpp/main.c
util/cpp/preprocess.c
util/cpp/replace.c

index 49ca7b2..e4b2f53 100644 (file)
@@ -62,7 +62,7 @@ GSRC =        char.c symbol2str.c
 GHSRC =        errout.h idfsize.h ifdepth.h lapbuf.h \
        nparams.h numsize.h obufsize.h \
        parbufsize.h pathlength.h strsize.h textsize.h \
-       botch_free.h debug.h inputtype.h dobits.h line_prefix.h
+       botch_free.h debug.h inputtype.h dobits.h line_prefix.h mkdep.h
 
 # Other generated files, for 'make clean' only
 GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \
@@ -172,6 +172,7 @@ domacro.o: input.h
 domacro.o: inputtype.h
 domacro.o: interface.h
 domacro.o: macro.h
+domacro.o: mkdep.h
 domacro.o: nparams.h
 domacro.o: parbufsize.h
 domacro.o: textsize.h
@@ -188,7 +189,10 @@ input.o: file_info.h
 input.o: input.h
 input.o: inputtype.h
 main.o: file_info.h
+main.o: idf.h
 main.o: idfsize.h
+main.o: macro.h
+main.o: mkdep.h
 options.o: charoffset.h
 options.o: class.h
 options.o: idf.h
@@ -205,6 +209,7 @@ preprocess.o: idfsize.h
 preprocess.o: input.h
 preprocess.o: inputtype.h
 preprocess.o: line_prefix.h
+preprocess.o: mkdep.h
 preprocess.o: obufsize.h
 replace.o: LLlex.h
 replace.o: charoffset.h
index 35aa033..32ba2fd 100644 (file)
 #define LINE_PREFIX    "#"     /* prefix for generated line directives,
                                   either "#" or "#line"
                                */
+
+
+!File: mkdep.h
+#undef MKDEP           1       /* if defined, preprocessor only outputs
+                                  names of files included (not finished yet)
+                               */
+
+
+
index d011401..f0c0b29 100644 (file)
@@ -23,6 +23,7 @@
 #include       "class.h"
 #include       "macro.h"
 #include       "bits.h"
+#include       "mkdep.h"
 
 IMPORT char **inctable;                /* list of include directories          */
 IMPORT char *getwdir();
@@ -273,9 +274,17 @@ do_include()
        inctable[0] = WorkingDir;
        if (filenm) {
                if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
+#ifndef MKDEP
                        error("cannot find include file \"%s\"", filenm);
+#else
+                       warning("cannot find include file \"%s\"", filenm);
+                       add_file(filenm);
+#endif
                }
                else {
+#ifdef MKDEP
+                       add_file(result);
+#endif
                        WorkingDir = getwdir(result);
                        svnestlevel[++nestcount] = nestlevel;
                        FileName = result;
index 9988360..ab926f9 100644 (file)
@@ -4,13 +4,17 @@
  * See the copyright notice in the ACK home directory, in the file "Copyright".
  */
 struct id_usr {
-       struct macro *idu_macro;
+       union {
+               struct macro *idu_macro;
+               struct idf *idu_file;
+       } idu_x;
        int idu_resmac;
 };
 
 #define IDF_TYPE struct id_usr
 #define IDF_HSIZE 6
-#define id_macro id_user.idu_macro
+#define id_macro id_user.idu_x.idu_macro
+#define id_file id_user.idu_x.idu_file
 #define id_resmac id_user.idu_resmac
 
 #include <idf_pkg.spec>
index b9b3383..175d5e9 100644 (file)
@@ -75,3 +75,4 @@ extern char *std_alloc();
 #define        K_LINE          9
 #define        K_UNDEF         10
 #define K_PRAGMA       11
+#define K_FILE         100     /* for dependency generator */
index 5ac7408..70852a3 100644 (file)
@@ -7,13 +7,20 @@
 
 #include <alloc.h>
 #include <em_arith.h>
+#include <assert.h>
 #include "file_info.h"
 #include "idfsize.h"
+#include "mkdep.h"
+#ifdef MKDEP
+#include "idf.h"
+#include "macro.h"
+#endif
 
 extern char *symbol2str();
 extern char *getwdir();
 extern int err_occurred;
 int idfsize = IDFSIZE;
+extern char options[];
 
 arith ifval;
 
@@ -49,6 +56,9 @@ main(argc, argv)
                do_option(par);
                argc--, argv++;
        }
+#ifdef MKDEP
+       options['P'] = 1;
+#endif
        compile(argc - 1, &argv[1]);
        exit(err_occurred);
 }
@@ -79,4 +89,34 @@ compile(argc, argv)
                        source ? source : "stdin");
        if (source) WorkingDir = getwdir(dummy);
        preprocess(source);
+#ifdef MKDEP
+       list_files();
+#endif
 }
+
+#ifdef MKDEP
+struct idf     *file_head;
+
+list_files()
+{
+       register struct idf *p = file_head;
+
+       while (p) {
+               assert(p->id_resmac == K_FILE);
+               print("%s\n", p->id_text);
+               p = p->id_file;
+       }
+}
+
+add_file(s)
+       char *s;
+{
+       register struct idf *p = str2idf(s, 0);
+
+       if (! p->id_resmac) {
+               p->id_resmac = K_FILE;
+               p->id_file = file_head;
+               file_head = p;
+       }
+}
+#endif
index 20dbaee..d3814b5 100644 (file)
 #include "idfsize.h"
 #include "bits.h"
 #include "line_prefix.h"
-
-char _obuf[OBUFSIZE];
+#include "mkdep.h"
 
 #ifdef DOBITS
 char bits[128];
 #endif
 
+#ifndef MKDEP
+char _obuf[OBUFSIZE];
+
 Xflush()
 {
        sys_write(STDOUT, _obuf, OBUFSIZE);
 }
+#endif
 
 preprocess(fn)
        char *fn;
 {
        register int c;
+#ifndef MKDEP
        register char *op = _obuf;
        register char *ob = &_obuf[OBUFSIZE];
+#endif
        char Xbuf[256];
        int lineno = 0;
        extern char options[];
 
+#ifndef MKDEP
 #define flush(X)       (sys_write(STDOUT,_obuf,X))
 #define echo(ch)       if (op == ob) { Xflush(); op = _obuf; } *op++ = (ch);
 #define newline()      echo('\n')
+#else
+#define flush(X)
+#define echo(ch)       (ch)
+#define newline()
+#endif
 
        if (! options['P']) {
                /* Generate a line directive communicating the
index 8c4dd96..abf8309 100644 (file)
@@ -78,7 +78,6 @@ replace(idef)
                        struct idf *param;
                        char *nam;
                        extern char *GetIdentifier();
-                       extern struct idf *str2idf();
 
                        UnknownIdIsZero = 0;
                        nam = GetIdentifier();