file reorg, pathnames.h, paths.h
[unix-history] / usr / src / usr.bin / f77 / f77.vax / f77.c
index 172636a..2cf0a18 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)f77.c      5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)f77.c      5.5 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -16,6 +16,18 @@ static       char sccsid[] = "@(#)f77.c      5.1 (Berkeley) %G%";
  * University of Utah CS Dept modification history:
  *
  * $Log:       f77.c,v $
  * University of Utah CS Dept modification history:
  *
  * $Log:       f77.c,v $
+ * Revision 5.4  85/12/17  19:12:14  donn
+ * Dynamically allocate buffer; add lint fixes.
+ * 
+ * Revision 5.3  85/11/25  00:00:02  donn
+ * 4.3 beta
+ * 
+ * Revision 5.2  85/08/10  05:16:14  donn
+ * Ifdeffed 66 code, added -r8 flag.  From Jerry Berkman.
+ * 
+ * Revision 5.1  85/08/10  03:32:12  donn
+ * 4.3 alpha
+ * 
  * Revision 1.14  85/03/01  00:07:57  donn
  * Portability fix from Ralph Campbell.
  * 
  * Revision 1.14  85/03/01  00:07:57  donn
  * Portability fix from Ralph Campbell.
  * 
@@ -68,12 +80,12 @@ static      char sccsid[] = "@(#)f77.c      5.1 (Berkeley) %G%";
  * 
  */
 
  * 
  */
 
-char *xxxvers[] = "\n@(#) F77 DRIVER, VERSION 4.2,   1984 JULY 28\n";
-#include <stdio.h>
+char *xxxvers = "\n@(#) F77 DRIVER, VERSION 4.2,   1984 JULY 28\n";
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/signal.h>
 #include <ctype.h>
 #include <ctype.h>
