# 2.11BSD#431 - /usr/src/new/PORT/B/src/bsmall/b2err.c

##### Functions

    Line              X
    bye               X
    checkerr          X
    core_dump         X
    debug             X
    display_line      X
    errmess           X
    error             X
    fix_files         X
    int_signal        X
    interrupt         X
    memexh            X
    message           X
    parerr            X
    pprerr            X
    prline            X
    prname            X
    proceed           X
    show_where        X
    syserr            X
    trace             X

##### Variables

    bugs              X
    errlino           X
    errutype          X
    main_loop         X
    skipping          X
    tracing           X

##### Macros

    Errout            X
    Interactive       X
    Skip              X

       1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
       2: /* $Header: b2err.c,v 1.1 84/06/28 00:49:07 timo Exp $ */
       3:
       4: /* B error message handling */
       5: #include "b.h"
       6: #include "b0con.h"
       7: #include "b1obj.h"
       8: #include "b2err.h"
       9: #include "b2scr.h"
      10: #include "b2env.h"
      11: #include "b2sem.h" /* for xeq */
      12: #include "b2syn.h"
      13: #include "b2sig.h"
      14: #include "b2fil.h"
      15:
      16: jmp_buf main_loop;
      17: bool skipping;
      18:
      19:
      20: #define Interactive ((cntxt == In_read || active_reads > 0) \
      21:                 ? read_interactive : interactive)
      22: #define Errout (Interactive ? stderr : stdout)
      23: #define Skip() {if (skipping) proceed();}
      24:
      25: Hidden Procedure Line() {
      26:     if (interactive || Errout == stdout) line();
      27: }
      28:
      29: Hidden Procedure errmess(m) string m; {
      30:     fprintf(Errout, m);
      31: }
      32:
      33: Hidden Procedure core_dump() {
      34:     errmess("*** Core-dump for inspection purposes: ");
      35:     fflush(stdout);
      36:     dump();
      37: }
      38:
      39: Visible Procedure bye(ex) int ex; {
      40:     at_nwl= Yes;
      41:     putprmnv();
      42:     exit(ex);
      43: }
      44:
      45: Hidden Procedure prname(name) value name; {
      46:     value ch; int k, len;
      47:     if (Is_text(name)) {
      48:         len= length(name);
      49:         k_Over_len {
      50:             ch= thof(k+1, name);
      51:             putc(charval(ch), Errout);
      52:             release(ch);
      53:         }
      54:     } else errmess("???");
      55: }
      56:
      57: value erruname= Vnil; literal errutype; intlet errlino= 0;
      58:
      59: Hidden intlet display_line(ax) txptr ax; {
      60:     /*displays the line that tx is in, and returns the column number that
      61: 	  ax is at.
      62: 	*/
      63:     txptr lx= fcol(); intlet ap= -1, p= 0; char c;
      64:     while (!Eol(lx) && Char(lx) != Eotc) {
      65:         if (lx == ax) ap= p;
      66:         c= *lx++;
      67:         if (c == '\t') {
      68:             do { putc(' ', Errout); } while (((++p)%4)!=0);
      69:         } else { putc(c, Errout); p++; }
      70:     }
      71:     putc('\n', Errout);
      72:     if (ap < 0) return p;
      73:     return ap;
      74: }
      75:
      76: Hidden Procedure prline(at) bool at; {
      77:     txptr ax= tx; intlet p, ap;
      78:     if (cntxt == In_read || cntxt == In_value) errmess(" in your ");
      79:     else if (cntxt != In_formal)
      80:         fprintf(Errout, " in line %d of your ", lino);
      81:     switch (cntxt) {
      82:     case In_command: errmess("command"); break;
      83:     case In_read: errmess("expression to be read"); break;
      84:     case In_value: errmess("edited value"); break;
      85:     case In_unit:errmess("unit "); prname(uname);
      86:         erruname= uname; errutype= utype; errlino= lino;
      87:         break;
      88:     case In_formal: break;
      89:     case In_prmnv: errmess("permanent environment"); break;
      90:     default: errmess("???\n"); return;
      91:     }
      92:     errmess("\n    ");
      93:     if (!at) do ax--; while (Space(Char(ax)));
      94:     ap= display_line(ax)+4;
      95:     for (p= 0; p < ap; p++) putc(' ', Errout);
      96:     putc('^', Errout);
      97:     putc('\n', Errout);
      98: }
      99:
     100: Hidden Procedure show_where(at, wia) bool at, wia; {
     101:     context cc;
     102:     if (cntxt == In_formal) {
     103:         sv_context(&cc);
     104:         set_context(&how_context);
     105:         prline(No);
     106:         set_context(&cc);
     107:         errmess("originating from your command");
     108:     }
     109:     prline(at);
     110:     if (!Interactive || !wia) {
     111:         fprintf(Errout,
     112:     "(detected after reading %d input line%s of your input file ",
     113:         alino, alino == 1 ? "" : "s");
     114:         if (iname == Vnil) errmess("standard input)");
     115:         else {
     116:             prname(iname);
     117:             errmess(")");
     118:         }
     119:         putc('\n', Errout);
     120:     }
     121: }
     122:
     123: Visible Procedure syserr(m) string m; {
     124:     Line();
     125:     errmess("*** Sorry, B system malfunction");
     126:     show_where(Yes, Yes);
     127:     fprintf(Errout, "*** The problem is: %s\n", m);
     128:     errmess("*** Please save pertinent data for inspection by B guru\n");
     129:     core_dump();
     130: }
     131:
     132: Visible Procedure memexh() {
     133:     Line();
     134:     errmess("*** Sorry, memory exhausted");
     135:     show_where(Yes, Yes);
     136:     errmess("*** Get your boss to buy a larger computer\n");
     137:     core_dump();
     138: }
     139:
     140: Hidden Procedure fix_files() {
     141:     if (ifile != stdin) fclose(ifile);
     142:     if (f_interactive(stdin) || filtered) {
     143:         interactive= Yes;
     144:         release(iname);
     145:         iname = Vnil;
     146:         ifile = stdin;
     147:         Eof= Eof0= No;
     148:     }
     149: }
     150:
     151: Hidden Procedure proceed() {
     152:     if (cntxt == In_prmnv) exit(-1);
     153:     else if (cntxt == In_read && read_interactive) {
     154:         errmess("*** please enter a valid expression instead\n");
     155:         longjmp(reading[active_reads-1], 1);
     156:     } else if (active_reads > 0 && read_interactive) {
     157:         errmess("*** please enter a suitable expression instead\n");
     158:         longjmp(reading[active_reads-1], 1);
     159:     } else {
     160:         if (cntxt == In_value) fix_files();
     161:         longjmp(main_loop, 1);
     162:     }
     163: }
     164:
     165: Hidden Procedure message(m1, m2, m3, at) string m1, m2, m3; bool at; {
     166:     Skip(); Line();
     167:     errmess(m1);
     168:     show_where(at, Yes);
     169:     fprintf(Errout, "*** The problem is: %s%s\n", m2, m3);
     170:     proceed();
     171: }
     172:
     173: Visible Procedure error(m) string m; {
     174:     message("*** Cannot cope with problem", m, "", No);
     175: }
     176:
     177: Visible Procedure parerr(m, ss) string m, ss; {
     178:     message("*** There's something I don't understand", m, ss, Yes);
     179: }
     180:
     181: Visible Procedure pprerr(m, ss) string m, ss; {
     182:     message("*** There's something I don't understand", m, ss, No);
     183: }
     184:
     185: Visible Procedure checkerr() {
     186:     Line();
     187:     errmess("*** Your check failed");
     188:     show_where(No, Yes);
     189:     longjmp(main_loop, 1);
     190: }
     191:
     192: Visible Procedure int_signal(in_read) bool in_read; {
     193:     if (cntxt == In_prmnv) exit(-1);
     194:     else if (interactive) {
     195:         interrupt(in_read);
     196:         if (!in_read) accept_int();
     197:         longjmp(main_loop, 1);
     198:     } else {
     199:         fix_files();
     200:         if (interactive) {
     201:             interrupt(in_read);
     202:             if (!in_read) accept_int();
     203:             process();
     204:         } else bye(1);
     205:     }
     206: }
     207:
     208: Hidden Procedure interrupt(in_read) bool in_read; {
     209:     if (!in_read) at_nwl= No;
     210:     Line();
     211:     errmess(in_read ? "*** READ aborted\n" : "*** interrupted\n");
     212:     if (filtered) errmess("\177");
     213:     if (cntxt == In_read || active_reads > 0) set_context(&read_context);
     214:     /* show_where(No, was_interactive); */
     215: }
     216:
     217: bool bugs= No;
     218: bool tracing= No;
     219:
     220: Visible Procedure debug(m) string m; {
     221:     if (bugs) {
     222:         Line();
     223:         fprintf(Errout, "*** Debugging (xeq = %s, cur_ilev = %d)",
     224:             xeq ? "Yes" : "No", cur_ilev);
     225:         show_where(Yes, Yes);
     226:         fprintf(Errout, "*** %s\n", m);
     227:     }
     228: }
     229:
     230: Visible Procedure trace() {
     231:     VOID display_line(tx);
     232: }

