BSD 4_4_Lite2 release
[unix-history] / usr / src / usr.bin / pascal / src / main.c
index 5408d82..9159cbb 100644 (file)
@@ -1,12 +1,49 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*-
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 
-static char copyright[] =
-           "@(#)Copyright (c) 1979 Regents of the University of California";
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
 
 
-static char sccsid[] = "@(#)main.c 1.9 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)main.c     8.2 (Berkeley) 5/24/94";
+#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 +58,22 @@ static char sccsid[] = "@(#)main.c 1.9 %G%";
  */
 
 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 +84,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 +104,8 @@ main(argc, argv)
 {
        register char *cp;
        register c;
 {
        register char *cp;
        register c;
+       FILE *fopen();
+       extern char *myctime();
        int i;
 
        if (argv[0][0] == 'a')
        int i;
 
        if (argv[0][0] == 'a')
@@ -95,10 +139,10 @@ main(argc, argv)
        }
 #      ifdef OBJ
            opt('p') = opt('t') = opt('b') = 1;
        }
 #      ifdef OBJ
            opt('p') = opt('t') = opt('b') = 1;
-#ifdef vax
-           /* pdx is currently supported only on the vax */
+#if defined(vax) || defined(tahoe)
+           /* pdx is currently supported on the vax and the tahoe */
            opt('g') = 1;
            opt('g') = 1;
-#endif vax
+#endif
            while (argc > 0) {
                    cp = argv[0];
                    if (*cp++ != '-')
            while (argc > 0) {
                    cp = argv[0];
                    if (*cp++ != '-')
@@ -122,7 +166,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':
@@ -152,6 +196,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);
@@ -193,7 +240,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':
@@ -252,6 +299,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);
@@ -280,7 +330,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
@@ -290,7 +340,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);
@@ -307,7 +357,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
@@ -377,7 +432,7 @@ pexit(c)
 onintr()
 {
 
 onintr()
 {
 
-       signal( SIGINT , SIG_IGN );
+       (void) signal( SIGINT , SIG_IGN );
        pexit(NOSTART);
 }
 
        pexit(NOSTART);
 }
 
@@ -389,7 +444,8 @@ geterr(seekpt, buf)
        char *buf;
 {
 
        char *buf;
 {
 
-       lseek(efil, (long) seekpt, 0);
+       if (lseek(efil, (off_t) seekpt, 0) == -1)
+               perror(err_file), pexit(DIED);
        if (read(efil, buf, 256) <= 0)
                perror(err_file), pexit(DIED);
 }
        if (read(efil, buf, 256) <= 0)
                perror(err_file), pexit(DIED);
 }
@@ -405,10 +461,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
 }