-#include <signal.h>
+#include <stdio.h>
 
 #ifdef SIGPROF
 /*
 
 #ifdef SIGPROF
 /*
@@ -88,7 +100,7 @@ char *xxxvers[] = "\n@(#) F77 DRIVER, VERSION 4.2,   1984 JULY 28\n";
 
 #include "defines.h"
 #include "machdefs.h"
 
 #include "defines.h"
 #include "machdefs.h"
-#include "drivedefs.h"
+#include "pathnames.h"
 #include "version.h"
 
 static FILEP diagfile  = {stderr} ;
 #include "version.h"
 
 static FILEP diagfile  = {stderr} ;
@@ -106,8 +118,8 @@ static char *ldname = LDNAME ;
 static char *footname  = FOOTNAME;
 static char *proffoot  = PROFFOOT;
 static char *macroname = "m4";
 static char *footname  = FOOTNAME;
 static char *proffoot  = PROFFOOT;
 static char *macroname = "m4";
-static char *shellname = "/bin/sh";
-static char *cppname   = "/lib/cpp";
+static char *shellname = _PATH_BSHELL;
+static char *cppname   = _PATH_CPP;
 static char *aoutname  = "a.out" ;
 static char *temppref  = TEMPPREF;
 
 static char *aoutname  = "a.out" ;
 static char *temppref  = TEMPPREF;
 
@@ -134,7 +146,6 @@ static char rflags[30]      = "";
 static char lflag[3]   = "-x";
 static char *fflagp    = fflags+1;
 static char *f2flagp   = f2flags;
 static char lflag[3]   = "-x";
 static char *fflagp    = fflags+1;
 static char *f2flagp   = f2flags;
-static char *cflagp    = cflags+2;
 static char *eflagp    = eflags+12;
 static char *rflagp    = rflags;
 static char *cppflags  = "";
 static char *eflagp    = eflags+12;
 static char *rflagp    = rflags;
 static char *cppflags  = "";
@@ -149,12 +160,15 @@ static flag profileflag   = NO;
 static flag optimflag  = NO;
 static flag debugflag  = NO;
 static flag verbose    = NO;
 static flag optimflag  = NO;
 static flag debugflag  = NO;
 static flag verbose    = NO;
-static flag nofloating = NO;
 static flag fortonly   = NO;
 static flag macroflag  = NO;
 static flag sdbflag    = NO;
 static flag namesflag  = YES;
 
 static flag fortonly   = NO;
 static flag macroflag  = NO;
 static flag sdbflag    = NO;
 static flag namesflag  = YES;
 
+#if TARGET == PDP11
+static flag nofloating = NO;
+#endif
+
 static int ncpp;
 
 \f
 static int ncpp;
 
 \f
@@ -162,12 +176,14 @@ main(argc, argv)
 int argc;
 char **argv;
 {
 int argc;
 char **argv;
 {
-int i, c, status;
+register int i, n;
+int c, status;
 char *setdoto(), *lastchar(), *lastfield(), *copys(), *argvtos();
 ptr ckalloc();
 char *setdoto(), *lastchar(), *lastfield(), *copys(), *argvtos();
 ptr ckalloc();
+char *strcat();
 register char *s;
 char fortfile[20], *t;
 register char *s;
 char fortfile[20], *t;
-char buff[100];
+char *buff;
 int intrupt();
 int new_aoutname = NO;
 
 int intrupt();
 int new_aoutname = NO;
 
@@ -195,6 +211,10 @@ loadp = loadargs + 4;
 --argc;
 ++argv;
 
 --argc;
 ++argv;
 
+for (i = 0, n = 50; i < argc; ++i)
+       n += strlen(argv[i]) + 1;
+buff = (char *) ckalloc(n);
+
 while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
        {
        for(s = argv[0]+1 ; *s ; ++s) switch(*s)
 while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
        {
        for(s = argv[0]+1 ; *s ; ++s) switch(*s)
@@ -223,6 +243,7 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                                }
                        break;
 
                                }
                        break;
 
+#ifdef ONLY66
                case '6':
                        if(s[1]=='6')
                                {
                case '6':
                        if(s[1]=='6')
                                {
@@ -233,6 +254,7 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                                fprintf(diagfile, "invalid flag 6%c\n", s[1]);
                                done(1);
                                }
                                fprintf(diagfile, "invalid flag 6%c\n", s[1]);
                                done(1);
                                }
+#endif
 
                case 'w':
                        if(s[1]=='6' && s[2]=='6')
 
                case 'w':
                        if(s[1]=='6' && s[2]=='6')
@@ -286,7 +308,7 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                        break;
 
                case 'S':
                        break;
 
                case 'S':
-                       strcat(cflags, " -S");
+                       (void) strcat(cflags, " -S");
                        saveasmflag = YES;
 
                case 'c':
                        saveasmflag = YES;
 
                case 'c':
@@ -322,13 +344,13 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                                fprintf(diagfile, "-g and -O are incompatible; -g ignored\n");
                                break;
                                }
                                fprintf(diagfile, "-g and -O are incompatible; -g ignored\n");
                                break;
                                }
-                       strcat(cflags," -g");
+                       (void) strcat(cflags," -g");
                        sdbflag = YES;
                        goto copyfflag;
 
                case 'p':
                        profileflag = YES;
                        sdbflag = YES;
                        goto copyfflag;
 
                case 'p':
                        profileflag = YES;
-                       strcat(cflags," -p");
+                       (void) strcat(cflags," -p");
                        *fflagp++ = 'p';
                        if(s[1] == 'g')
                                {
                        *fflagp++ = 'p';
                        if(s[1] == 'g')
                                {
@@ -382,6 +404,18 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                        fprintf(diagfile, "invalid flag -i%c\n", s[1]);
                        done(1);
 
                        fprintf(diagfile, "invalid flag -i%c\n", s[1]);
                        done(1);
 
+               case 'r':       /* -r8 - double the precision */
+                       if(s[1] == '8' && s[2] == '\0')
+                               {
+                               s++;
+                               goto copyfflag;
+                               }
+                       else
+                               {
+                               *loadp++ = "-r";
+                               break;
+                               }
+
                case 'l':       /* letter ell--library */
                        s[-1] = '-';
                        *loadp++ = s-1;
                case 'l':       /* letter ell--library */
                        s[-1] = '-';
                        *loadp++ = s-1;
@@ -413,7 +447,7 @@ if(!debugflag)
        struct rlimit r;
 
        r.rlim_cur = r.rlim_max = 0;
        struct rlimit r;
 
        r.rlim_cur = r.rlim_max = 0;
-       setrlimit(RLIMIT_CORE, &r);
+       (void) setrlimit(RLIMIT_CORE, &r);
        }
 #endif NOCORE
 
        }
 #endif NOCORE
 
@@ -727,7 +761,8 @@ obj = setdoto(s);
                else
                        {
                        sprintf(buff,"mv %s %s", optzfname, asmpass2);
                else
                        {
                        sprintf(buff,"mv %s %s", optzfname, asmpass2);
-                       sys(buff);
+                       if( sys(buff) )
+                               fatal("can't rename optimizer output file");
                        }
                }
 #      endif
                        }
                }
 #      endif
@@ -752,7 +787,8 @@ if(saveasmflag)
                CATNAME, asmfname, initfname, asmpass2, obj);
 #endif
 #endif
                CATNAME, asmfname, initfname, asmpass2, obj);
 #endif
 #endif
-       sys(buff);
+       if( sys(buff) )
+               fatal("can't concatenate assembly files");
        *lastc = 'o';
        }
 else
        *lastc = 'o';
        }
 else