#### Defined functions

Line defined in line 25; used 6 times

- in line 124, 133, 166, 186, 210, 222

bye defined in line 39; used 7 times

- in line 204
- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 324
- in /usr/src/new/PORT/B/src/bsmall/b2mai.c line 28, 40, 52
- in /usr/src/new/PORT/B/src/bsmall/b2scr.c line 53
- in /usr/src/new/PORT/B/src/bsmall/b2syn.c line 225

checkerr defined in line 185; used 1 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 83

core_dump defined in line 33; used 2 times

- in line 129, 137

debug defined in line 220; used 15 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 431, 450
- in /usr/src/new/PORT/B/src/bsmall/b2syn.c line 242-247(3), 263-266(2)
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 143, 157, 227, 248, 263, 271, 311, 350

display_line defined in line 59; used 2 times

- in line 94, 231

errmess defined in line 29; used 23 times

- in line 34, 54, 78-92(8), 107, 114-117(2), 125-128(2), 134-136(2), 154-157(2), 167, 187, 211-212(2)

error defined in line 173; used 113 times

- in /usr/src/new/PORT/B/src/bsmall/B1fun.c line 39, 95-97(2), 106-108(2), 116, 148
- in /usr/src/new/PORT/B/src/bsmall/B1lis.c line 17, 36-40(3)
- in /usr/src/new/PORT/B/src/bsmall/B1num.c line 21, 27, 38, 54, 71, 91
- in /usr/src/new/PORT/B/src/bsmall/B1num.h line 12
- in /usr/src/new/PORT/B/src/bsmall/B1obj.c line 24
- in /usr/src/new/PORT/B/src/bsmall/B1tab.c line 20, 35, 52
- in /usr/src/new/PORT/B/src/bsmall/B1tex.c line 22, 32-33(2), 40, 48-50(2), 59-60(2)
- in /usr/src/new/PORT/B/src/bsmall/B1tlt.c line 11, 19-25(3), 156-157(2), 163-176(7), 182-189(5), 199-200(2), 247-253(3)
- in /usr/src/new/PORT/B/src/bsmall/b1mem.c line 11
- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 28, 53, 504
- in /usr/src/new/PORT/B/src/bsmall/b2exp.c line 147, 249, 283, 303, 314-316(2), 426-433(4), 441-451(5)
- in /usr/src/new/PORT/B/src/bsmall/b2fpr.c line 216-219(2)
- in /usr/src/new/PORT/B/src/bsmall/b2loc.c line 15-20(2), 40-41(2), 65, 72, 89-94(3), 104-106(2), 112, 120, 131, 144, 154-159(2), 176-179(2), 205
- in /usr/src/new/PORT/B/src/bsmall/b2scr.c line 126, 154, 168
- in /usr/src/new/PORT/B/src/bsmall/b2sig.c line 58
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 95, 234, 253, 404, 440
- in /usr/src/new/PORT/B/src/bsmall/b2tar.c line 70
- in /usr/src/new/PORT/B/src/bsmall/b2tes.c line 164-169(2)
- in /usr/src/new/PORT/B/src/bsmall/b2typ.c line 98, 111
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 296-298(2), 357-359(2), 520

