BSD 4 release
[unix-history] / usr / src / cmd / f77 / driver.c
index 7fefae3..bb8b760 100644 (file)
@@ -1,4 +1,4 @@
-char *xxxvers[] = "\n FORTRAN 77 DRIVER, VERSION 2.00,   7 JANUARY 1980\n";
+char *xxxvers[] = "\n@(#) FORTRAN 77 DRIVER, VERSION 2.03.5,   7 NOVEMBER 1980\n";
 #include <stdio.h>
 #include <ctype.h>
 #include "defines"
 #include <stdio.h>
 #include <ctype.h>
 #include "defines"
@@ -23,26 +23,31 @@ static char *proffoot       = PROFFOOT;
 static char *macroname = "m4";
 static char *shellname = "/bin/sh";
 static char *aoutname  = "a.out" ;
 static char *macroname = "m4";
 static char *shellname = "/bin/sh";
 static char *aoutname  = "a.out" ;
+static char *temppref  = TEMPPREF;
 
 static char *infname;
 
 static char *infname;
-static char textfname[15];
-static char asmfname[15];
-static char asmpass2[15];
-static char initfname[15];
-static char sortfname[15];
-static char prepfname[15];
-static char objfdefault[15];
-static char optzfname[15];
-static char setfname[15];
+static char textfname[40];
+static char asmfname[40];
+static char asmpass2[40];
+static char initfname[40];
+static char sortfname[40];
+static char prepfname[40];
+static char objfdefault[40];
+static char optzfname[40];
+static char setfname[40];
 
 static char fflags[50] = "-";
 
 static char fflags[50] = "-";
-static char cflags[20] = "-c";
-static char eflags[30] = "";
+static char cflags[50] = "-c";
+#if TARGET == GCOS
+       static char eflags[30]  = "system=gcos ";
+#else
+       static char eflags[30]  = "system=unix ";
+#endif
 static char rflags[30] = "";
 static char lflag[3]   = "-x";
 static char *fflagp    = fflags+1;
 static char *cflagp    = cflags+2;
 static char rflags[30] = "";
 static char lflag[3]   = "-x";
 static char *fflagp    = fflags+1;
 static char *cflagp    = cflags+2;
-static char *eflagp    = eflags;
+static char *eflagp    = eflags+12;
 static char *rflagp    = rflags;
 static char **loadargs;
 static char **loadp;
 static char *rflagp    = rflags;
 static char **loadargs;
 static char **loadp;
@@ -57,6 +62,8 @@ static flag verbose   = NO;
 static flag nofloating = NO;
 static flag fortonly   = NO;
 static flag macroflag  = NO;
 static flag nofloating = NO;
 static flag fortonly   = NO;
 static flag macroflag  = NO;
+static flag sdbflag    = NO;
+
 
 \f
 main(argc, argv)
 
 \f
 main(argc, argv)
@@ -64,7 +71,7 @@ int argc;
 char **argv;
 {
 int i, c, status;
 char **argv;
 {
 int i, c, status;
-char *setdoto(), *lastchar(), *lastfield();
+char *setdoto(), *lastchar(), *lastfield(), *copys();
 ptr ckalloc();
 register char *s;
 char fortfile[20], *t;
 ptr ckalloc();
 register char *s;
 char fortfile[20], *t;
@@ -113,6 +120,8 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                                        footname = s+1; goto endfor;
                                case 'm':
                                        macroname = s+1; goto endfor;
                                        footname = s+1; goto endfor;
                                case 'm':
                                        macroname = s+1; goto endfor;
+                               case 't':
+                                       temppref = s+1; goto endfor;
                                default:
                                        fatali("bad option -T%c", *s);
                                }
                                default:
                                        fatali("bad option -T%c", *s);
                                }
@@ -139,10 +148,8 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                copyfflag:
                case 'u':
                case 'U':
                copyfflag:
                case 'u':
                case 'U':
-               case 'M':
                case '1':
                case 'C':
                case '1':
                case 'C':
-               case 'g':
                        *fflagp++ = *s;
                        break;
 
                        *fflagp++ = *s;
                        break;
 
@@ -177,6 +184,7 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                        break;
 
                case 'S':
                        break;
 
                case 'S':
+                       strcat(cflags, " -S");
                        saveasmflag = YES;
 
                case 'c':
                        saveasmflag = YES;
 
                case 'c':
