# 2.11BSD#431 - /usr/src/bin/csh/sh.err.c

##### Functions

    Perror            X
    bferr             X
    error             X
    seterr            X
    seterr2           X
    seterrc           X

##### Variables

    errspl            X
    one               X
    onev              X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley Software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #if !defined(lint) && defined(DOSCCS)
       8: static char *sccsid = "@(#)sh.err.c	5.3 (Berkeley) 5/13/86";
       9: #endif
      10:
      11: #include "sh.h"
      12: #include <sys/ioctl.h>
      13:
      14: /*
      15:  * C Shell
      16:  */
      17:
      18: bool    errspl;         /* Argument to error was spliced by seterr2 */
      19: char    one[2] = { '1', 0 };
      20: char    *onev[2] = { one, NOSTR };
      21: /*
      22:  * Print error string s with optional argument arg.
      23:  * This routine always resets or exits.  The flag haderr
      24:  * is set so the routine who catches the unwind can propogate
      25:  * it if they want.
      26:  *
      27:  * Note that any open files at the point of error will eventually
      28:  * be closed in the routine process in sh.c which is the only
      29:  * place error unwinds are ever caught.
      30:  */
      31: /*VARARGS1*/
      32: error(s, arg)
      33:     char *s;
      34: {
      35:     register char **v;
      36:     register char *ep;
      37:
      38:     /*
      39: 	 * Must flush before we print as we wish output before the error
      40: 	 * to go on (some form of) standard output, while output after
      41: 	 * goes on (some form of) diagnostic output.
      42: 	 * If didfds then output will go to 1/2 else to FSHOUT/FSHDIAG.
      43: 	 * See flush in sh.print.c.
      44: 	 */
      45:     flush();
      46:     haderr = 1;     /* Now to diagnostic output */
      47:     timflg = 0;     /* This isn't otherwise reset */
      48:     if (v = pargv)
      49:         pargv = 0, blkfree(v);
      50:     if (v = gargv)
      51:         gargv = 0, blkfree(v);
      52:
      53:     /*
      54: 	 * A zero arguments causes no printing, else print
      55: 	 * an error diagnostic here.
      56: 	 */
      57:     if (s)
      58:         printf(s, arg), printf(".\n");
      59:
      60:     didfds = 0;     /* Forget about 0,1,2 */
      61:     if ((ep = err) && errspl) {
      62:         errspl = 0;
      63:         xfree(ep);
      64:     }
      65:     errspl = 0;
      66:
      67:     /*
      68: 	 * Go away if -e or we are a child shell
      69: 	 */
      70:     if (exiterr || child)
      71:         exit(1);
      72:
      73:     /*
      74: 	 * Reset the state of the input.
      75: 	 * This buffered seek to end of file will also
      76: 	 * clear the while/foreach stack.
      77: 	 */
      78:     btoeof();
      79:
      80:     setq("status", onev, &shvhed);
      81:     if (tpgrp > 0)
      82:         (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp);
      83:     reset();        /* Unwind */
      84: }
      85:
      86: /*
      87:  * Perror is the shells version of perror which should otherwise
      88:  * never be called.
      89:  */
      90: Perror(s)
      91:     char *s;
      92: {
      93:
      94:     /*
      95: 	 * Perror uses unit 2, thus if we didn't set up the fd's
      96: 	 * we must set up unit 2 now else the diagnostic will disappear
      97: 	 */
      98:     if (!didfds) {
      99:         register int oerrno = errno;
     100:
     101:         (void) dcopy(SHDIAG, 2);
     102:         errno = oerrno;
     103:     }
     104:     perror(s);
     105:     error(NOSTR);       /* To exit or unwind */
     106: }
     107:
     108: bferr(cp)
     109:     char *cp;
     110: {
     111:
     112:     flush();
     113:     haderr = 1;
     114:     printf("%s: ", bname);
     115:     error(cp);
     116: }
     117:
     118: /*
     119:  * The parser and scanner set up errors for later by calling seterr,
     120:  * which sets the variable err as a side effect; later to be tested,
     121:  * e.g. in process.
     122:  */
     123: seterr(s)
     124:     char *s;
     125: {
     126:
     127:     if (err == 0)
     128:         err = s, errspl = 0;
     129: }
     130:
     131: /* Set err to a splice of cp and dp, to be freed later in error() */
     132: seterr2(cp, dp)
     133:     char *cp, *dp;
     134: {
     135:
     136:     if (err)
     137:         return;
     138:     err = strspl(cp, dp);
     139:     errspl++;
     140: }
     141:
     142: /* Set err to a splice of cp with a string form of character d */
     143: seterrc(cp, d)
     144:     char *cp, d;
     145: {
     146:     char chbuf[2];
     147:
     148:     chbuf[0] = d;
     149:     chbuf[1] = 0;
     150:     seterr2(cp, chbuf);
     151: }