fix_files defined in line 140; used 2 times

- in line 160, 199

int_signal defined in line 192; used 2 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 59
- in /usr/src/new/PORT/B/src/bsmall/b2sig.c line 63

interrupt defined in line 208; used 2 times

- in line 195, 201

memexh defined in line 132; used 2 times

- in /usr/src/new/PORT/B/src/bsmall/b1mem.c line 22, 35

message defined in line 165; used 3 times

- in line 174-182(3)

parerr defined in line 177; used 50 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 276, 438-439(2), 447, 487
- in /usr/src/new/PORT/B/src/bsmall/b2exp.c line 116, 153, 259, 309, 350, 388
- in /usr/src/new/PORT/B/src/bsmall/b2mai.c line 131
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 59, 136, 156, 210, 221, 322, 328
- in /usr/src/new/PORT/B/src/bsmall/b2syn.c line 14, 20, 95, 105, 171, 257
- in /usr/src/new/PORT/B/src/bsmall/b2tar.c line 54, 77
- in /usr/src/new/PORT/B/src/bsmall/b2tes.c line 26, 107, 151-156(3)
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 31, 43, 74, 84-99(5), 107, 115-119(2), 139, 171, 184, 230, 426, 489, 496

pprerr defined in line 181; used 28 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 126, 189, 271, 280, 398-409(4)
- in /usr/src/new/PORT/B/src/bsmall/b2exp.c line 86, 336
- in /usr/src/new/PORT/B/src/bsmall/b2fpr.c line 154-157(2), 183-187(2)
- in /usr/src/new/PORT/B/src/bsmall/b2loc.c line 202-204(2)
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 158, 329
- in /usr/src/new/PORT/B/src/bsmall/b2syn.c line 79
- in /usr/src/new/PORT/B/src/bsmall/b2tar.c line 47
- in /usr/src/new/PORT/B/src/bsmall/b2tes.c line 25, 70, 100, 159
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 46, 471, 514-515(2)