@@ -191,9 +199,18 @@ while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0')
                        debugflag = YES;
                        goto copyfflag;
 
                        debugflag = YES;
                        goto copyfflag;
 
+               case 'M':
+                       *loadp++ = "-M";
+                       break;
+
+               case 'g':
+                       strcat(cflags," -g");
+                       sdbflag = YES;
+                       goto copyfflag;
+
                case 'p':
                        profileflag = YES;
                case 'p':
                        profileflag = YES;
-                       *cflagp++ = 'p';
+                       strcat(cflags," -p");
                        goto copyfflag;
 
                case 'o':
                        goto copyfflag;
 
                case 'o':
@@ -339,7 +356,7 @@ for(i = 0 ; i<argc ; ++i)
 #if HERE==PDP11 || HERE==VAX
                        fprintf(diagfile, "%s:\n", argv[i]);
 #endif
 #if HERE==PDP11 || HERE==VAX
                        fprintf(diagfile, "%s:\n", argv[i]);
 #endif
-                       sprintf(buff, "cc -c %s", argv[i] );
+                       sprintf(buff, "cc %s %s", cflags, argv[i] );
                        if( sys(buff) )
                                erred = YES;
                        else
                        if( sys(buff) )
                                erred = YES;
                        else
@@ -428,7 +445,7 @@ if(verbose)
 #      if TARGET==INTERDATA
        sprintf(buff, "%s -A%s <%s >%s", pass2name, setfname, textfname, asmpass2);
 #      else
 #      if TARGET==INTERDATA
        sprintf(buff, "%s -A%s <%s >%s", pass2name, setfname, textfname, asmpass2);
 #      else
-       sprintf(buff, "%s <%s >%s", pass2name, textfname, asmpass2);
+       sprintf(buff, "%s %s >%s", pass2name, textfname, asmpass2);
 #      endif
        return( sys(buff) );
 #endif
 #      endif
        return( sys(buff) );
 #endif
@@ -443,6 +460,7 @@ char *s;
 register char *lastc;
 char *obj;
 char buff[200];
 register char *lastc;
 char *obj;
 char buff[200];
+char *lastchar(), *setdoto();
 
 if(*s == '\0')
        s = objfdefault;
 
 if(*s == '\0')
        s = objfdefault;
@@ -519,6 +537,8 @@ register char *v0[], *v[];
 char **p;
 int waitpid;
 
 char **p;
 int waitpid;
 
+if(sdbflag)
+       *v++ = "-lg";
 for(p = liblist ; *p ; *v++ = *p++)
        ;
 
 for(p = liblist ; *p ; *v++ = *p++)
        ;
 
@@ -843,7 +863,7 @@ if(!debugflag && fn!=NULL && *fn!='\0')
 LOCAL fname(name, suff)
 char *name, *suff;
 {
 LOCAL fname(name, suff)
 char *name, *suff;
 {
-sprintf(name, "fort%d.%s", pid, suff);
+sprintf(name, "%s%d.%s", temppref, pid, suff);
 }
 
 
 }
 
 
@@ -913,7 +933,7 @@ fatal("out of memory");
 
 
 
 
 
 
-copyn(n, s)
+char *copyn(n, s)
 register int n;
 register char *s;
 {
 register int n;
 register char *s;
 {
@@ -927,7 +947,7 @@ return(p);
 
 
 
 
 
 
-copys(s)
+char *copys(s)
 char *s;
 {
 return( copyn( strlen(s)+1 , s) );
 char *s;
 {
 return( copyn( strlen(s)+1 , s) );
@@ -1001,6 +1021,8 @@ char *s;
 fprintf(diagfile, "Error in file %s: %s\n", infname, s);
 }
 \f
 fprintf(diagfile, "Error in file %s: %s\n", infname, s);
 }
 \f
+/* Code to generate initializations for DATA statements */
+
 LOCAL int nch  = 0;
 LOCAL FILEP asmfile;
 LOCAL FILEP sortfile;
 LOCAL int nch  = 0;
 LOCAL FILEP asmfile;
 LOCAL FILEP sortfile;
@@ -1067,6 +1089,7 @@ while( rdname(&vargroup, varname) && rdlong(&offset) && rdlong(&vlen) && rdlong(
                {
                erred = YES;
                err("overlapping initializations");
                {
                erred = YES;
                err("overlapping initializations");
+               ooffset = offset;
                }
        if(offset > ooffset)
                {
                }
        if(offset > ooffset)
                {