BSD 4_3 release
[unix-history] / usr / src / ucb / pascal / src / main.c
index 1051ee5..d8d098d 100644 (file)
@@ -1,12 +1,22 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
 
 
-static char copyright[] =
-           "@(#)Copyright (c) 1979 Regents of the University of California";
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
 
 
-static char sccsid[] = "@(#)main.c 1.7 3/31/82";
+#ifndef lint
+static char sccsid[] = "@(#)main.c     5.1 (Berkeley) 6/5/85";
+#endif not lint
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
+#include "tree_ty.h"           /* must be included for yy.h */
 #include "yy.h"
 #include <signal.h>
 #include "objfmt.h"
 #include "yy.h"
 #include <signal.h>
 #include "objfmt.h"
@@ -21,16 +31,22 @@ static char sccsid[] = "@(#)main.c 1.7 3/31/82";
  */
 
 char   piusage[]       = "pi [ -blnpstuw ] [ -i file ... ] name.p";
  */
 
 char   piusage[]       = "pi [ -blnpstuw ] [ -i file ... ] name.p";
-char   pixusage[]      = "pix [ -blnpstuw ] [ -i file ... ] name.p [ arg ... ]";
-char   pcusage[]       = "pc [ options ] [ -o file ] [ -i file ... ] name.p";
 
 char   *usageis        = piusage;
 
 #ifdef OBJ
 
 char   *usageis        = piusage;
 
 #ifdef OBJ
-    char       *obj    = "obj";
+
+char   pixusage[]      = "pix [ -blnpstuw ] [ -i file ... ] name.p [ arg ... ]";
+char   *obj    = "obj";
+
 #endif OBJ
 #endif OBJ
+
 #ifdef PC
 #ifdef PC
-    char       *pcname = "pc.pc0";
+
+char   *pcname = "pc.pc0";
+char   pcusage[]       = "pc [ options ] [ -o file ] [ -i file ... ] name.p";
+FILE   *pcstream = NULL;
+
 #endif PC
 #ifdef PTREE
     char       *pTreeName = "pi.pTree";
 #endif PC
 #ifdef PTREE
     char       *pTreeName = "pi.pTree";
@@ -41,7 +57,6 @@ int   onintr();
 extern char *lastname;
 
 FILE   *ibuf;
 extern char *lastname;
 
 FILE   *ibuf;
