BSD 4_4 release
[unix-history] / usr / src / usr.bin / pascal / libpc / PCSTART.c
index 5faee77..29daa14 100644 (file)
@@ -1,8 +1,43 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*-
+ * Copyright (c) 1979, 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 sccsid[] = "@(#)PCSTART.c 1.5 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)PCSTART.c  8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 
+#include <signal.h>
 #include "h00vars.h"
 #include "h00vars.h"
+#include "libpc.h"
 
 /*
  * program variables
 
 /*
  * program variables
@@ -13,11 +48,12 @@ char                **_argv;
 long           _stlim = 500000;
 long           _stcnt = 0;
 long           _seed = 1;
 long           _stlim = 500000;
 long           _stcnt = 0;
 long           _seed = 1;
-#ifdef VAX
+#ifdef ADDR32
 char           *_minptr = (char *)0x7fffffff;
 char           *_minptr = (char *)0x7fffffff;
-#else
+#endif ADDR32
+#ifdef ADDR16
 char           *_minptr = (char *)0xffff;
 char           *_minptr = (char *)0xffff;
-#endif VAX
+#endif ADDR16
 char           *_maxptr = (char *)0;
 
 /*
 char           *_maxptr = (char *)0;
 
 /*
@@ -42,11 +78,11 @@ struct iorechd      input = {
        &_inwin,                /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
        &_inwin,                /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
-       &_iob[0],               /* fbuf    */
+       stdin,                  /* fbuf    */
        OUTPUT,                 /* fchain  */
        STDLVL,                 /* flev    */
        "standard input",       /* pfname  */
        OUTPUT,                 /* fchain  */
        STDLVL,                 /* flev    */
        "standard input",       /* pfname  */
-       FTEXT | FREAD | SYNC,   /* funit   */
+       FTEXT|FREAD|SYNC|EOLN,  /* funit   */
        0,                      /* fblk    */
        1                       /* fsize   */
 };
        0,                      /* fblk    */
        1                       /* fsize   */
 };
@@ -54,7 +90,7 @@ struct iorechd        output = {
        &_outwin,               /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
        &_outwin,               /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
-       &_iob[1],               /* fbuf    */
+       stdout,                 /* fbuf    */
        ERR,                    /* fchain  */
        STDLVL,                 /* flev    */
        "standard output",      /* pfname  */
        ERR,                    /* fchain  */
        STDLVL,                 /* flev    */
        "standard output",      /* pfname  */
@@ -66,7 +102,7 @@ struct iorechd       _err = {
        &_errwin,               /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
        &_errwin,               /* fileptr */
        0,                      /* lcount  */
        0x7fffffff,             /* llimit  */
-       &_iob[2],               /* fbuf    */
+       stderr,                 /* fbuf    */
        FILNIL,                 /* fchain  */
        STDLVL,                 /* flev    */
        "Message file",         /* pfname  */
        FILNIL,                 /* fchain  */
        STDLVL,                 /* flev    */
        "Message file",         /* pfname  */
@@ -75,7 +111,8 @@ struct iorechd       _err = {
        1                       /* fsize   */
 };
 
        1                       /* fsize   */
 };
 
-PCSTART()
+PCSTART(mode)
+       int mode;
 {
        /*
         * necessary only on systems which do not initialize
 {
        /*
         * necessary only on systems which do not initialize
@@ -84,5 +121,12 @@ PCSTART()
 
        struct iorec    **ip;
 
 
        struct iorec    **ip;
 
+       /*
+        * if running with runtime tests enabled, give more
+        * coherent error messages for FPEs
+        */
+       if (mode) {
+               signal(SIGFPE, EXCEPT);
+       }
        for (ip = &_actfile[3]; ip < &_actfile[MAXFILES]; *ip++ = FILNIL);
 }
        for (ip = &_actfile[3]; ip < &_actfile[MAXFILES]; *ip++ = FILNIL);
 }