# 2.11BSD#431 - /usr/src/new/PORT/apl/src/ah.c

##### Functions

    evLlx             X
    ex_immed          X
    vfname            X

       1: static char Sccsid[] = "ah.c @(#)ah.c	1.1	10/1/82 Berkeley ";
       2: #include "apl.h"
       3:
       4: ex_immed()
       5: {
       6:     register i;
       7:     register struct item *p;
       8:     register struct nlist *n;
       9:     double f;
      10:     char fname[64];         /* Array for filename */
      11:     char *cp, *vfname();
      12:     int *ip;
      13:
      14:     i = *pcp++;
      15:     switch(i) {
      16:
      17:     default:
      18:         error("immed B");
      19:
      20:     case SCRIPT:
      21:         if(protofile > 0)
      22:             CLOSEF(protofile);
      23:         protofile = 0;
      24:         cp = vfname(fname);
      25:         if(equal(cp, "off"))
      26:             return;
      27:         if((protofile = OPENF(cp, 1)) > 0){
      28:             SEEKF(protofile, 0L, 2);  /* append to existing file */
      29:             printf("[appending]\n");
      30:         } else {
      31:             /*
      32: 			 * create new file
      33: 			 */
      34:             protofile = opn(cp, 0644);
      35:             printf("[new file]\n");
      36:         }
      37:         WRITEF(protofile, "\t)script on\n", 12);
      38:         return;
      39:
      40:     case DEBUG:
      41:         debug = ~debug;
      42:         return;
      43:
      44:     case DIGITS:
      45:         i = topfix();
      46:         if(i < 1 || i > 20)
      47:             error("digits D");
      48:         printf("was %d\n",thread.digits);
      49:         thread.digits = i;
      50:         return;
      51:     case TRACE:
      52:         funtrace = 1;
      53:         return;
      54:
      55:     case UNTRACE:
      56:         funtrace = 0;
      57:         return;
      58:
      59:     case WRITE:
      60:         funwrite(0);
      61:         return;
      62:
      63:     case DEL:
      64:     case EDITF:
      65:         *sp++ = sp[-1]; /* duplicate top of stack */
      66:         funwrite(scr_file);
      67:         funedit(scr_file, i);
      68:         unlink(scr_file);
      69:         return;
      70:
      71:
      72:     case EDIT:
      73:         funedit(0, i);
      74:         return;
      75:
      76:     case FUZZ:
      77:         i = topfix();
      78:         if(i <= 0) {
      79:             thread.fuzz = 0.;
      80:             return;
      81:         }
      82:         f = i;
      83:         thread.fuzz = exp(-f*2.3025851);
      84:         return;
      85:
      86:     case ORIGIN:
      87:         printf("was %d\n",thread.iorg);
      88:         thread.iorg = topfix();
      89:         return;
      90:
      91:     case WIDTH:
      92:         i = topfix();
      93:         if(i < 1)
      94:             error("width D");
      95:         printf("was %d\n",thread.width);
      96:         thread.width = i;
      97:         return;
      98:
      99:     case READ:
     100:         funread(0);
     101:         return;
     102:
     103:     case ERASE:
     104:         p = sp[-1];
     105:         sp--;
     106:         erase(p);
     107:         return;
     108:
     109:     case CONTIN:
     110:         i = opn("continue", 0644);
     111:         wssave(i);
     112:         printf(" continue");
     113:
     114:     case OFF:
     115:         term(0);
     116:
     117:     case VARS:
     118:         for(n=nlist; n->namep; n++)
     119:             if(n->itemp && n->use == DA && n->namep[0] != 'L') {
     120:                 if(column+8 >= thread.width)
     121:                     printf("\n\t");
     122:                 printf(n->namep);
     123:                 putchar('\t');
     124:             }
     125:         putchar('\n');
     126:         return;
     127:
     128:     case FNS:
     129:         for(n=nlist; n->namep; n++)
     130:             if(n->use == DF || n->use == MF || n->use == NF) {
     131:                 if(column+8 >= thread.width)
     132:                     printf("\n\t");
     133:                 printf(n->namep);
     134:                 putchar('\t');
     135:             }
     136:         putchar('\n');
     137:         return;
     138:
     139:     case CODE:
     140:         n = (struct nlist *)sp[-1];
     141:         sp--;
     142:         switch(n->use){
     143:         default:
     144:             error("not a fn");
     145:         case NF:
     146:         case MF:
     147:         case DF:
     148:             if(n->itemp == 0)
     149:                 funcomp(n);
     150:             ip = (int *)n->itemp;
     151:             for(i=0; i <= *ip; i++){
     152:                 printf(" [%d] ", i);
     153:                 dump(ip[i+1], 0);
     154:             }
     155:             putchar('\n');
     156:         }
     157:         return;
     158:
     159:     case RESET:
     160:         while(gsip)
     161:             ex_ibr0();
     162:         error("");
     163:
     164:     case SICOM:
     165:         tback(1);
     166:         return;
     167:
     168:     case CLEAR:
     169:         clear();
     170:         printf("clear ws\n");
     171:         goto warp1;     /* four lines down, or so... */
     172:
     173:     case LOAD:
     174:         i = opn(vfname(fname), 0);
     175:         clear();
     176:         wsload(i);
     177:         printf(" %s\n", fname);
     178:         evLlx();    /* possible latent expr evaluation */
     179: warp1:
     180:         /*
     181: 		 * this garbage is necessary because clear()
     182: 		 * does a brk(&end), and the normal return & cleanup
     183: 		 * procedures are guaranteed to fail (miserably).
     184: 		 *		--jjb 1/78
     185: 		 */
     186:         sp = stack;
     187:         reset();
     188:
     189:     case LIB:
     190:         listdir();
     191:         return;
     192:
     193:     case COPY:
     194:         if(gsip)
     195:             error("si damage -- type ')reset'");
     196:         wsload(opn(vfname(fname),0));
     197:         printf(" copy %s\n", fname);
     198:         return;
     199:
     200:     case DROPC:
     201:         cp = vfname(fname);
     202:         if(unlink(cp) == -1)
     203:             printf("[can't remove %s]\n", cp);
     204:         return;
     205:
     206:     case SAVE:
     207:         i = opn(vfname(fname), 0644);
     208:         wssave(i);
     209:         printf(" saved %s\n", fname);
     210:         return;
     211:
     212:     case VSAVE:
     213:         i = opn(vfname(fname), 0644);
     214:         vsave(i);
     215:         putchar('\n');
     216:         return;
     217:
     218:
     219:     case SHELL:
     220:         ex_shell();
     221:         return;
     222:
     223:     case LIST:
     224:         ex_list();
     225:         return;
     226:
     227:     case PRWS:
     228:         ex_prws();
     229:         return;
     230:
     231:     }
     232: }
     233:
     234: char *
     235: vfname(array)
     236: char *array;
     237: {
     238:     register struct nlist *n;
     239:     register char *p;
     240:
     241:     n = (struct nlist *)sp[-1];
     242:     sp--;
     243:     if(n->type != LV)
     244:         error("save B");
     245:     p = n->namep;
     246:     while(*array++ = *p++);
     247:     return(n->namep);
     248:
     249: }
     250:
     251: /*
     252:  * check for latent expr., and evaluate it if it is there:
     253:  */
     254: evLlx()
     255: {
     256:     register struct nlist *n;
     257:     register struct item *p;
     258:
     259:     if((n=nlook("Llx")) && n->itemp->type == CH && n->itemp->size){
     260:         *sp++ = dupdat(n->itemp);
     261:         ex_meps();
     262:         p = sp[-1];
     263:         if(p->type != EL && p->type != DU)
     264:             ex_print();
     265:         pop();
     266: /*		error("");	*/
     267:     }
     268: }

#### Defined functions

evLlx defined in line 254; used 2 times

- in line 178
- in /usr/src/new/PORT/apl/src/a0.c line 130

ex_immed defined in line 4; used 2 times

- in /usr/src/new/PORT/apl/src/at.c line 66, 225

vfname defined in line 234; used 7 times

- in line 11, 24, 174, 196-201(2), 207, 213

#### Defined variables

Sccsid defined in line 1; never used

Last modified: 1983-06-22 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1285 |