-FILE   *pcstream = NULL;
 
 /*
  * these are made real variables
 
 /*
  * these are made real variables
@@ -62,6 +77,9 @@ main(argc, argv)
 {
        register char *cp;
        register c;
 {
        register char *cp;
        register c;
+       FILE *fopen();
+       extern char *myctime();
+       extern long lseek();
        int i;
 
        if (argv[0][0] == 'a')
        int i;
 
        if (argv[0][0] == 'a')
@@ -94,7 +112,11 @@ main(argc, argv)
                pexit(NOSTART);
        }
 #      ifdef OBJ
                pexit(NOSTART);
        }
 #      ifdef OBJ
-           opt('g') = opt('p') = opt('t') = opt('b') = 1;
+           opt('p') = opt('t') = opt('b') = 1;
+#ifdef vax
+           /* pdx is currently supported only on the vax */
+           opt('g') = 1;
+#endif vax
            while (argc > 0) {
                    cp = argv[0];
                    if (*cp++ != '-')
            while (argc > 0) {
                    cp = argv[0];
                    if (*cp++ != '-')
@@ -118,7 +140,7 @@ main(argc, argv)
                                    opt('r')++;
                                    continue;
                            case 'U':
                                    opt('r')++;
                                    continue;
                            case 'U':
-                                   yyunique = 0;
+                                   yyunique = FALSE;
                                    continue;
 #endif
                            case 'b':
                                    continue;
 #endif
                            case 'b':
@@ -148,6 +170,9 @@ main(argc, argv)
                            case 'z':
                                    monflg = TRUE;
                                    continue;
                            case 'z':
                                    monflg = TRUE;
                                    continue;
+                           case 'L':
+                                   togopt( 'L' );
+                                   continue;
                            default:
     usage:
                                    Perror( "Usage", usageis);
                            default:
     usage:
                                    Perror( "Usage", usageis);
@@ -189,7 +214,7 @@ main(argc, argv)
                            opt('r')++;
                            break;
                    case 'U':
                            opt('r')++;
                            break;
                    case 'U':
-                           yyunique = 0;
+                           yyunique = FALSE;
                            break;
 #endif
                    case 'b':
                            break;
 #endif
                    case 'b':
@@ -217,6 +242,9 @@ main(argc, argv)
                            argc--;
                            pcname = argv[0];
                            break;      
                            argc--;
                            pcname = argv[0];
                            break;      
+                   case 'J':
+                           togopt( 'J' );
+                           break;
                    case 'C':
                                /*
                                 * since -t is an ld switch, use -C
                    case 'C':
                                /*
                                 * since -t is an ld switch, use -C
@@ -245,6 +273,9 @@ main(argc, argv)
                    case 'z':
                            monflg = TRUE;
                            break;
                    case 'z':
                            monflg = TRUE;
                            break;
+                   case 'L':
+                           togopt( 'L' );
+                           break;
                    default:
 usage:
                            Perror( "Usage", usageis);
                    default:
 usage:
                            Perror( "Usage", usageis);
@@ -273,7 +304,7 @@ usage:
                perror( pcname );
                pexit( NOSTART );
            }
                perror( pcname );
                pexit( NOSTART );
            }
-           stabsource( filename );
+           stabsource( filename, TRUE );
 #      endif PC
 #      ifdef PTREE
 #          define      MAXpPAGES       16
 #      endif PC
 #      ifdef PTREE
 #          define      MAXpPAGES       16
@@ -283,7 +314,7 @@ usage:
            }
 #      endif PTREE
        if ( signal( SIGINT , SIG_IGN ) != SIG_IGN )
            }
 #      endif PTREE
        if ( signal( SIGINT , SIG_IGN ) != SIG_IGN )
-               signal( SIGINT , onintr );
+               (void) signal( SIGINT , onintr );
        if (opt('l')) {
                opt('n')++;
                yysetfile(filename);
        if (opt('l')) {
                opt('n')++;
                yysetfile(filename);
@@ -300,7 +331,12 @@ pchr(c)
        putc ( c , stdout );
 }
 
        putc ( c , stdout );
 }
 
+#ifdef PC
+char   ugh[]   = "Fatal error in pc\n";
+#endif
+#ifdef OBJ
 char   ugh[]   = "Fatal error in pi\n";
 char   ugh[]   = "Fatal error in pi\n";
+#endif
 /*
  * Exit from the Pascal system.
  * We throw in an ungraceful termination
 /*
  * Exit from the Pascal system.
  * We throw in an ungraceful termination
@@ -370,7 +406,7 @@ pexit(c)
 onintr()
 {
 
 onintr()
 {
 
-       signal( SIGINT , SIG_IGN );
+       (void) signal( SIGINT , SIG_IGN );
        pexit(NOSTART);
 }
 
        pexit(NOSTART);
 }
 
@@ -382,7 +418,7 @@ geterr(seekpt, buf)
        char *buf;
 {
 
        char *buf;
 {
 
-       lseek(efil, (long) seekpt, 0);
+       (void) lseek(efil, (long) seekpt, 0);
        if (read(efil, buf, 256) <= 0)
                perror(err_file), pexit(DIED);
 }
        if (read(efil, buf, 256) <= 0)
                perror(err_file), pexit(DIED);
 }
@@ -398,10 +434,10 @@ header()
        anyheaders++;
 #      ifdef OBJ
            printf("Berkeley Pascal PI -- Version %s\n\n%s  %s\n\n",
        anyheaders++;
 #      ifdef OBJ
            printf("Berkeley Pascal PI -- Version %s\n\n%s  %s\n\n",
-                   version, myctime(&tvec), filename);
+                   version, myctime((int *) (&tvec)), filename);
 #      endif OBJ
 #      ifdef PC
            printf("Berkeley Pascal PC -- Version %s\n\n%s  %s\n\n",
 #      endif OBJ
 #      ifdef PC
            printf("Berkeley Pascal PC -- Version %s\n\n%s  %s\n\n",
-                   version, myctime(&tvec), filename);
+                   version, myctime((int *) (&tvec)), filename);
 #      endif PC
 }
 #      endif PC
 }