date and time created 83/08/05 13:34:37 by sam
[unix-history] / usr / src / old / make / files.c
index f36331d..d568d9a 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)files.c     4.3 (Berkeley) 82/03/14";
+static char *sccsid = "@(#)files.c     4.8 (Berkeley) 83/06/30";
 /* UNIX DEPENDENT PROCEDURES */
 
 
 /* UNIX DEPENDENT PROCEDURES */
 
 
@@ -9,7 +9,7 @@ char *builtin[] =
 #ifdef pwb
        ".SUFFIXES : .L .out .o .c .f .e .r .y .yr .ye .l .s .z .x .t .h .cl",
 #else
 #ifdef pwb
        ".SUFFIXES : .L .out .o .c .f .e .r .y .yr .ye .l .s .z .x .t .h .cl",
 #else
-       ".SUFFIXES : .out .o .c .f .e .r .y .yr .ye .l .s .cl .p",
+       ".SUFFIXES : .out .o .c .F .f .e .r .y .yr .ye .l .s .cl .p",
 #endif
        "YACC=yacc",
        "YACCR=yacc -r",
 #endif
        "YACC=yacc",
        "YACCR=yacc -r",
@@ -18,7 +18,7 @@ char *builtin[] =
        "LEX=lex",
        "LFLAGS=",
        "CC=cc",
        "LEX=lex",
        "LFLAGS=",
        "CC=cc",
-#ifdef vax
+#if defined(vax) || defined(sun)
        "AS=as",
 #else
        "AS=as -",
        "AS=as",
 #else
        "AS=as -",
@@ -48,7 +48,7 @@ char *builtin[] =
        ".cl.o :",
        "\tclass -c $<",
 
        ".cl.o :",
        "\tclass -c $<",
 
-       ".e.o .r.o .f.o :",
+       ".e.o .r.o .F.o .f.o :",
        "\t$(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<",
 
        ".s.o :",
        "\t$(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<",
 
        ".s.o :",
@@ -114,7 +114,7 @@ char *builtin[] =
        ".s.out .c.out .o.out :",
        "\t$(CC) $(CFLAGS) $< $(LOADLIBES) -o $@",
 
        ".s.out .c.out .o.out :",
        "\t$(CC) $(CFLAGS) $< $(LOADLIBES) -o $@",
 
-       ".f.out .r.out .e.out :",
+       ".f.out .F.out .r.out .e.out :",
        "\t$(FC) $(EFLAGS) $(RFLAGS) $(FFLAGS) $< $(LOADLIBES) -o $@",
        "\t-rm $*.o",
 
        "\t$(FC) $(EFLAGS) $(RFLAGS) $(FFLAGS) $< $(LOADLIBES) -o $@",
        "\t-rm $*.o",
 
@@ -131,7 +131,6 @@ char *builtin[] =
        0 };
 \f
 #include "defs"
        0 };
 \f
 #include "defs"
-#include <sys/types.h>
 
 
 TIMETYPE exists(filename)
 
 
 TIMETYPE exists(filename)
@@ -148,11 +147,7 @@ for(s = filename ; *s!='\0' && *s!='(' ; ++s)
 if(*s == '(')
        return(lookarch(filename));
 
 if(*s == '(')
        return(lookarch(filename));
 
-#if vax
-if (lstat(filename, &buf) < 0)
-#else
-if(stat(filename,&buf) < 0) 
-#endif
+if (stat(filename, &buf) < 0)
        return(0);
 else   return(buf.st_mtime);
 }
        return(0);
 else   return(buf.st_mtime);
 }
@@ -167,9 +162,8 @@ return(t);
 
 \f
 
 
 \f
 