@@ -772,7 +808,8 @@ else
        else
                sprintf(buff, "%s %s %s >>%s",
                        CATNAME, initfname, asmpass2, asmfname);
        else
                sprintf(buff, "%s %s %s >>%s",
                        CATNAME, initfname, asmpass2, asmfname);
-       sys(buff);
+       if( sys(buff) )
+               fatal("can't concatenate assembly files");
 #ifdef UCBVAXASM
        sprintf(buff, "%s -J -o %s %s", asmname, obj, asmfname);
 #else
 #ifdef UCBVAXASM
        sprintf(buff, "%s -J -o %s %s", asmname, obj, asmfname);
 #else
@@ -840,7 +877,8 @@ if(debugflag)
                execv(ldname, v0);
                fatalstr("couldn't load %s", ldname);
                }
                execv(ldname, v0);
                fatalstr("couldn't load %s", ldname);
                }
-       await(waitpid);
+       if( await(waitpid) )
+               erred = YES;
 #endif
 
 #if HERE==INTERDATA
 #endif
 
 #if HERE==INTERDATA
@@ -864,7 +902,7 @@ sys(str)
 char *str;
 {
 register char *s, *t;
 char *str;
 {
 register char *s, *t;
-char *argv[100], path[100];
+char *argv[100];
 char *inname, *outname;
 int append;
 int waitpid;
 char *inname, *outname;
 int append;
 int waitpid;
@@ -913,25 +951,19 @@ if(argc == 1)   /* no command */
        return(-1);
 argv[argc] = 0;
 
        return(-1);
 argv[argc] = 0;
 
-s = path;
-t = "/usr/bin/";
-while(*t)
-       *s++ = *t++;
-for(t = argv[1] ; *s++ = *t++ ; )
-       ;
 if((waitpid = fork()) == 0)
        {
        if(inname)
 if((waitpid = fork()) == 0)
        {
        if(inname)
-               freopen(inname, "r", stdin);
+               if(freopen(inname, "r", stdin) == NULL)
+                       fatalstr("Cannot open %s", inname);
        if(outname)
        if(outname)
-               freopen(outname, (append ? "a" : "w"), stdout);
+               if(freopen(outname, (append ? "a" : "w"), stdout) == NULL)
+                       fatalstr("Cannot open %s", outname);
        enbint(SIG_DFL);
 
        enbint(SIG_DFL);
 
-       texec(path+9, argv);  /* command */
-       texec(path+4, argv);  /*  /bin/command */
-       texec(path  , argv);  /* /usr/bin/command */
+       texec(argv[1], argv);
 
 
-       fatalstr("Cannot load %s",path+9);
+       fatalstr("Cannot load %s", argv[1]);
        }
 
 return( await(waitpid) );
        }
 
 return( await(waitpid) );
@@ -989,13 +1021,13 @@ enbint(k)
 int (*k)();
 {
 if(sigivalue == 0)
 int (*k)();
 {
 if(sigivalue == 0)
-       signal(SIGINT,k);
+       (void) signal(SIGINT,k);
 if(sigqvalue == 0)
 if(sigqvalue == 0)
-       signal(SIGQUIT,k);
+       (void) signal(SIGQUIT,k);
 if(sighvalue == 0)
 if(sighvalue == 0)
-       signal(SIGHUP,k);
+       (void) signal(SIGHUP,k);
 if(sigtvalue == 0)
 if(sigtvalue == 0)
-       signal(SIGTERM,k);
+       (void) signal(SIGTERM,k);
 }
 
 
 }
 
 
@@ -1084,6 +1116,7 @@ stupid(s)
 char *s;
 {
 char c;
 char *s;
 {
 char c;
+extern char *index();
 
 if( (c = dotchar(s))
   && index("focsreF", c)
 
 if( (c = dotchar(s))
   && index("focsreF", c)
@@ -1189,7 +1222,7 @@ if(fn!=NULL && *fn!='\0')
 LOCAL fname(name, suff)
 char *name, *suff;
 {
 LOCAL fname(name, suff)
 char *name, *suff;
 {
-sprintf(name, "/tmp/%s%d.%s", temppref, pid, suff);
+sprintf(name, "%s/%s%d.%s", _PATH_TMP, temppref, pid, suff);
 }
 
 
 }
 
 
@@ -1246,9 +1279,10 @@ fatalstr("cannot open intermediate file %s", s);
 ptr ckalloc(n)
 int n;
 {
 ptr ckalloc(n)
 int n;
 {
-ptr p, calloc();
+ptr p;
+extern char *calloc();
 
 
-if( p = calloc(1, (unsigned) n) )
+if( p = (ptr) calloc(1, (unsigned) n) )
        return(p);
 
 fatal("out of memory");
        return(p);
 
 fatal("out of memory");