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

##### Functions

    call              X
    erm               X
    init              X
    main              X
    process           X
    show_call         X

##### Variables

    call_error        X
    in_process        X
    pname             X

##### Macros

    Cllerr            X

       1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
       2: static char rcsid[]="$Header: b2mai.c,v 1.1 84/06/28 00:49:17 timo Exp $";
       3:
       4: /* B driver for interpreter */
       5: #include "b.h"
       6: #include <sys/types.h>
       7:
       8: #include "b1obj.h"
       9: #include "b1mem.h"
      10: #include "b2env.h"
      11: #include "b2scr.h"
      12: #include "b2err.h"
      13: #include "b2fil.h"
      14: #include "b2sig.h"
      15: #include "b2syn.h"
      16: #include "b2sem.h"
      17: #include "b2sou.h"
      18:
      19: bool call_error, in_process;
      20:
      21: main(argc, argv) int argc; string argv[]; {
      22:     in_process= No; call_error= No;
      23:     call(argc, argv);
      24:     if (call_error) exit(-1);
      25:     in_process= Yes;
      26:     init();
      27:     call(argc, argv);
      28:     bye(0);
      29: }
      30:
      31: #define Cllerr stderr
      32:
      33: string pname;    /* program name */
      34:
      35: Hidden Procedure erm(m, n, argc, pargc, pargv) string m, n; int argc, pargc; string pargv[]; {
      36:     fprintf(Cllerr,
      37:  "*** There is something I don't quite get in your call of %s\n", pname);
      38:     show_call(argc, pargc, pargv);
      39:     fprintf(Cllerr, "*** The problem is: %s %s\n", m, n);
      40:     if (in_process) bye(-1);
      41:     call_error= Yes;
      42: }
      43:
      44: Hidden Procedure call(pargc, pargv) int pargc; string pargv[]; {
      45:     int argc; string *argv;
      46:
      47:     pname = pargv[0];
      48:     argc = pargc-1;
      49:     argv = pargv+1;
      50:     while (argc >= 0)
      51:     if (argc > 0 && argv[0][0] == '-' && argv[0][1] != '\0') {
      52:         if (argv[0][1] == 'q') { if (in_process) bye(0); }
      53:         else if (argv[0][1] == 'i') {
      54:             filtered= Yes;
      55:             cmd_prompt= "\001>";
      56:             eg_prompt=  "\001E";
      57:             raw_prompt= "\001R";
      58:             qn_prompt=  "\001Y";
      59:         } else erm("I never learned about the option", argv[0], argc, pargc, pargv);
      60:         argc -= 1;
      61:         argv += 1;
      62:     } else {
      63:         if (argc == 0 || (argv[0][0] == '-' && argv[0][1] == '\0')) {
      64:             release(iname);
      65:             iname = Vnil;
      66:             ifile = stdin;
      67:         } else {
      68:             release(iname);
      69:             iname = mk_text(*argv);
      70:             ifile = fopen(*argv, "r");
      71:         }
      72:         if (ifile != NULL) { if (in_process) process();
      73:         } else erm("can't open input file", *argv, argc, pargc, pargv);
      74:         if (ifile != NULL && ifile != stdin) fclose(ifile);
      75:         ++argv; --argc;
      76:     }
      77: }
      78:
      79: Hidden Procedure show_call(eargc, pargc, pargv)
      80:  int eargc, pargc; string pargv[]; {
      81:     int argc= pargc; string *argv= pargv;
      82:     intlet p, pos= 4;
      83:     fprintf(Cllerr, "    ");
      84:     while (argc > 0) {
      85:         fprintf(Cllerr, *argv);
      86:         pos+= strlen(*argv);
      87:         if (argc == eargc) p= pos-1;
      88:         ++argv; --argc;
      89:         if (argc > 0) {
      90:             putc(' ', Cllerr);
      91:             pos++;
      92:         }
      93:     }
      94:     putc('\n', Cllerr);
      95:     for (pos= 0; pos < p; pos++) putc(' ', Cllerr);
      96:     fprintf(Cllerr, "^\n");
      97: }
      98:
      99: Hidden Procedure init() {
     100:     initmem();
     101:     initnum();
     102:     initenv();
     103:     inittors();
     104:     initsou();
     105:     initfprs();
     106:     inithow();
     107:     initscr();
     108:     setprmnv();
     109:     getprmnv();
     110:     inisigs();
     111: }
     112:
     113: Visible Procedure process() {
     114:     re_screen();
     115:     alino= 0; Eof= Eof0= No;
     116:     xeq= Yes; skipping= No; cntxt= In_command;
     117:     if (setjmp(main_loop) != 0) /* long jump occurred */ {
     118:         re_files();
     119:         if (Eof) return;
     120:         xeq= interactive; skipping= !interactive;
     121:         /* skipping may be reset by command() */
     122:     }
     123:     inistreams();
     124:     re_env();
     125:     active_reads= 0;
     126:     while (!Eof) {
     127:         re_streams();
     128:         cntxt= In_command; resexp= Voi; lino= 0;
     129:         cur_ilev= 0;
     130:         terminated= No;
     131:         if (ilev(Yes) > 0) parerr("outer indentation not zero", "");
     132:         findceol(); command();
     133:         re_files();
     134:     }
     135: }

#### Defined functions

call defined in line 44; used 2 times

- in line 23-27(2)

erm defined in line 35; used 2 times

- in line 59, 73

init defined in line 99; used 1 times

- in line 26

main defined in line 21; never used
process defined in line 113; used 2 times

- in line 72
- in /usr/src/new/PORT/B/src/bsmall/b2err.c line 203

show_call defined in line 79; used 1 times

- in line 38

#### Defined variables

call_error defined in line 19; used 3 times

- in line 22-24(2), 41

in_process defined in line 19; used 5 times

- in line 22-25(2), 40, 52, 72

pname defined in line 33; used 2 times

- in line 37, 47

rcsid defined in line 2; never used

#### Defined macros

Cllerr defined in line 31; used 8 times

- in line 36-39(2), 83-96(6)

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