prline defined in line 76; used 2 times

- in line 105-109(2)

prname defined in line 45; used 2 times

- in line 85, 116

proceed defined in line 151; used 2 times

- in line 23, 170

show_where defined in line 100; used 5 times

- in line 126, 135, 168, 188, 225

syserr defined in line 123; used 69 times

- in /usr/src/new/PORT/B/src/bsmall/B1num.c line 60-62(2), 73, 181-184(2), 211, 228
- in /usr/src/new/PORT/B/src/bsmall/B1obj.c line 43, 67
- in /usr/src/new/PORT/B/src/bsmall/B1tab.c line 44, 74, 80-84(3)
- in /usr/src/new/PORT/B/src/bsmall/B1tex.c line 163
- in /usr/src/new/PORT/B/src/bsmall/B1tlt.c line 57, 93, 149, 214, 263
- in /usr/src/new/PORT/B/src/bsmall/B1val.c line 23-24(2), 62, 148, 218, 277
- in /usr/src/new/PORT/B/src/bsmall/b1mem.c line 60
- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 45, 483
- in /usr/src/new/PORT/B/src/bsmall/b2env.c line 78-88(3)
- in /usr/src/new/PORT/B/src/bsmall/b2exp.c line 45, 66, 72, 127
- in /usr/src/new/PORT/B/src/bsmall/b2fil.c line 172
- in /usr/src/new/PORT/B/src/bsmall/b2fpr.c line 160, 190, 202-206(2), 230-234(2), 247
- in /usr/src/new/PORT/B/src/bsmall/b2loc.c line 23, 44-46(3)
- in /usr/src/new/PORT/B/src/bsmall/b2scr.c line 183
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 35, 115, 397
- in /usr/src/new/PORT/B/src/bsmall/b2syn.c line 84, 222, 246
- in /usr/src/new/PORT/B/src/bsmall/b2typ.c line 53, 84
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 150, 161, 204, 214, 240, 252, 274, 312, 389, 396, 525, 533

trace defined in line 230; used 1 times

- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 432

#### Defined variables

bugs defined in line 217; used 7 times

- in line 221
- in /usr/src/new/PORT/B/src/bsmall/b1mem.c line 21, 29
- in /usr/src/new/PORT/B/src/bsmall/b2cmd.c line 365, 377
- in /usr/src/new/PORT/B/src/bsmall/b2err.c line 221
- in /usr/src/new/PORT/B/src/bsmall/b2scr.c line 182

errlino defined in line 57; used 1 times

- in line 86

errutype defined in line 57; used 1 times

- in line 86

main_loop defined in line 16; used 3 times

- in line 161, 189, 197

skipping defined in line 17; used 1 times

- in line 23

tracing defined in line 218; never used

#### Defined macros

Errout defined in line 22; used 16 times

- in line 26-30(2), 51, 68-71(3), 80, 95-97(3), 111, 119, 127, 169, 223-226(2)

Interactive defined in line 20; used 2 times

- in line 22, 110

Skip defined in line 23; used 1 times

- in line 166

Last modified: 1985-08-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1313 |