#### Defined functions

Perror defined in line 90; used 15 times

- in /usr/src/bin/csh/sh.c line 204, 215, 824
- in /usr/src/bin/csh/sh.dir.c line 114, 173, 223, 232, 297
- in /usr/src/bin/csh/sh.dol.c line 576, 583
- in /usr/src/bin/csh/sh.exec.c line 214
- in /usr/src/bin/csh/sh.glob.c line 210
- in /usr/src/bin/csh/sh.sem.c line 349, 369-373(2)

bferr defined in line 108; used 64 times

- in /usr/src/bin/csh/sh.c line 639
- in /usr/src/bin/csh/sh.dir.c line 107-109(2), 221, 272, 290-292(2)
- in /usr/src/bin/csh/sh.dol.c line 86, 598, 658
- in /usr/src/bin/csh/sh.exec.c line 162-163(2)
- in /usr/src/bin/csh/sh.exp.c line 356, 384, 403, 429, 569
- in /usr/src/bin/csh/sh.func.c line 72-74(2), 92, 113, 151, 219-222(2), 318, 334, 352-360(3), 394, 432, 441, 663-677(5), 743, 866, 897-902(2), 998
- in /usr/src/bin/csh/sh.glob.c line 420, 532, 539
- in /usr/src/bin/csh/sh.misc.c line 368
- in /usr/src/bin/csh/sh.proc.c line 797, 805, 855, 928-933(2), 941, 957, 964-966(2)
- in /usr/src/bin/csh/sh.set.c line 53, 61, 108, 132, 184, 258, 321, 392, 536

error defined in line 32; used 54 times

- in line 105, 115
- in /usr/src/bin/csh/sh.c line 546, 660, 775, 791
- in /usr/src/bin/csh/sh.dir.c line 69
- in /usr/src/bin/csh/sh.dol.c line 162, 226, 321, 368, 390, 436, 490, 606
- in /usr/src/bin/csh/sh.exec.c line 75
- in /usr/src/bin/csh/sh.exp.c line 331, 338, 512
- in /usr/src/bin/csh/sh.func.c line 205, 307, 931, 1011, 1050, 1056, 1090, 1133, 1153
- in /usr/src/bin/csh/sh.glob.c line 142, 240-245(2), 285, 342, 460, 474, 601, 661-665(2), 733, 742
- in /usr/src/bin/csh/sh.hist.c line 101
- in /usr/src/bin/csh/sh.misc.c line 84
- in /usr/src/bin/csh/sh.parse.c line 36, 71, 123
- in /usr/src/bin/csh/sh.proc.c line 691, 873, 917, 1044, 1098-1100(2)
- in /usr/src/bin/csh/sh.sem.c line 146, 399, 411

seterr defined in line 123; used 21 times

- in /usr/src/bin/csh/sh.lex.c line 261, 420, 430, 516, 555, 574, 599, 623, 674, 736, 881, 966
- in /usr/src/bin/csh/sh.parse.c line 208, 246, 519, 545, 553, 569-571(2), 590-595(2)

seterr2 defined in line 132; used 2 times

- in line 150
- in /usr/src/bin/csh/sh.lex.c line 1046

seterrc defined in line 143; used 2 times

- in /usr/src/bin/csh/sh.lex.c line 234, 639

#### Defined variables

errspl defined in line 18; used 5 times

- in line 61-65(3), 128, 139

one defined in line 19; used 1 times

- in line 20

onev defined in line 20; used 1 times

- in line 80

sccsid defined in line 8; never used

Last modified: 1991-08-31 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1322 |