-#include <sys/dir.h>
-FSTATIC char n15[15];
-FSTATIC char *n15end   = &n15[14];
+FSTATIC char nbuf[MAXNAMLEN + 1];
+FSTATIC char *nbufend  = &nbuf[MAXNAMLEN];
 
 
 
 
 
 
@@ -178,17 +172,17 @@ register char *pat; /* pattern to be matched in directory */
 int mkchain;  /* nonzero if results to be remembered */
 struct depblock *nextdbl;  /* final value for chain */
 {
 int mkchain;  /* nonzero if results to be remembered */
 struct depblock *nextdbl;  /* final value for chain */
 {
-FILE * dirf;
+DIR *dirf;
 register int i;
 int nread, cldir;
 char *dirname, *dirpref, *endir, *filepat, *p, temp[100];
 char fullname[100], *p1, *p2;
 struct nameblock *q;
 struct depblock *thisdbl;
 register int i;
 int nread, cldir;
 char *dirname, *dirpref, *endir, *filepat, *p, temp[100];
 char fullname[100], *p1, *p2;
 struct nameblock *q;
 struct depblock *thisdbl;
-struct opendir *od;
+struct dirhdr *od;
 struct pattern *patp;
 
 struct pattern *patp;
 
-struct direct entry[32];
+struct direct *dptr;
 
 
 thisdbl = 0;
 
 
 thisdbl = 0;
@@ -227,18 +221,19 @@ for(od = firstod; od; od = od->nxtopendir)
        if(! unequal(dirname, od->dirn) )
                {
                dirf = od->dirfc;
        if(! unequal(dirname, od->dirn) )
                {
                dirf = od->dirfc;
-               fseek(dirf, 0L, 0); /* start over at the beginning  */
+               if (dirf != NULL)
+                       rewinddir(dirf); /* start over at the beginning  */
                break;
                }
 
 if(dirf == NULL)
        {
                break;
                }
 
 if(dirf == NULL)
        {
-       dirf = fopen(dirname, "r");
+       dirf = opendir(dirname);
        if(nopdir >= MAXDIR)
                cldir = YES;
        else    {
                ++nopdir;
        if(nopdir >= MAXDIR)
                cldir = YES;
        else    {
                ++nopdir;
-               od = ALLOC(opendir);
+               od = ALLOC(dirhdr);
                od->nxtopendir = firstod;
                firstod = od;
                od->dirfc = dirf;
                od->nxtopendir = firstod;
                firstod = od;
                od->dirfc = dirf;
@@ -252,37 +247,33 @@ if(dirf == NULL)
        fatal("Cannot open");
        }
 
        fatal("Cannot open");
        }
 
-else do
+else for (dptr = readdir(dirf); dptr != NULL; dptr = readdir(dirf))
        {
        {
-       nread = fread( (char *) &entry[0], sizeof(struct direct), 32, dirf) ;
-       for(i=0; i<nread; ++i)
-               if(entry[i].d_ino!= 0)
+       p1 = dptr->d_name;
+       p2 = nbuf;
+       while( (p2<nbufend) && (*p2++ = *p1++)!='\0' )
+               /* void */;
+       if( amatch(nbuf,filepat) )
+               {
+               concat(dirpref,nbuf,fullname);
+               if( (q=srchname(fullname)) ==0)
+                       q = makename(copys(fullname));
+               if(mkchain)
                        {
                        {
-                       p1 = entry[i].d_name;
-                       p2 = n15;
-                       while( (p2<n15end) &&
-                         (*p2++ = *p1++)!='\0' );
-                       if( amatch(n15,filepat) )
-                               {
-                               concat(dirpref,n15,fullname);
-                               if( (q=srchname(fullname)) ==0)
-                                       q = makename(copys(fullname));
-                               if(mkchain)
-                                       {
-                                       thisdbl = ALLOC(depblock);
-                                       thisdbl->nxtdepblock = nextdbl;
-                                       thisdbl->depname = q;
-                                       nextdbl = thisdbl;
-                                       }
-                               }
+                       thisdbl = ALLOC(depblock);
+                       thisdbl->nxtdepblock = nextdbl;
+                       thisdbl->depname = q;
+                       nextdbl = thisdbl;
                        }
                        }
-
-       } while(nread==32);
+               }
+       }
 
 if(endir != 0)  *endir = '/';
 
 
 if(endir != 0)  *endir = '/';
 
-if(cldir)
-       fclose(dirf);
+if(cldir) {
+       closedir(dirf);
+       dirf = NULL;
+}
 return(thisdbl);
 }
 \f
 return(thisdbl);
 }
 \f
@@ -393,7 +384,7 @@ static struct nlist objentry;
 TIMETYPE lookarch(filename)
 char *filename;
 {
 TIMETYPE lookarch(filename)
 char *filename;
 {
-char *p, *q, *send, s[15];
+char *p, *q, *send, s[MAXNAMLEN + 1];
 int i, nc, nsym, objarch;
 
 for(p = filename; *p!= '(' ; ++p)
 int i, nc, nsym, objarch;
 
 for(p = filename; *p!= '(' ; ++p)
@@ -411,7 +402,7 @@ if(*p == '(')
 else
        {
        objarch = NO;
 else
        {
        objarch = NO;
-       nc = 14;
+       nc = MAXNAMLEN;
        }
 send = s + nc;
 
        }
 send = s + nc;
 
@@ -466,11 +457,7 @@ int word;
 #include <sys/stat.h>
 struct stat buf;
 
 #include <sys/stat.h>
 struct stat buf;
 
-#if vax
-lstat(f, &buf);
-#else
 stat(f, &buf);
 stat(f, &buf);
-#endif
 arlen = buf.st_size;
 
 arfd = fopen(f, "r");
 arlen = buf.st_size;
 
 arfd = fopen(f, "r");
@@ -526,7 +513,7 @@ fread( (char *) &objhead, sizeof(objhead), 1, arfd);
 if (N_BADMAG(objhead))
        fatal1("%s is not an object module", arfname);
 skip = objhead.a_text + objhead.a_data;
 if (N_BADMAG(objhead))
        fatal1("%s is not an object module", arfname);
 skip = objhead.a_text + objhead.a_data;
-#ifdef vax
+#if defined(vax) || defined(sun)
 skip += objhead.a_trsize + objhead.a_drsize;
 #else
 if(! objhead.a_flag )
 skip += objhead.a_trsize + objhead.a_drsize;
 #else
 if(! objhead.a_flag )